Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / devices / ioram / include / ioram.h
/*
* ========== Copyright Header Begin ==========================================
*
* OpenSPARC T2 Processor File: ioram.h
* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
*
* The above named program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License version 2 as published by the Free Software Foundation.
*
* The above named program is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this work; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
* ========== Copyright Header End ============================================
*/
#ifndef __SAM_IOMEM_H__
#define _SAM_IOMEM_H__
// SAM IOMem module. Built as a wrapper around Sparse Memory class.
#include <assert.h>
#include <pthread.h>
// sam includes
#include "types.h"
#include "module.h"
#include "arg.h"
#include "mmi.h"
#include "sparse_mem.h"
#include "cpu_interface.h"
class IOMem:public Module{
// configurable parameters for the module
// physical address space to be mapped by IOMem
uint64_t sAddr;
uint64_t eAddr;
uint64_t mem_size;
const char * loadFile;
uint64_t loadAddr;
uint64_t *mem;
int iomemWrite(uint64_t addr, uint64_t buf, int size);
int iomemRead(uint64_t addr, uint64_t * buf, int size);
ioMemIntf* memIf;
enum accessType { RW, RO, WO };
enum fileType { BIN, IMG, ELF , NONE };
enum memType { SPARSE, FLAT };
enum cmdType { READ, WRITE, DIS, SAVE, DUMP, UNKNWN };
fileType ft;
accessType at;
memType mt;
bool addrInvalid(uint64_t addr);
bool getNum(const char * s, uint64_t * val);
bool numArgsOK(int argc, char * args[]);
void ui_write(char * args[]);
void ui_read(char * args[]);
void ui_dump(char * args[]);
void ui_dis(char * args[]);
void ui_save(char * args[]);
void ui_cmd_usage();
public:
void handle_ui(int argc, char * argv[]);
// handle load/stores from SAM for this module
int iomemHandler(uint32_t cpuid,uint64_t paddr, mmi_bool_t wr, uint32_t size, uint64_t* buf, uint8_t bytemask);
// constructor
IOMem(const char *_modname, const char *_instance_name);
~IOMem(){}
// SAM Module functions
const char *get_help();
bool parse_arg(const char *);
bool check_args();
void init_done();
void modinfo();
void module_added(mmi_instance_t, const char*){return; }
void module_deleted(mmi_instance_t, const char*){return;}
bool dump(FILE *fp);
bool restore(FILE *fp);
void *get_interface(const char*){return 0;}
};
// callback function to steer load/stores to this module
extern "C"{
int iomemLdSt(uint32_t cpuid, void* obj, uint64_t paddr, mmi_bool_t wr, uint32_t size, uint64_t* buf, uint8_t bytemask);
int iomem_ui_cmd(void*, int argc, char * argv[]);
}
#endif // __SAM_IOMEM_H__