Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | /* |
2 | * ========== Copyright Header Begin ========================================== | |
3 | * | |
4 | * OpenSPARC T2 Processor File: ioram.h | |
5 | * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. | |
6 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES. | |
7 | * | |
8 | * The above named program is free software; you can redistribute it and/or | |
9 | * modify it under the terms of the GNU General Public | |
10 | * License version 2 as published by the Free Software Foundation. | |
11 | * | |
12 | * The above named program is distributed in the hope that it will be | |
13 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | * General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public | |
18 | * License along with this work; if not, write to the Free Software | |
19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. | |
20 | * | |
21 | * ========== Copyright Header End ============================================ | |
22 | */ | |
23 | #ifndef __SAM_IOMEM_H__ | |
24 | #define _SAM_IOMEM_H__ | |
25 | ||
26 | // SAM IOMem module. Built as a wrapper around Sparse Memory class. | |
27 | ||
28 | #include <assert.h> | |
29 | #include <pthread.h> | |
30 | // sam includes | |
31 | #include "types.h" | |
32 | #include "module.h" | |
33 | #include "arg.h" | |
34 | #include "mmi.h" | |
35 | #include "sparse_mem.h" | |
36 | #include "cpu_interface.h" | |
37 | ||
38 | class IOMem:public Module{ | |
39 | ||
40 | // configurable parameters for the module | |
41 | ||
42 | // physical address space to be mapped by IOMem | |
43 | uint64_t sAddr; | |
44 | uint64_t eAddr; | |
45 | uint64_t mem_size; | |
46 | const char * loadFile; | |
47 | uint64_t loadAddr; | |
48 | uint64_t *mem; | |
49 | ||
50 | int iomemWrite(uint64_t addr, uint64_t buf, int size); | |
51 | int iomemRead(uint64_t addr, uint64_t * buf, int size); | |
52 | ||
53 | ioMemIntf* memIf; | |
54 | ||
55 | enum accessType { RW, RO, WO }; | |
56 | enum fileType { BIN, IMG, ELF , NONE }; | |
57 | enum memType { SPARSE, FLAT }; | |
58 | enum cmdType { READ, WRITE, DIS, SAVE, DUMP, UNKNWN }; | |
59 | ||
60 | fileType ft; | |
61 | accessType at; | |
62 | memType mt; | |
63 | ||
64 | bool addrInvalid(uint64_t addr); | |
65 | bool getNum(const char * s, uint64_t * val); | |
66 | bool numArgsOK(int argc, char * args[]); | |
67 | ||
68 | void ui_write(char * args[]); | |
69 | void ui_read(char * args[]); | |
70 | void ui_dump(char * args[]); | |
71 | void ui_dis(char * args[]); | |
72 | void ui_save(char * args[]); | |
73 | void ui_cmd_usage(); | |
74 | ||
75 | public: | |
76 | void handle_ui(int argc, char * argv[]); | |
77 | ||
78 | // handle load/stores from SAM for this module | |
79 | int iomemHandler(uint32_t cpuid,uint64_t paddr, mmi_bool_t wr, uint32_t size, uint64_t* buf, uint8_t bytemask); | |
80 | // constructor | |
81 | IOMem(const char *_modname, const char *_instance_name); | |
82 | ~IOMem(){} | |
83 | // SAM Module functions | |
84 | const char *get_help(); | |
85 | bool parse_arg(const char *); | |
86 | bool check_args(); | |
87 | void init_done(); | |
88 | void modinfo(); | |
89 | void module_added(mmi_instance_t, const char*){return; } | |
90 | void module_deleted(mmi_instance_t, const char*){return;} | |
91 | bool dump(FILE *fp); | |
92 | bool restore(FILE *fp); | |
93 | void *get_interface(const char*){return 0;} | |
94 | }; | |
95 | ||
96 | // callback function to steer load/stores to this module | |
97 | extern "C"{ | |
98 | int iomemLdSt(uint32_t cpuid, void* obj, uint64_t paddr, mmi_bool_t wr, uint32_t size, uint64_t* buf, uint8_t bytemask); | |
99 | int iomem_ui_cmd(void*, int argc, char * argv[]); | |
100 | } | |
101 | ||
102 | #endif // __SAM_IOMEM_H__ |