Changeset 160
- Timestamp:
- Jun 12, 2012, 4:21:27 PM (12 years ago)
- Location:
- soft/giet_vm
- Files:
-
- 128 added
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/Makefile
r158 r160 4 4 DU=mipsel-unknown-elf-objdump 5 5 6 SYS_OBJS = reset.o \7 boot_handler.o \8 giet.o \9 switch.o \10 common.o \11 ctx_handler.o \12 drivers.o \13 exc_handler.o \14 irq_handler.o\15 sys_handler.o6 SYS_OBJS = giet.o \ 7 switch.o \ 8 common.o \ 9 ctx_handler.o \ 10 drivers.o \ 11 exc_handler.o \ 12 irq_handler.o \ 13 sys_handler.o \ 14 init.o \ 15 task_init.o 16 16 17 PGCD_OBJS = pgcd_stdio.o \ 18 pgcd_main.o 19 20 HELLO_OBJS = hello_stdio.o \ 21 hello_main.o 22 23 FIFO_OBJS = fifo_stdio.o \ 24 fifo_main.o \ 25 fifo_mwmr.o 26 27 ROUTER_OBJS = router_stdio.o \ 28 router_main.o \ 29 router_mwmr.o 17 BOOT_OBJS = reset.o \ 18 boot_handler.o 30 19 31 20 SYS_PATH = sys 32 HELLO_PATH = hello 33 FIFO_PATH = fifo 34 PGCD_PATH = pgcd 35 ROUTER_PATH = router 21 BOOT_PATH = boot 36 22 MAP_PATH = xml 37 23 LIBS_PATH = libs 24 BUILD_DIR_NAME = build 38 25 39 CFLAGS=-Wall -ffreestanding -mno-gpopt -mips32 26 CFLAGS=-Wall -ffreestanding -mno-gpopt -mips32 -g 40 27 41 28 SYS_INCLUDE = -I$(SYS_PATH) -I$(MAP_PATH) -I$(LIBS_PATH) -I. 42 HELLO_INCLUDE= -I$(HELLO_PATH) -I$(LIBS_PATH)43 FIFO_INCLUDE= -I$(FIFO_PATH) -I$(LIBS_PATH)44 PGCD_INCLUDE= -I$(PGCD_PATH) -I$(LIBS_PATH)45 ROUTER_INCLUDE= -I$(ROUTER_PATH) -I$(LIBS_PATH)46 29 47 all: sys.bin hello.bin router.bin fifo.bin pgcd.bin map.bin 30 BOOT_INCLUDE = -I$(BOOT_PATH) -I$(MAP_PATH) -I$(LIBS_PATH) -I. 31 32 #commons between sys and boot are: common.ld , mips_registers.h... 33 34 TRASH= /dev/null||true 35 36 .PHONY: apps prepare 37 38 all: prepare soft.bin 39 40 41 ## merge all *.bin to soft.bin 42 soft.bin: boot.bin sys.bin map.bin apps 43 make -C mover 44 mover/mover.x -sm map.bin 45 $(DU) -D $@ > $@.txt 46 47 ## prepare the environement 48 prepare: 49 @mkdir $(BUILD_DIR_NAME) 2>$(TRASH) 48 50 49 51 ## mapping compilation 50 51 52 map.bin: map.xml 53 make -C xml #compile the parser 52 54 xml/xml2bin map.xml map.bin 53 55 54 56 ## system compilation 55 56 57 sys.bin: $(SYS_OBJS) $(SYS_PATH)/sys.ld 57 $(LD) -o $@ -T $(SYS_PATH)/sys.ld $(SYS_OBJS)58 $(DU) -D $@ > $@.txt58 (cd $(BUILD_DIR_NAME); $(LD) -o ../$@ -T ../$(SYS_PATH)/sys.ld $(SYS_OBJS) ) 59 (cd $(BUILD_DIR_NAME); $(DU) -D ../$@ > $@.txt) 59 60 60 61 switch.o: $(SYS_PATH)/switch.s giet_config.h 61 $(AS) -g -mips32 -o $ @ $<62 $(AS) -g -mips32 -o $(BUILD_DIR_NAME)/$@ $< 62 63 63 64 giet.o: $(SYS_PATH)/giet.s giet_config.h 64 $(AS) -g -mips32 -o $ @ $<65 $(AS) -g -mips32 -o $(BUILD_DIR_NAME)/$@ $< 65 66 66 reset.o: $(SYS_PATH)/reset.S giet_config.h 67 $(CC) $(CFLAGS) $(SYS_INCLUDE) -c -o $@ $< 68 $(DU) -D $@ > $@.txt 69 70 boot_handler.o: $(SYS_PATH)/boot_handler.c $(SYS_PATH)/boot_handler.h giet_config.h 71 $(CC) $(CFLAGS) $(SYS_INCLUDE) -c -o $@ $< 67 task_init.o: $(SYS_PATH)/task_init.S giet_config.h 68 #$(AS) -g -mips32 -o $(BUILD_DIR_NAME)/$@ $< 69 $(CC) $(CFLAGS) $(SYS_INCLUDE) -c -o $(BUILD_DIR_NAME)/$@ $< 70 $(DU) -D $(BUILD_DIR_NAME)/$@ > $(BUILD_DIR_NAME)/$@.txt 72 71 73 72 ctx_handler.o: $(SYS_PATH)/ctx_handler.c $(SYS_PATH)/ctx_handler.h giet_config.h 74 $(CC) $(CFLAGS) $(SYS_INCLUDE) -c -o $ @ $<73 $(CC) $(CFLAGS) $(SYS_INCLUDE) -c -o $(BUILD_DIR_NAME)/$@ $< 75 74 76 75 exc_handler.o: $(SYS_PATH)/exc_handler.c $(SYS_PATH)/exc_handler.h giet_config.h 77 $(CC) $(CFLAGS) $(SYS_INCLUDE) -c -o $ @ $<76 $(CC) $(CFLAGS) $(SYS_INCLUDE) -c -o $(BUILD_DIR_NAME)/$@ $< 78 77 79 78 irq_handler.o: $(SYS_PATH)/irq_handler.c $(SYS_PATH)/irq_handler.h giet_config.h 80 $(CC) $(CFLAGS) $(SYS_INCLUDE) -c -o $ @ $<79 $(CC) $(CFLAGS) $(SYS_INCLUDE) -c -o $(BUILD_DIR_NAME)/$@ $< 81 80 82 81 sys_handler.o: $(SYS_PATH)/sys_handler.c $(SYS_PATH)/sys_handler.h giet_config.h 83 $(CC) $(CFLAGS) $(SYS_INCLUDE) -c -o $ @ $<82 $(CC) $(CFLAGS) $(SYS_INCLUDE) -c -o $(BUILD_DIR_NAME)/$@ $< 84 83 85 84 drivers.o: $(SYS_PATH)/drivers.c $(SYS_PATH)/drivers.h giet_config.h 86 $(CC) $(CFLAGS) $(SYS_INCLUDE) -c -o $ @ $<85 $(CC) $(CFLAGS) $(SYS_INCLUDE) -c -o $(BUILD_DIR_NAME)/$@ $< 87 86 88 87 common.o: $(SYS_PATH)/common.c $(SYS_PATH)/common.h giet_config.h 89 $(CC) $(CFLAGS) $(SYS_INCLUDE) -c -o $ @ $<88 $(CC) $(CFLAGS) $(SYS_INCLUDE) -c -o $(BUILD_DIR_NAME)/$@ $< 90 89 91 ## application "hello" compilation 90 init.o: $(SYS_PATH)/init.c giet_config.h 91 $(CC) $(CFLAGS) $(SYS_INCLUDE) -c -o $(BUILD_DIR_NAME)/$@ $< 92 92 93 hello.bin: $(HELLO_OBJS) $(HELLO_PATH)/hello.ld 94 $(LD) -o $@ -T $(HELLO_PATH)/hello.ld $(HELLO_OBJS) 95 $(DU) -D $@ > $@.txt 93 ## boot compilation 94 boot.bin: $(BOOT_OBJS) $(BOOT_PATH)/boot.ld 95 (cd $(BUILD_DIR_NAME); $(LD) -o ../$@ -T ../$(BOOT_PATH)/boot.ld $(BOOT_OBJS) ) 96 (cd $(BUILD_DIR_NAME); $(DU) -D ../$@ > $@.txt) 96 97 97 hello_stdio.o: $(LIBS_PATH)/stdio.c $(LIBS_PATH)/stdio.h giet_config.h 98 $(CC) $(CFLAGS) $(HELLO_INCLUDE) -c -o $@ $< 98 reset.o: $(BOOT_PATH)/reset.S giet_config.h 99 $(CC) $(CFLAGS) $(BOOT_INCLUDE) -c -o $(BUILD_DIR_NAME)/$@ $< 100 $(DU) -D $(BUILD_DIR_NAME)/$@ > $(BUILD_DIR_NAME)/$@.txt 99 101 100 hello_main.o: $(HELLO_PATH)/main.cgiet_config.h101 $(CC) $(CFLAGS) $( HELLO_INCLUDE) -c -o$@ $<102 boot_handler.o: $(BOOT_PATH)/boot_handler.c $(BOOT_PATH)/boot_handler.h giet_config.h 103 $(CC) $(CFLAGS) $(BOOT_INCLUDE) -c -o $(BUILD_DIR_NAME)/$@ $< 102 104 103 ## application "fifo" compilation 104 105 fifo.bin: $(FIFO_OBJS) $(FIFO_PATH)/fifo.ld 106 $(LD) -o $@ -T $(FIFO_PATH)/fifo.ld $(FIFO_OBJS) 107 $(DU) -D $@ > $@.txt 108 109 fifo_stdio.o: $(LIBS_PATH)/stdio.c $(LIBS_PATH)/stdio.h giet_config.h 110 $(CC) $(CFLAGS) $(FIFO_INCLUDE) -c -o $@ $< 111 112 fifo_mwmr.o: $(LIBS_PATH)/mwmr.c $(LIBS_PATH)/mwmr.h giet_config.h 113 $(CC) $(CFLAGS) $(FIFO_INCLUDE) -c -o $@ $< 114 115 fifo_main.o: $(FIFO_PATH)/main.c giet_config.h 116 $(CC) $(CFLAGS) $(FIFO_INCLUDE) -c -o $@ $< 117 118 ## application "router" compilation 119 120 router.bin: $(ROUTER_OBJS) $(ROUTER_PATH)/router.ld 121 $(LD) -o $@ -T $(ROUTER_PATH)/router.ld $(ROUTER_OBJS) 122 $(DU) -D $@ > $@.txt 123 124 router_stdio.o: $(LIBS_PATH)/stdio.c $(LIBS_PATH)/stdio.h giet_config.h 125 $(CC) $(CFLAGS) $(ROUTER_INCLUDE) -c -o $@ $< 126 127 router_mwmr.o: $(LIBS_PATH)/mwmr.c $(LIBS_PATH)/mwmr.h giet_config.h 128 $(CC) $(CFLAGS) $(ROUTER_INCLUDE) -c -o $@ $< 129 130 router_main.o: $(ROUTER_PATH)/main.c giet_config.h 131 $(CC) $(CFLAGS) $(ROUTER_INCLUDE) -c -o $@ $< 132 133 ## application "pgcd" compilation 134 135 pgcd.bin: $(PGCD_OBJS) $(PGCD_PATH)/pgcd.ld 136 $(LD) -o $@ -T $(PGCD_PATH)/pgcd.ld $(PGCD_OBJS) 137 $(DU) -D $@ > $@.txt 138 139 pgcd_stdio.o: $(LIBS_PATH)/stdio.c $(LIBS_PATH)/stdio.h giet_config.h 140 $(CC) $(CFLAGS) $(PGCD_INCLUDE) -c -o $@ $< 141 142 pgcd_main.o: $(PGCD_PATH)/main.c giet_config.h 143 $(CC) $(CFLAGS) $(PGCD_INCLUDE) -c -o $@ $< 105 ## applications and libs compilation 106 apps: 107 @echo "---------------------------------------------BUILDING APPS------------------------------------------------------" 108 make -C apps 144 109 145 110 ### special rules 146 147 111 clean: 148 rm -f *.o *.bin *.txt core *~ 112 rm -f *.o *.bin *.txt core *~ 2>$(TRASH) 113 make clean -C xml/ 2>$(TRASH) 114 make clean -C mover/ 2>$(TRASH) 115 make clean -C apps 2>$(TRASH) 116 rm -r $(BUILD_DIR_NAME) 2>$(TRASH) -
soft/giet_vm/giet_config.h
r158 r160 15 15 #define BOOT_DEBUG_PT 0 /* display the page tables after mapping */ 16 16 #define BOOT_DEBUG_CTX 0 /* display the task contexts after mapping */ 17 #define INIT_DEBUG_CTX 1 /* display the task contexts after mapping */ 17 18 18 19 #define GIET_DEBUG_SWITCH 0 /* Trace context switchs */ 20 21 22 #define CONFIG_SRL_VERBOSITY TRACE 19 23 20 24 /* hardware parameters */ … … 22 26 #define NB_CLUSTERS 1 /* number of clusters */ 23 27 #define CLUSTER_SPAN 0 /* address increment between clusters */ 24 #define NB_PROCS 4 /* number of processors per cluster */25 #define NB_TIMERS 4 /* number of timers per cluster */26 #define NB_DMAS 4 /* number of DMA channels per cluster */27 #define NB_TTYS 7/* total number of TTY terminals */28 #define NB_PROCS 4 /* number of processors per cluster */ 29 #define NB_TIMERS 4 /* number of timers per cluster */ 30 #define NB_DMAS 4 /* number of DMA channels per cluster */ 31 #define NB_TTYS 9 /* total number of TTY terminals */ 28 32 29 33 /* software parameters */ 30 34 31 #define GIET_NB_TASKS_MAX 4/* max number of tasks per processor */32 #define GIET_NB_VSPACE_MAX 3/* max number of virtual spaces */35 #define GIET_NB_TASKS_MAX 6 /* max number of tasks per processor */ 36 #define GIET_NB_VSPACE_MAX 4 /* max number of virtual spaces */ 33 37 #define GIET_NB_PT2_MAX 16 /* max number of level 2 page tables per vspace */ 34 38 #define GIET_TICK_VALUE 20000 /* context switch period (number of cycles) */ -
soft/giet_vm/libs/barrier.c
r159 r160 5 5 // Copyright (c) UPMC-LIP6 6 6 /////////////////////////////////////////////////////////////////////////////////// 7 // The barrier.c and barrier.h files are part of the GIET nano-kernel.7 // These barrier.c and barrier.h files are part of the GIET nano-kernel. 8 8 // This user-level library provides a synchronisation service between several 9 9 // tasks sharing the same address space in a parallel multi-tasks application. 10 // 11 // The barrier_init(), and the barrier_wait() functions do not require a syscall. 12 // The barrier itself must have been allocated in a non cacheable segment, 13 // if the platform does not provide hardwate cache coherence. 14 // 15 // ALL barriers must be defined in the mapping_info data structure, 16 // to be initialised by the GIET in the boot phase. 17 // The vobj_get_vbase() system call (defined in stdio.c and stdio.h files) 18 // can be used to get the virtual base address of the barrier from it's name. 10 // Neither the barrier_init(), nor the barrier_wait() function require a syscall. 11 // The barrier itself must have been allocated in a shared data segment. 19 12 /////////////////////////////////////////////////////////////////////////////////// 20 21 #include <barrier.h>22 13 23 14 /////////////////////////////////////////////////////////////////////////////////// -
soft/giet_vm/libs/stdio.c
r158 r160 34 34 #define SYSCALL_IOC_READ 0x16 35 35 #define SYSCALL_IOC_COMPLETED 0x17 36 #define SYSCALL_ MWMR_BASE 0x1A36 #define SYSCALL_VOBJ_GET_VBASE 0x1A 37 37 38 38 ////////////////////////////////////////////////////////////////////////////////// … … 720 720 ////////////////////////////////////////////////////////////////////////////////// 721 721 // mwmr_base() 722 // TODO! 722 723 // This function returns in argument buffer the virtual base address 723 724 // of a MWMR communication channel, identified by the two arguments … … 726 727 // must be declared in the mapping_info data structure to be initialised 727 728 // in the boot phase. 728 // - Returns 0 if success, > 0 if error ( channel not defined ) 729 ////////////////////////////////////////////////////////////////////////////////// 730 unsigned int mwmr_base( char* vspace_name, 731 char* mwmr_name, 732 void* buffer ) 733 { 734 return sys_call(SYSCALL_MWMR_BASE, 729 // - Returns the address if success, 0 if error ( channel not defined ) 730 ////////////////////////////////////////////////////////////////////////////////// 731 unsigned int vobj_get_vbase( char* vspace_name, char* vobj_name, 732 unsigned int vobj_type, unsigned int* vobj_buffer) 733 { 734 return sys_call(SYSCALL_VOBJ_GET_VBASE, 735 735 (unsigned int)vspace_name, 736 (unsigned int) mwmr_name,737 (unsigned int) buffer,738 0);736 (unsigned int)vobj_name, 737 (unsigned int)vobj_type, 738 (unsigned int)vobj_buffer); 739 739 } 740 740 //////////////////////////////////////////////////////////////////////////////////// -
soft/giet_vm/libs/stdio.h
r158 r160 8 8 #ifndef _STDIO_H 9 9 #define _STDIO_H 10 11 #include <mapping_info.h> 10 12 11 13 /* MIPS32 related functions */ … … 57 59 unsigned int rand(); 58 60 unsigned int ctx_switch(); 59 unsigned int mwmr_base(char* vspace_name, char* mwmr_name, void* buffer); 61 unsigned int vobj_get_vbase( char* vspace_name, char* vobj_name, 62 unsigned int vobj_type, unsigned int* vobj_buffer); 60 63 61 64 /* -
soft/giet_vm/map.xml
r158 r160 5 5 clusters = "1" 6 6 psegs = "9" 7 ttys = "7" 8 vspaces = "3" 9 globals = "13" 10 syspath = "soft/sys.bin" > 7 ttys = "9" 8 vspaces = "4" 9 globals = "13" > 11 10 12 11 <clusterset> … … 55 54 56 55 <globalset> 57 <vseg name = "seg_boot_code "56 <vseg name = "seg_boot_code_data" 58 57 vbase = "0xbfc00000" 59 length = "0x00008000"60 58 mode = "CX__" 61 59 psegname = "PSEG_ROM" 62 ident = "1" /> 60 ident = "1" > 61 <vobj name = "boot_code_data" 62 type = "ELF" 63 length = "0x00008000" 64 binpath = "boot.bin" 65 /> 66 </vseg> 63 67 64 68 <vseg name = "seg_boot_stack" 65 69 vbase = "0xbfc08000" 66 length = "0x00004000"67 70 mode = "C_W_" 68 71 psegname = "PSEG_ROM" 69 ident = "1" /> 72 ident = "1" > 73 <vobj name = "boot_stack" 74 type = "BUFFER" 75 length = "0x00004000" /> 76 </vseg> 70 77 71 78 <vseg name = "seg_boot_mapping" 72 79 vbase = "0xbfc0c000" 73 length = "0x00004000"74 80 mode = "C_W_" 75 81 psegname = "PSEG_ROM" 76 ident = "1" /> 82 ident = "1" > 83 <vobj name = "boot_mapping" 84 type = "ELF" 85 length = "0x00004000" 86 binpath = "map.bin" 87 /> 88 </vseg> 77 89 78 90 <vseg name = "seg_kernel_code" 79 91 vbase = "0x80000000" 80 length = "0x00010000"81 92 mode = "CX__" 82 93 psegname = "PSEG_RAK" 83 ident = "1" /> 94 ident = "1" > 95 <vobj name = "kernel_code" 96 type = "ELF" 97 length = "0x00010000" 98 binpath = "sys.bin" 99 /> 100 </vseg> 84 101 85 102 <vseg name = "seg_kernel_data" 86 103 vbase = "0x80010000" 87 length = "0x00010000"88 104 mode = "C_W_" 89 105 psegname = "PSEG_RAK" 90 ident = "1" /> 106 ident = "1" > 107 <vobj name = "kernel_data" 108 type = "ELF" 109 length = "0x00010000" 110 binpath = "sys.bin" 111 /> 112 </vseg> 91 113 92 114 <vseg name = "seg_kernel_uncdata" 93 115 vbase = "0x80020000" 94 length = "0x00010000"95 116 mode = "__W_" 96 117 psegname = "PSEG_RAK" 97 ident = "1" /> 98 99 <vseg name = "seg_kernel_pt" 118 ident = "1" > 119 <vobj name = "kernel_uncdata" 120 type = "ELF" 121 length = "0x00010000" 122 binpath = "sys.bin" 123 /> 124 </vseg> 125 126 <vseg name = "seg_kernel_init" 100 127 vbase = "0x80030000" 101 length = "0x00040000" 102 mode = "C_W_" 128 mode = "CX__" 103 129 psegname = "PSEG_RAK" 104 ident = "1" /> 130 ident = "1" > 131 <vobj name = "kernel_init" 132 type = "ELF" 133 length = "0x00010000" 134 binpath = "sys.bin" 135 /> 136 </vseg> 137 105 138 106 139 <vseg name = "seg_tty" 107 140 vbase = "0x90000000" 108 length = "0x00000200"109 141 mode = "__W_" 110 142 psegname = "PSEG_TTY" 111 ident = "1" /> 143 ident = "1" > 144 <vobj name = "tty" 145 type = "PERI" 146 length = "0x00000100" /> 147 </vseg> 112 148 113 149 <vseg name = "seg_timer" 114 150 vbase = "0x91000000" 115 length = "0x00000080"116 151 mode = "__W_" 117 152 psegname = "PSEG_TIM" 118 ident = "1" /> 153 ident = "1" > 154 <vobj name = "timer" 155 type = "PERI" 156 length = "0x00000080" /> 157 </vseg> 119 158 120 159 <vseg name = "seg_ioc" 121 160 vbase = "0x92000000" 122 length = "0x00000020"123 161 mode = "__W_" 124 162 psegname = "PSEG_IOC" 125 ident = "1" /> 163 ident = "1" > 164 <vobj name = "ioc" 165 type = "PERI" 166 length = "0x00000020" /> 167 </vseg> 126 168 127 169 <vseg name = "seg_dma" 128 170 vbase = "0x93000000" 129 length = "0x00000100"130 171 mode = "__W_" 131 172 psegname = "PSEG_DMA" 132 ident = "1" /> 173 ident = "1" > 174 <vobj name = "dma" 175 type = "PERI" 176 length = "0x00000100" /> 177 </vseg> 133 178 134 179 <vseg name = "seg_fb" 135 180 vbase = "0x96000000" 136 length = "0x00004000"137 181 mode = "__W_" 138 182 psegname = "PSEG_FBF" 139 ident = "1" /> 183 ident = "1" > 184 <vobj name = "fb" 185 type = "PERI" 186 length = "0x00004000" /> 187 </vseg> 140 188 141 189 <vseg name = "seg_icu" 142 190 vbase = "0x9F000000" 143 length = "0x00000100"144 191 mode = "__W_" 145 192 psegname = "PSEG_ICU" 146 ident = "1" /> 193 ident = "1" > 194 <vobj name = "icu" 195 type = "PERI" 196 length = "0x00000100" /> 197 </vseg> 147 198 </globalset> 148 199 149 200 <vspaceset> 150 201 <vspace name = "router" 151 binpath = "soft/router.bin" 152 vsegs = "8" 153 tasks = "4" 154 mwmrs = "2" 202 funcs = "data" 155 203 ttys = "4" > 156 204 157 <vseg name = "seg_data "205 <vseg name = "seg_data_router" 158 206 vbase = "0x00800000" 159 length = "0x00010000"160 207 mode = "__WU" 161 208 psegname = "PSEG_RAU" 162 ident = "1" /> 163 <vseg name = "seg_code" 209 ident = "0" > 210 <vobj name = "data" 211 type = "ELF" 212 length = "0x00010000" 213 binpath = "router.bin" 214 /> 215 </vseg> 216 217 <vseg name = "seg_code_router" 164 218 vbase = "0x00400000" 165 length = "0x00010000"166 219 mode = "CX_U" 167 220 psegname = "PSEG_RAU" 168 ident = "1" /> 221 ident = "0" > 222 <vobj name = "code" 223 type = "ELF" 224 length = "0x00010000" 225 binpath = "router.bin" 226 /> 227 </vseg> 228 229 <vseg name = "seg_ptab" 230 vbase = "0x00300000" 231 mode = "C___" 232 psegname = "PSEG_RAU" 233 ident = "0" > 234 <vobj name = "ptab" 235 type = "PTAB" 236 length = "0x00010000" 237 align = "13" 238 /> 239 </vseg> 240 169 241 <vseg name = "seg_stack_producer" 170 vbase = "0x00000000" 171 length = "0x00010000" 172 mode = "C_WU" 173 psegname = "PSEG_RAU" /> 242 vbase = "0x00010000" 243 mode = "C_WU" 244 psegname = "PSEG_RAU" > 245 <vobj name = "stack_producer" 246 type = "BUFFER" 247 length = "0x00010000" /> 248 </vseg> 249 174 250 <vseg name = "seg_stack_consumer" 175 vbase = "0x00010000" 176 length = "0x00010000" 177 mode = "C_WU" 178 psegname = "PSEG_RAU" /> 251 vbase = "0x00020000" 252 mode = "C_WU" 253 psegname = "PSEG_RAU" > 254 <vobj name = "stack_consumer" 255 type = "BUFFER" 256 length = "0x00010000" /> 257 </vseg> 258 179 259 <vseg name = "seg_stack_router_A" 180 vbase = "0x00020000" 181 length = "0x00010000" 182 mode = "C_WU" 183 psegname = "PSEG_RAU" /> 260 vbase = "0x00030000" 261 mode = "C_WU" 262 psegname = "PSEG_RAU" > 263 <vobj name = "stack_router_A" 264 type = "BUFFER" 265 length = "0x00010000" /> 266 </vseg> 267 184 268 <vseg name = "seg_stack_router_B" 185 vbase = "0x00030000" 186 length = "0x00010000" 187 mode = "C_WU" 188 psegname = "PSEG_RAU" /> 269 vbase = "0x00040000" 270 mode = "C_WU" 271 psegname = "PSEG_RAU" > 272 <vobj name = "stack_router_B" 273 type = "BUFFER" 274 length = "0x00010000" /> 275 </vseg> 276 189 277 <vseg name = "seg_mwmr_in" 190 vbase = "0x00040000" 191 length = "0x00001000" 278 vbase = "0x00050000" 192 279 mode = "__WU" 193 280 psegname = "PSEG_RAU" 194 mwmr = "1" /> 281 mwmr = "1" > 282 <vobj name = "mwmr_in" 283 type = "MWMR" 284 length = "0x00000020"/> 285 </vseg> 286 195 287 <vseg name = "seg_mwmr_out" 196 vbase = "0x00050000" 197 length = "0x00001000" 288 vbase = "0x00060000" 198 289 mode = "__WU" 199 290 psegname = "PSEG_RAU" 200 mwmr = "1" /> 291 mwmr = "1" > 292 <vobj name = "mwmr_out" 293 type = "MWMR" 294 length = "0x00000020"/> 295 </vseg> 201 296 202 297 <task name = "producer" 203 298 clusterid = "0" 204 299 proclocid = "0" 205 stackname = "s eg_stack_producer"300 stackname = "stack_producer" 206 301 startid = "0" 207 302 ttylocid = "0" /> … … 209 304 clusterid = "0" 210 305 proclocid = "1" 211 stackname = "s eg_stack_consumer"306 stackname = "stack_consumer" 212 307 startid = "1" 213 308 ttylocid = "1" /> … … 215 310 clusterid = "0" 216 311 proclocid = "2" 217 stackname = "s eg_stack_router_A"312 stackname = "stack_router_A" 218 313 startid = "2" 219 314 ttylocid = "2" /> … … 221 316 clusterid = "0" 222 317 proclocid = "3" 223 stackname = "s eg_stack_router_B"318 stackname = "stack_router_B" 224 319 startid = "2" 225 320 ttylocid = "3" /> … … 227 322 228 323 <vspace name = "hello" 229 binpath = "soft/hello.bin" 230 vsegs = "3" 231 tasks = "1" 232 mwmrs = "0" 324 funcs = "data" 233 325 ttys = "1" > 234 326 235 <vseg name = "seg_data" 236 vbase = "0x00810000" 237 length = "0x00010000" 238 mode = "C_WU" 239 psegname = "PSEG_RAU" 240 ident = "1" /> 327 <vseg name = "seg_data_hello" 328 vbase = "0x00800000" 329 mode = "C_WU" 330 psegname = "PSEG_RAU" 331 ident = "0" > 332 <vobj name = "data" 333 type = "ELF" 334 length = "0x00010000" 335 binpath = "hello.bin"/> 336 </vseg> 337 338 <vseg name = "seg_code_hello" 339 vbase = "0x00400000" 340 mode = "CX_U" 341 psegname = "PSEG_RAU" 342 ident = "0" > 343 <vobj name = "code" 344 type = "ELF" 345 length = "0x00010000" 346 binpath = "hello.bin"/> 347 </vseg> 348 349 <vseg name = "seg_ptab" 350 vbase = "0x00300000" 351 mode = "C___" 352 psegname = "PSEG_RAU" 353 ident = "0" > 354 <vobj name = "ptab" 355 type = "PTAB" 356 length = "0x00010000" 357 align = "13" 358 /> 359 </vseg> 241 360 242 361 <vseg name = "seg_stack" 243 362 vbase = "0x00000000" 244 length = "0x00010000" 245 mode = "C_WU" 246 psegname = "PSEG_RAU" /> 247 248 <vseg name = "seg_code" 249 vbase = "0x00410000" 250 length = "0x00010000" 251 mode = "CX_U" 252 psegname = "PSEG_RAU" 253 ident = "1" /> 363 mode = "C_WU" 364 psegname = "PSEG_RAU" > 365 <vobj name = "stack" 366 type = "BUFFER" 367 length = "0x00010000" /> 368 </vseg> 369 254 370 255 371 <task name = "main_hello" 256 372 clusterid = "0" 257 373 proclocid = "2" 258 stackname = "s eg_stack"374 stackname = "stack" 259 375 startid = "0" 260 376 ttylocid = "0" /> … … 262 378 263 379 <vspace name = "pgcd" 264 binpath = "soft/pgcd.bin" 265 vsegs = "3" 266 tasks = "1" 267 mwmrs = "0" 380 funcs = "data" 268 381 ttys = "1" > 269 382 270 <vseg name = "seg_data" 271 vbase = "0x00820000" 272 length = "0x00010000" 273 mode = "C_WU" 274 psegname = "PSEG_RAU" 275 ident = "1" /> 383 <vseg name = "seg_data_pgcd" 384 vbase = "0x00800000" 385 mode = "C_WU" 386 psegname = "PSEG_RAU" 387 ident = "0" > 388 <vobj name = "data" 389 type = "ELF" 390 length = "0x00010000" 391 binpath = "pgcd.bin" /> 392 </vseg> 393 394 <vseg name = "seg_ptab" 395 vbase = "0x00300000" 396 mode = "C___" 397 psegname = "PSEG_RAU" 398 ident = "0" > 399 <vobj name = "ptab" 400 type = "PTAB" 401 length = "0x00010000" 402 align = "13" 403 /> 404 </vseg> 405 406 <vseg name = "seg_code_pgcd" 407 vbase = "0x00400000" 408 mode = "CX_U" 409 psegname = "PSEG_RAU" 410 ident = "0" > 411 <vobj name = "code" 412 type = "ELF" 413 length = "0x00010000" 414 binpath = "pgcd.bin" /> 415 </vseg> 276 416 277 417 <vseg name = "seg_stack" 278 418 vbase = "0x00000000" 279 length = "0x00010000" 280 mode = "C_WU" 281 psegname = "PSEG_RAU" /> 282 283 <vseg name = "seg_code" 284 vbase = "0x00420000" 285 length = "0x00010000" 419 mode = "C_WU" 420 psegname = "PSEG_RAU" > 421 <vobj name = "stack" 422 type = "BUFFER" 423 length = "0x00010000" /> 424 </vseg> 425 426 427 <task name = "main_pgcd" 428 clusterid = "0" 429 proclocid = "3" 430 stackname = "stack" 431 startid = "0" 432 ttylocid = "0" /> 433 </vspace> 434 435 <vspace name = "numsplit" 436 funcs = "data" 437 ttys = "2" > 438 439 <vseg name = "seg_data_numsplit" 440 vbase = "0x00800000" 441 mode = "__WU" 442 psegname = "PSEG_RAU" 443 ident = "0" > 444 <vobj name = "data" 445 type = "ELF" 446 length = "0x00010000" 447 binpath = "numsplit.bin" 448 /> 449 </vseg> 450 451 <vseg name = "seg_code_numsplit" 452 vbase = "0x00400000" 286 453 mode = "CX_U" 287 454 psegname = "PSEG_RAU" 288 ident = "1" /> 289 290 <task name = "main_pgcd" 291 clusterid = "0" 292 proclocid = "3" 293 stackname = "seg_stack" 294 startid = "0" 455 ident = "0" > 456 <vobj name = "code" 457 type = "ELF" 458 length = "0x00010000" 459 binpath = "numsplit.bin" 460 /> 461 </vseg> 462 463 <vseg name = "seg_ptab" 464 vbase = "0x00300000" 465 mode = "C___" 466 psegname = "PSEG_RAU" 467 ident = "0" > 468 <vobj name = "ptab" 469 type = "PTAB" 470 length = "0x00010000" 471 align = "13" 472 /> 473 </vseg> 474 475 <vseg name = "seg_stack_producer" 476 vbase = "0x00010000" 477 mode = "C_WU" 478 psegname = "PSEG_RAU" > 479 <vobj name = "stack_producer" 480 type = "BUFFER" 481 length = "0x00010000" /> 482 </vseg> 483 484 <vseg name = "seg_stack_consumer" 485 vbase = "0x00020000" 486 mode = "C_WU" 487 psegname = "PSEG_RAU" > 488 <vobj name = "stack_consumer" 489 type = "BUFFER" 490 length = "0x00010000" /> 491 </vseg> 492 493 <vseg name = "seg_mwmr" 494 vbase = "0x00050000" 495 mode = "__WU" 496 psegname = "PSEG_RAU" 497 mwmr = "1" > 498 <vobj name = "mwmr" 499 type = "MWMR" 500 length = "0x00000080"/> 501 </vseg> 502 503 <task name = "producer" 504 clusterid = "0" 505 proclocid = "0" 506 stackname = "stack_producer" 507 startid = "0" 508 ttylocid = "1" /> 509 510 <task name = "consumer" 511 clusterid = "0" 512 proclocid = "1" 513 stackname = "stack_consumer" 514 startid = "1" 295 515 ttylocid = "0" /> 296 516 </vspace> -
soft/giet_vm/sys/common.c
r158 r160 9 9 /////////////////////////////////////////////////////////////////////////////////// 10 10 11 #include <mapping_info.h>12 11 #include <common.h> 13 12 #include <drivers.h> … … 216 215 } 217 216 ///////////////////////////////////////////////////////////////////////////// 218 mapping_ task_t* _get_task_base( mapping_header_t* header )219 { 220 return (mapping_ task_t*)((char*)header +217 mapping_vobj_t* _get_vobj_base( mapping_header_t* header ) 218 { 219 return (mapping_vobj_t*) ((char*)header + 221 220 MAPPING_HEADER_SIZE + 222 221 MAPPING_CLUSTER_SIZE*header->clusters + 223 222 MAPPING_PSEG_SIZE*header->psegs + 224 223 MAPPING_VSPACE_SIZE*header->vspaces + 224 MAPPING_VSEG_SIZE*header->vsegs ); 225 } 226 ///////////////////////////////////////////////////////////////////////////// 227 mapping_task_t* _get_task_base( mapping_header_t* header ) 228 { 229 return (mapping_task_t*) ((char*)header + 230 MAPPING_HEADER_SIZE + 231 MAPPING_CLUSTER_SIZE*header->clusters + 232 MAPPING_PSEG_SIZE*header->psegs + 233 MAPPING_VSPACE_SIZE*header->vspaces + 234 MAPPING_VOBJ_SIZE*header->vobjs + 225 235 MAPPING_VSEG_SIZE*header->vsegs); 226 236 } 227 237 238 -
soft/giet_vm/sys/common.h
r158 r160 24 24 extern _ld_symbol_t seg_fb_base; 25 25 extern _ld_symbol_t seg_ioc_base; 26 extern _ld_symbol_t seg_ boot_mapping_base;26 extern _ld_symbol_t seg_mapping_base; 27 27 extern _ld_symbol_t seg_kernel_pt_base; 28 28 … … 49 49 mapping_vspace_t* _get_vspace_base( mapping_header_t* header ); 50 50 mapping_vseg_t* _get_vseg_base( mapping_header_t* header ); 51 mapping_vobj_t* _get_vobj_base( mapping_header_t* header ); 51 52 mapping_task_t* _get_task_base( mapping_header_t* header ); 52 53 -
soft/giet_vm/sys/ctx_handler.c
r158 r160 31 31 32 32 #include <giet_config.h> 33 #include <ctx_handler.h>34 #include <sys_handler.h>35 33 #include <drivers.h> 36 34 #include <common.h> 35 #include <ctx_handler.h> 36 #include <mapping_info.h> 37 #include <sys_handler.h> 37 38 38 39 extern void _task_switch(unsigned int *, unsigned int *); … … 71 72 // return if only one task */ 72 73 if ( tasks <= 1) return; 73 74 74 75 // compute the task context base address for the current task 75 76 curr_task_id = _scheduler[proc_id].current; 76 77 curr_context = &(_scheduler[proc_id].context[curr_task_id][0]); 77 78 78 79 // select the next task using a round-robin scheduling policy 79 80 next_task_id = (curr_task_id + 1) % tasks; -
soft/giet_vm/sys/drivers.c
r158 r160 5 5 // Copyright (c) UPMC-LIP6 6 6 /////////////////////////////////////////////////////////////////////////////////// 7 // The vers.c and drivers.h files are part ot the GIET nano kernel.7 // The drivers.c and drivers.h files are part ot the GIET nano kernel. 8 8 // They contains the drivers for the peripherals available in the SoCLib library: 9 9 // - vci_multi_tty … … 204 204 205 205 proc_id = _procid(); 206 206 207 task_id = _scheduler[proc_id].current; 207 208 tty_id = _scheduler[proc_id].context[task_id][CTX_TTY_ID]; -
soft/giet_vm/sys/irq_handler.c
r158 r160 45 45 int interrupt_index; 46 46 _isr_func_t isr; 47 48 // interrupt vector initialisation 49 47 50 48 51 /* retrieves the highest priority active interrupt index */ -
soft/giet_vm/sys/sys.ld
r158 r160 2 2 * Definition of the base address for all virtual segments 3 3 *****************************************************************************/ 4 5 /* The vsegs used in the boot phase must respect identity mapping:6 physical address = virtual address */7 8 seg_boot_code_base = 0xBFC00000; /* boot code */9 seg_boot_stack_base = 0xBFC08000; /* boot temporary stack */10 seg_boot_mapping_base = 0xBFC0C000; /* boot mapping_info */11 4 12 5 /* The vsegs used by the system are replicated in all virtual spaces … … 16 9 seg_kernel_data_base = 0x80010000; /* system cacheable data */ 17 10 seg_kernel_uncdata_base = 0x80020000; /* system uncacheable data */ 18 seg_kernel_ pt_base= 0x80030000; /* system page table */11 seg_kernel_init_base = 0x80030000; /* system page table */ 19 12 20 /* The peripherals base addresses are referenced by the software drivers and 13 14 /* The peripherals base addresses are referenced by the software drivers and \ 21 15 must be defined, even if the peripherals are not used in the architecture */ 22 16 … … 29 23 seg_icu_base = 0x9F000000; /* ICU device */ 30 24 25 /*****************************************/ 26 seg_mapping_base = 0xBFC0C000; /* boot mapping_info */ 27 31 28 /* 32 29 * Grouping sections into segments for system code and data … … 35 32 SECTIONS 36 33 { 37 . = seg_boot_code_base;38 seg_boot_code :39 {40 *(.boot)41 }42 34 . = seg_kernel_code_base; 43 35 seg_kernel_code : … … 69 61 *(.unckdata) 70 62 } 71 . = seg_kernel_pt_base; 72 seg_kernel_pt : 63 64 . = seg_kernel_init_base; 65 seg_kernel_init : 73 66 { 74 *(.ptab) 67 *(.kinitentry) 68 *(.kinit) 75 69 } 76 70 } -
soft/giet_vm/sys/sys_handler.c
r158 r160 12 12 13 13 #include <sys_handler.h> 14 #include <boot_handler.h>14 //#include <boot_handler.h> 15 15 #include <drivers.h> 16 16 #include <ctx_handler.h> … … 49 49 &_sys_ukn, /* 0x18 */ 50 50 &_sys_ukn, /* 0x19 */ 51 &_ mwmr_base,/* 0x1A */51 &_vobj_get_vbase, /* 0x1A */ 52 52 &_sys_ukn, /* 0x1B */ 53 53 &_sys_ukn, /* 0x1C */ … … 117 117 unsigned int* buffer) 118 118 { 119 mapping_header_t* header = (mapping_header_t*)&seg_ boot_mapping_base;119 mapping_header_t* header = (mapping_header_t*)&seg_mapping_base; 120 120 mapping_cluster_t* cluster = _get_cluster_base( header ); 121 121 … … 131 131 } 132 132 ///////////////////////////////////////////////////////////////////////////// 133 // _mwmr_base() 134 // returns in buffer argument the base address of the MWMR channel 135 // identified by the (vspace_name / channel_name) couple. 133 // _vobj_get_base() 134 // returns 0: success, else: failed. 135 // give access to the base address of a vobj identified by the (vspace_name / channel_name ) couple. 136 // The "type" argument is here for checking purpose. 136 137 ///////////////////////////////////////////////////////////////////////////// 137 unsigned int _mwmr_base( char* vspace_name, 138 char* channel_name, 139 unsigned int* buffer ) 138 unsigned int _vobj_get_vbase( char* vspace_name, char* vobj_name, 139 unsigned vobj_type, unsigned int* vobj_buffer) 140 140 { 141 mapping_header_t* header = (mapping_header_t*)&seg_ boot_mapping_base;141 mapping_header_t* header = (mapping_header_t*)&seg_mapping_base; 142 142 mapping_vspace_t* vspace = _get_vspace_base( header ); 143 mapping_v seg_t* vseg = _get_vseg_base( header );143 mapping_vobj_t* vobj = _get_vobj_base( header ); 144 144 145 145 unsigned int vspace_id; 146 unsigned int vseg_id; 146 unsigned int vobj_id; 147 147 148 148 149 // scan vspaces … … 151 152 if ( _strncmp( vspace[vspace_id].name, vspace_name, 31) == 0 ) 152 153 { 153 // scan vsegs 154 for ( vseg_id = vspace[vspace_id].vseg_offset ; 155 vseg_id < (vspace[vspace_id].vseg_offset + vspace[vspace_id].vsegs) ; 156 vseg_id++ ) 154 // scan vobjs 155 for(vobj_id= vspace[vspace_id].vobj_offset; vobj_id < (vspace[vspace_id].vobj_offset + vspace[vspace_id].vobjs); vobj_id++) 157 156 { 158 if ( _strncmp( vseg[vseg_id].name, channel_name, 31) == 0 ) 157 158 if ( _strncmp( vobj[vobj_id].name, vobj_name, 31) == 0 ) 159 159 { 160 *buffer = vseg[vseg_id].vbase; 160 if(vobj[vobj_id].type != vobj_type) 161 return -1;//wrong type 162 163 *vobj_buffer = (unsigned int)vobj[vobj_id].vaddr; 161 164 return 0; 162 165 } … … 165 168 } 166 169 // not found !!! 167 return 1;170 return -2; 168 171 } 169 172 -
soft/giet_vm/sys/sys_handler.h
r158 r160 30 30 unsigned int* buffer ); 31 31 32 unsigned int _mwmr_base( char* vspace_name, 33 char* channel_name, 34 unsigned int* buffer); 35 32 unsigned int _vobj_get_vbase( char* vspace_name, char* vobj_name, 33 unsigned vobj_type, unsigned int* vobj_buffer); 36 34 #endif -
soft/giet_vm/xml/Makefile
r158 r160 8 8 gcc -Wall -I. -I/usr/include/libxml2 xml_parser.c -o xml2bin -lxml2 9 9 10 test: 11 ./xml2bin map.xml test.bin 12 ./bin2xml test.bin test.xml 13 14 up_test: 15 ./xml2bin ../map.xml ../test.bin 16 ./bin2xml ../test.bin ../test.xml 17 18 10 19 clean: 11 20 rm xml2bin bin2xml -
soft/giet_vm/xml/mapping_info.h
r158 r160 18 18 // - mapping_vspace_t vspace[vspaces] (MAPPING_VSPACE_SIZE * vspaces) 19 19 // - mapping_vseg_t vseg[vsegs] (MAPPING_VSEG_SIZE * vsegs) 20 // - mapping_vseg_t vobj[vsegs] (MAPPING_VOBJ_SIZE * vsegs) 20 21 // - mapping_task_t task[tasks] (MAPPING_TASK_SIZE * tasks) 21 // - mapping_mwmr_t mwmr[mwmrs] (MAPPING_MWMR_SIZE * mwmrs)22 22 // 23 23 // The number of clusters and the number of vspaces are defined in the header. … … 43 43 #define MAPPING_VSPACE_SIZE sizeof(mapping_vspace_t) 44 44 #define MAPPING_VSEG_SIZE sizeof(mapping_vseg_t) 45 #define MAPPING_VOBJ_SIZE sizeof(mapping_vobj_t) 45 46 #define MAPPING_PSEG_SIZE sizeof(mapping_pseg_t) 46 47 #define MAPPING_TASK_SIZE sizeof(mapping_task_t) … … 54 55 #define OUT_MAPPING_SIGNATURE 0xBABEF00D 55 56 57 enum 58 { 59 ELF = 0, //loadable code object 60 PTAB, //page table 61 PERI, //hardware component 62 MWMR, //MWMR channel 63 LOCK, //Lock 64 BUFFER, //Any "no intialiasation needed" objects (stacks...) 65 BARRIER //Barrier 66 }; 67 68 56 69 /////////////////////////////// 57 70 typedef struct mapping_header_s … … 63 76 unsigned int globals; // number of vsegs mapped in all vspaces 64 77 unsigned int vspaces; // number of virtual spaces 65 unsigned int vsegs; // total number of virtual segments (for all vspaces 78 unsigned int vsegs; // total number of virtual segments (for all vspaces) 79 unsigned int vobjs; // total number of virtual memory objects (for all vspaces) 66 80 unsigned int tasks; // total number of tasks (for all vspaces) 67 81 char name[32]; // mapping name 68 char syspath[64]; // path for the system binary code ("sys.bin")69 82 } mapping_header_t; 70 83 … … 90 103 { 91 104 char name[32]; // virtual space name 92 char binpath[64]; // pathname to the binary code ("app.bin")105 unsigned int funcs_offset; // offset of the vobj containing the function entry table (relative to vobj_offset) 93 106 unsigned int vsegs; // number of private virtual segments 107 unsigned int vobjs; // number of vobjs channels 94 108 unsigned int tasks; // number of tasks 95 unsigned int mwmrs; // number of mwmr channels96 109 unsigned int ttys; // number of required TTY terminals 97 110 unsigned int vseg_offset; // index of first vseg in vspace 111 unsigned int vobj_offset; // index of first vobjs in vspace 98 112 unsigned int task_offset; // index of first task in vspace 99 unsigned int mwmr_offset; // index of first mwmr in vspace100 113 } mapping_vspace_t; 101 114 … … 110 123 unsigned char mode; // C-X-W-U flags 111 124 unsigned char ident; // identity mapping if non zero 112 unsigned char mwmr; // mwmr channel if non zero 125 unsigned int vobjs; // number of vobjs channels 126 unsigned int vobj_offset; // index of first vobjs in vspace 113 127 unsigned char reserved; // unused 114 128 } mapping_vseg_t; … … 120 134 unsigned int clusterid; // physical cluster index 121 135 unsigned int proclocid; // processor local index (inside cluster) 122 unsigned int v seglocid; // stack vsegindex in vspace136 unsigned int vobjlocid; // stack vobj index in vspace 123 137 unsigned int startid; // index in start_vector (in seg_data) 124 138 unsigned int ttylocid; // tty index (inside the vspace) 125 139 } mapping_task_t; 140 141 ///////////////////////////// 142 typedef struct mapping_vobj_s 143 { 144 char name[32]; // vobj name (unique in a vspace) 145 char binpath[64]; // path for the binary code ("*.bin") 146 unsigned int type; // type of vobj 147 unsigned int length; // size (bytes) 148 unsigned int align; // required alignement (logarithm of 2) 149 unsigned int vaddr; // virtual addresse of the vobj location (bytes) 150 unsigned int paddr; // physical addresse of the vobj location (bytes) 151 } mapping_vobj_t; 126 152 127 153 #endif -
soft/giet_vm/xml/xml_driver.c
r158 r160 20 20 void buildXml( mapping_header_t* header, FILE* fpout) 21 21 { 22 23 const char* 24 vobj_type[] = 25 { 26 "ELF", 27 "PTAB", //page table 28 "PERI", //hardware component 29 "MWMR", //MWMR channel 30 "LOCK", //Lock 31 "BUFFER", //Any "no intialiasation needed" objects (stacks...) 32 "BARRIER" //Barrier 33 }; 22 34 const char* mode_str[] = { "____", 23 35 "___U", … … 41 53 unsigned int pseg_id; 42 54 unsigned int vseg_id; 55 unsigned int vobj_id; 43 56 unsigned int task_id; 44 57 … … 47 60 mapping_vspace_t* vspace; 48 61 mapping_vseg_t* vseg; 62 mapping_vobj_t* vobj; 49 63 mapping_task_t* task; 50 64 … … 71 85 MAPPING_VSPACE_SIZE*header->vspaces ); 72 86 87 // computes the base adresss for vobjs array, 88 vobj = (mapping_vobj_t*) ((char*)header + 89 MAPPING_HEADER_SIZE + 90 MAPPING_CLUSTER_SIZE*header->clusters + 91 MAPPING_PSEG_SIZE*header->psegs + 92 MAPPING_VSPACE_SIZE*header->vspaces + 93 MAPPING_VSEG_SIZE*header->vsegs ); 94 73 95 // computes the base address for tasks array 74 96 task = (mapping_task_t*) ((char*)header + … … 77 99 MAPPING_PSEG_SIZE*header->psegs + 78 100 MAPPING_VSPACE_SIZE*header->vspaces + 101 MAPPING_VOBJ_SIZE*header->vobjs + 79 102 MAPPING_VSEG_SIZE*header->vsegs ); 80 103 … … 89 112 fprintf( fpout, " ttys = \"%d\"\n", header->ttys); 90 113 fprintf( fpout, " vspaces = \"%d\"\n", header->vspaces); 91 fprintf( fpout, " globals = \"%d\"\n", header->globals); 92 fprintf( fpout, " syspath = \"%s\" >\n", header->syspath); 114 fprintf( fpout, " globals = \"%d\" />\n\n", header->globals); 93 115 94 116 ///////////////////// clusters /////////////////////////////////////////////// … … 124 146 fprintf( fpout, " <vseg name = \"%s\"\n", vseg[vseg_id].name); 125 147 fprintf( fpout, " vbase = \"0x%x\"\n", vseg[vseg_id].vbase); 126 fprintf( fpout, " length = \"0x%x\"\n", vseg[vseg_id].length);127 148 fprintf( fpout, " mode = \"%s\"\n", mode_str[vseg[vseg_id].mode]); 128 149 fprintf( fpout, " psegname = \"%s\"\n", pseg[pseg_id].name); 129 fprintf( fpout, " ident = \"%d\" />\n\n", vseg[vseg_id].ident); 150 fprintf( fpout, " ident = \"%d\" >\n", vseg[vseg_id].ident); 151 for ( vobj_id = vseg[vseg_id].vobj_offset ; 152 vobj_id < (vseg[vseg_id].vobj_offset + vseg[vseg_id].vobjs) ; vobj_id++ ) 153 { 154 fprintf( fpout, " <vobj name = \"%s\"\n", vobj[vobj_id].name); 155 fprintf( fpout, " type = \"%s\" \n", vobj_type[vobj[vobj_id].type]); 156 if(vobj[vobj_id].length) 157 fprintf( fpout, " length = \"0x%x\" \n", vobj[vobj_id].length); 158 if(vobj[vobj_id].align) 159 fprintf( fpout, " align = \"%d\" \n", vobj[vobj_id].align); 160 if(vobj[vobj_id].binpath[0]!='\0') 161 fprintf( fpout, " binpath = \"%s\" \n", vobj[vobj_id].binpath); 162 fprintf( fpout, " />\n"); 163 } 164 fprintf( fpout, " </vseg>\n\n"); 130 165 } 131 166 fprintf( fpout, " </globalset>\n" ); … … 136 171 for ( vspace_id = 0 ; vspace_id < header->vspaces ; vspace_id++ ) 137 172 { 173 unsigned int func_id = vspace[vspace_id].vobj_offset + vspace[vspace_id].funcs_offset; 138 174 fprintf( fpout, " <vspace name = \"%s\"\n", vspace[vspace_id].name); 139 fprintf( fpout, " binpath = \"%s\"\n", vspace[vspace_id].binpath); 140 fprintf( fpout, " vsegs = \"%d\"\n", vspace[vspace_id].vsegs); 141 fprintf( fpout, " tasks = \"%d\"\n", vspace[vspace_id].tasks); 142 fprintf( fpout, " mwmrs = \"%d\"\n", vspace[vspace_id].mwmrs); 175 fprintf( fpout, " funcs = \"%s\"\n", vobj[func_id].name); 143 176 fprintf( fpout, " ttys = \"%d\" >\n\n", vspace[vspace_id].ttys); 144 177 … … 150 183 fprintf( fpout, " <vseg name = \"%s\"\n", vseg[vseg_id].name); 151 184 fprintf( fpout, " vbase = \"0x%x\"\n", vseg[vseg_id].vbase); 152 fprintf( fpout, " length = \"0x%x\"\n", vseg[vseg_id].length);153 185 fprintf( fpout, " mode = \"%s\"\n", mode_str[vseg[vseg_id].mode]); 154 186 fprintf( fpout, " psegname = \"%s\"\n", pseg[pseg_id].name); 155 fprintf( fpout, " mwmr = \"%d\"\n", vseg[vseg_id].mwmr); 156 fprintf( fpout, " ident = \"%d\" />\n\n", vseg[vseg_id].ident); 187 fprintf( fpout, " ident = \"%d\" >\n", vseg[vseg_id].ident); 188 189 for ( vobj_id = vseg[vseg_id].vobj_offset ; 190 vobj_id < (vseg[vseg_id].vobj_offset + vseg[vseg_id].vobjs) ; vobj_id++ ) 191 { 192 fprintf( fpout, "\t <vobj name = \"%s\"\n", vobj[vobj_id].name); 193 fprintf( fpout, "\t type = \"%s\" \n", vobj_type[vobj[vobj_id].type]); 194 if(vobj[vobj_id].length) 195 fprintf( fpout, "\t length = \"0x%x\" \n", vobj[vobj_id].length); 196 if(vobj[vobj_id].align) 197 fprintf( fpout, "\t align = \"%d\" \n", vobj[vobj_id].align); 198 if(vobj[vobj_id].binpath[0]!='\0') 199 fprintf( fpout, "\t binpath = \"%s\" \n", vobj[vobj_id].binpath); 200 fprintf( fpout, "\t />\n"); 201 } 202 fprintf( fpout, "\t\t </vseg>\n\n"); 157 203 } 158 204 for ( task_id = vspace[vspace_id].task_offset ; 159 205 task_id < (vspace[vspace_id].task_offset + vspace[vspace_id].tasks) ; task_id++ ) 160 206 { 161 unsigned int v seg_id = task[task_id].vseglocid + vspace[vspace_id].vseg_offset;207 unsigned int vobj_id = task[task_id].vobjlocid + vspace[vspace_id].vobj_offset; 162 208 163 209 fprintf( fpout, " <task name = \"%s\"\n", task[task_id].name); 164 210 fprintf( fpout, " clusterid = \"%d\"\n", task[task_id].clusterid); 165 211 fprintf( fpout, " proclocid = \"%d\"\n", task[task_id].proclocid); 166 fprintf( fpout, " stackname = \"%s\"\n", v seg[vseg_id].name);212 fprintf( fpout, " stackname = \"%s\"\n", vobj[vobj_id].name); 167 213 fprintf( fpout, " startid = \"%d\"\n", task[task_id].startid); 168 214 fprintf( fpout, " ttylocid = \"%d\" />\n\n", task[task_id].ttylocid); -
soft/giet_vm/xml/xml_parser.c
r158 r160 18 18 #include <mapping_info.h> 19 19 20 #define MAX_CLUSTERS 20 #define MAX_CLUSTERS 1024 21 21 #define MAX_PSEGS 4096 22 22 #define MAX_VSPACES 1024 … … 24 24 #define MAX_MWMRS 4096 25 25 #define MAX_VSEGS 4096 26 #define MAX_VOBJS 8192 26 27 27 28 #define XML_PARSER_DEBUG 0 … … 36 37 mapping_vspace_t* vspace[MAX_VSPACES]; // vspace array 37 38 mapping_vseg_t* vseg[MAX_VSEGS]; // vseg array 39 mapping_vobj_t* vobj[MAX_VOBJS]; // vobj array 38 40 mapping_task_t* task[MAX_TASKS]; // task array 39 41 … … 46 48 unsigned int task_index = 0; 47 49 unsigned int task_loc_index = 0; 48 unsigned int mwmr_index = 0; 49 unsigned int mwmr_loc_index = 0; 50 unsigned int vobj_index = 0; 51 unsigned int vobj_loc_index = 0; 52 unsigned int vobj_loc_vspace_index = 0; 53 54 char one_elf_found = 0;//bool: wether a first vobj of type elf was found 50 55 51 56 ////////////////////////////////////////////////// … … 132 137 133 138 ////////////////////////////////////////// 134 int getV segLocId( unsigned int vspace_id,139 int getVobjLocId( unsigned int vspace_id, 135 140 char* str ) 136 141 { 137 unsigned int vseg_id; 138 unsigned int vseg_min = vspace[vspace_id]->vseg_offset; 139 unsigned int vseg_max = vseg_min + vspace[vspace_id]->vsegs; 140 141 for ( vseg_id = vseg_min ; vseg_id < vseg_max ; vseg_id++ ) 142 { 143 if ( strcmp(vseg[vseg_id]->name, str) == 0 ) return (vseg_id - vseg_min); 142 unsigned int vobj_id; 143 unsigned int vobj_min = vspace[vspace_id]->vobj_offset; 144 unsigned int vobj_max = vobj_min + vobj_loc_vspace_index; 145 146 for ( vobj_id = vobj_min ; vobj_id < vobj_max ; vobj_id++ ) 147 { 148 if ( strcmp(vobj[vobj_id]->name, str) == 0 ) 149 { 150 return (vobj_id - vobj_min); 151 } 144 152 } 145 153 return -1; … … 218 226 if ( ok ) 219 227 { 220 int index = getV segLocId( vspace_index, str );228 int index = getVobjLocId( vspace_index, str ); 221 229 if ( index >= 0 ) 222 230 { … … 225 233 printf(" vsegid = %d\n", index); 226 234 #endif 227 task[task_index]->v seglocid = index;235 task[task_index]->vobjlocid = index; 228 236 } 229 237 else … … 283 291 } // end taskNode() 284 292 285 /////////////////////////////////////////////////////////////// 286 void vsegNode ( xmlTextReaderPtr reader ) 293 void vobjNode ( xmlTextReaderPtr reader ) 287 294 { 288 295 unsigned int ok; … … 292 299 if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return; 293 300 301 if ( vobj_index >= MAX_VOBJS ) 302 { 303 printf("[XML ERROR] The number of vobjs is larger than %d\n", MAX_VSEGS); 304 exit(1); 305 } 306 307 if(one_elf_found != 0) 308 { 309 printf("[XML ERROR] a vobj of the type ELF must be defined alone in a vseg (%d,%d)\n", 310 vspace_index, vobj_loc_vspace_index); 311 exit(1); 312 313 } 314 315 #if XML_PARSER_DEBUG 316 printf(" vobj %d\n", vobj_loc_index); 317 #endif 318 319 vobj[vobj_index] = (mapping_vobj_t*)malloc(sizeof(mapping_vobj_t)); 320 321 ///////// get name attribute 322 str = getStringValue(reader, "name", &ok); 323 if ( ok ) 324 { 325 #if XML_PARSER_DEBUG 326 printf(" name = %s\n", str); 327 #endif 328 strncpy( vobj[vobj_index]->name, str, 31); 329 } 330 else 331 { 332 printf("[XML ERROR] illegal or missing <name> attribute for vobj (%d,%d)\n", 333 vseg_index, vobj_loc_index); 334 exit(1); 335 } 336 337 338 // get type attribute 339 str = getStringValue(reader, "type", &ok); 340 #if XML_PARSER_DEBUG 341 printf(" type = %s\n", str); 342 #endif 343 if (ok && (strcmp(str, "ELF") == 0)){ 344 vobj[vobj_index]->type = ELF; 345 one_elf_found = 1; 346 if(vobj_loc_index != 0) //check that this vobj is the first 347 { 348 printf("[XML ERROR] a vobj of the type ELF must be defined alone in a vobj (%d,%d)\n", 349 vspace_index, vobj_loc_vspace_index); 350 exit(1); 351 352 } 353 } 354 else if (ok && (strcmp(str, "PTAB") == 0)) vobj[vobj_index]->type = PTAB; 355 else if (ok && (strcmp(str, "PERI") == 0)) vobj[vobj_index]->type = PERI; 356 else if (ok && (strcmp(str, "MWMR") == 0)) vobj[vobj_index]->type = MWMR; 357 else if (ok && (strcmp(str, "LOCK") == 0)) vobj[vobj_index]->type = LOCK; 358 else if (ok && (strcmp(str, "BUFFER") == 0)) vobj[vobj_index]->type = BUFFER; 359 else if (ok && (strcmp(str, "BARRIER") == 0)) vobj[vobj_index]->type = BARRIER; 360 else 361 { 362 printf("[XML ERROR] illegal or missing <type> attribute for vobj (%d,%d)\n", 363 vspace_index, vobj_loc_vspace_index); 364 exit(1); 365 } 366 367 368 ////////// get length attribute (0 if missing) 369 value = getIntValue(reader,"length", &ok); 370 if ( ok ) 371 { 372 #if XML_PARSER_DEBUG 373 printf(" length = %d\n", value); 374 #endif 375 vobj[vobj_index]->length = value; 376 } 377 else 378 { 379 vobj[vobj_index]->length = 0; 380 } 381 382 ////////// get align attribute (0 if missing) 383 value = getIntValue(reader,"align", &ok); 384 if ( ok ) 385 { 386 #if XML_PARSER_DEBUG 387 printf(" align = %d\n", value); 388 #endif 389 vobj[vobj_index]->align = value; 390 } 391 else 392 { 393 vobj[vobj_index]->align = 0; 394 } 395 396 ////////// get binpath attribute ('\0' if missing) 397 str = getStringValue(reader, "binpath", &ok); 398 if ( ok ) 399 { 400 #if XML_PARSER_DEBUG 401 printf(" binpath = %s\n", str); 402 #endif 403 strncpy(vobj[vobj_index]->binpath, str, 63); 404 } 405 else 406 { 407 vobj[vobj_index]->binpath[0] = '\0'; 408 } 409 410 vobj_index++; 411 vobj_loc_index++; 412 vobj_loc_vspace_index++; 413 } 414 415 416 /////////////////////////////////////////////////////////////// 417 void vsegNode ( xmlTextReaderPtr reader ) 418 { 419 unsigned int ok; 420 unsigned int value; 421 char* str; 422 vobj_loc_index = 0; 423 one_elf_found = 0; 424 425 if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return; 426 294 427 if ( vseg_index >= MAX_VSEGS ) 295 428 { … … 303 436 304 437 vseg[vseg_index] = (mapping_vseg_t*)malloc(sizeof(mapping_vseg_t)); 438 439 ////////// set vobj_offset attributes 440 vseg[vseg_index]->vobj_offset = vobj_index; 441 #if XML_PARSER_DEBUG 442 printf("- vobj_offset = %d\n", vobj_index); 443 #endif 305 444 306 445 ///////// get name attribute … … 336 475 } 337 476 338 ////////// get length attribute339 value = getIntValue(reader,"length", &ok);340 if ( ok )341 {342 #if XML_PARSER_DEBUG343 printf(" length = 0x%x\n", value);344 #endif345 vseg[vseg_index]->length = value;346 }347 else348 {349 printf("[XML ERROR] illegal or missing <length> attribute for vseg (%d,%d)\n",350 vspace_index, vseg_loc_index);351 exit(1);352 }353 477 354 478 ////////// get ident attribute (0 if missing) … … 366 490 } 367 491 368 ////////// get mwmr attribute (0 if missing)369 value = getIntValue(reader,"mwmr", &ok);370 if ( ok )371 {372 #if XML_PARSER_DEBUG373 printf(" mwmr = %d\n", value);374 #endif375 vseg[vseg_index]->mwmr = value;376 if ( value )377 {378 mwmr_index++;379 mwmr_loc_index++;380 }381 }382 else383 {384 vseg[vseg_index]->mwmr = 0;385 }386 492 387 493 ////////// get psegname attribute … … 440 546 } 441 547 442 vseg_index++; 443 vseg_loc_index++; 548 549 ////////// set the length attribute to 0 550 //the final value will be set by the VLoader 551 vseg[vseg_index]->length = value; 552 553 ////////// get vobjs 554 int status = xmlTextReaderRead ( reader ); 555 while ( status == 1 ) 556 { 557 const char* tag = (const char*)xmlTextReaderConstName(reader); 558 559 if ( strcmp(tag,"vobj") == 0 ) vobjNode(reader); 560 else if ( strcmp(tag,"#text" ) == 0 ) { } 561 else if ( strcmp(tag,"vseg") == 0 ) 562 { 563 // checking source file consistency? 564 vseg[vseg_index]->vobjs = vobj_loc_index; 565 vseg_index++; 566 vseg_loc_index++; 567 return; 568 } 569 else 570 { 571 printf("[XML ERROR] Unknown tag %s",tag); 572 exit(1); 573 } 574 status = xmlTextReaderRead ( reader ); 575 } 576 577 444 578 } // end vsegNode() 445 579 … … 450 584 unsigned int ok; 451 585 unsigned int value; 586 vobj_loc_vspace_index = 0; 587 vseg_loc_index = 0; 588 task_loc_index = 0; 452 589 453 590 if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return; … … 467 604 vspace[vspace_index] = (mapping_vspace_t*)malloc(sizeof(mapping_vspace_t)); 468 605 469 ////////// set vseg_offset 606 ////////// set vseg_offsetand task_offset attributes 470 607 vspace[vspace_index]->vseg_offset = vseg_index; 608 vspace[vspace_index]->vobj_offset = vobj_index; 471 609 vspace[vspace_index]->task_offset = task_index; 472 610 473 611 #if XML_PARSER_DEBUG 474 612 printf("- vseg_offset = %d\n", vseg_index); 613 printf("- vobj_offset = %d\n", vobj_index); 475 614 printf("- task_offset = %d\n", task_index); 476 615 #endif … … 492 631 } 493 632 494 ////////// / get binpathattribute495 str = getStringValue(reader, " binpath", &ok);496 if ( ok ) 497 { 498 #if XML_PARSER_DEBUG 499 printf(" binpath= %s\n", str);500 #endif 501 strncpy(vspace[vspace_index]->binpath, str, 63);502 } 503 else 504 { 505 printf("[XML ERROR] illegal or missing < binpath> attribute for vspace %d",633 ////////// get funcs_entry attribute 634 str = getStringValue(reader, "funcs", &ok); 635 if ( ok ) 636 { 637 #if XML_PARSER_DEBUG 638 printf(" name = %s\n", str); 639 #endif 640 //used after parsing all the vobjs 641 } 642 else 643 { 644 printf("[XML ERROR] illegal or missing <name> attribute for vspace %d", 506 645 vspace_index); 507 646 exit(1); 508 }509 510 ////////// get vsegs attribute511 value = getIntValue(reader,"vsegs",&ok);512 if ( ok )513 {514 #if XML_PARSER_DEBUG515 printf(" vsegs = %d\n", value);516 #endif517 vspace[vspace_index]->vsegs = value;518 }519 else520 {521 printf("[XML ERROR] illegal or missing <vsegs> attribute for vspace %d",522 vspace_index);523 exit(1);524 }525 526 // get tasks attribute527 value = getIntValue(reader,"tasks", &ok);528 if ( ok )529 {530 #if XML_PARSER_DEBUG531 printf(" tasks = %d\n", value);532 #endif533 vspace[vspace_index]->tasks = value;534 }535 else536 {537 printf("[XML ERROR] illegal or missing <tasks> attribute for vspace %d",538 vspace_index);539 exit(1);540 }541 542 // get mwmrs attribute543 value = getIntValue(reader,"mwmrs", &ok);544 if ( ok )545 {546 #if XML_PARSER_DEBUG547 printf(" mwmrs = %d\n", value);548 #endif549 vspace[vspace_index]->mwmrs = value;550 }551 else552 {553 vspace[vspace_index]->mwmrs = 0;554 647 } 555 648 … … 580 673 else if ( strcmp(tag,"vspace") == 0 ) 581 674 { 582 // checking source file consistency 583 if ( vseg_loc_index != vspace[vspace_index]->vsegs ) 675 vspace[vspace_index]->vobjs = vobj_loc_vspace_index; 676 vspace[vspace_index]->tasks = task_loc_index ; 677 vspace[vspace_index]->vsegs = vseg_loc_index ; 678 int index = getVobjLocId( vspace_index, str ); 679 if(index == -1) 584 680 { 585 printf(" [XML ERROR] Wrong number of vsegs in vspace %d\n", vspace_index);586 exit( 1);681 printf("Error funcs entry vobj not found %s\n",str); 682 exit(-1); 587 683 } 588 else if ( task_loc_index != vspace[vspace_index]->tasks ) 589 { 590 printf("[XML ERROR] Wrong number of tasks in vspace %d\n", vspace_index); 591 exit(1); 592 } 593 else if ( mwmr_loc_index != vspace[vspace_index]->mwmrs ) 594 { 595 printf("[XML ERROR] Wrong number of mwmrs in vspace %d\n", vspace_index); 596 exit(1); 597 } 598 else 599 { 600 vseg_loc_index = 0; 601 task_loc_index = 0; 602 mwmr_loc_index = 0; 603 vspace_index++; 604 return; 605 } 684 vspace[vspace_index]->funcs_offset = index; 685 686 vspace_index++; 687 return; 606 688 } 607 689 else … … 898 980 { 899 981 header->vsegs = vseg_index; 982 header->vobjs = vobj_index; 900 983 header->tasks = task_index; 901 984 return; … … 1033 1116 { 1034 1117 printf("[XML ERROR] illegal or missing <globals> attribute in mapping_info_header\n"); 1035 exit(1);1036 }1037 1038 // get syspath attribute1039 name = getStringValue(reader, "syspath", &ok);1040 if ( ok )1041 {1042 #if XML_PARSER_DEBUG1043 printf("- syspath = %s\n\n", name);1044 #endif1045 strncpy( header->syspath, name, 63);1046 }1047 else1048 {1049 printf("[XML ERROR] illegal or missing <syspath> attribute in header\n");1050 1118 exit(1); 1051 1119 } … … 1086 1154 unsigned int vspace_id; 1087 1155 unsigned int vseg_id; 1156 unsigned int vobj_id; 1088 1157 unsigned int task_id; 1089 1158 … … 1142 1211 #if XML_PARSER_DEBUG 1143 1212 printf("write vspace %d\n", vspace_id); 1213 printf("vspace->vobj_offset: %d\n", vspace[vspace_id]->vobj_offset); 1214 printf("vspace->vobjs: %d\n", vspace[vspace_id]->vobjs); 1215 printf("header->vobjs: %d\n", header->vobjs); 1144 1216 #endif 1145 1217 … … 1163 1235 { 1164 1236 perror("write vseg"); 1237 exit(1); 1238 } 1239 } 1240 1241 // write vobjs 1242 for ( vobj_id = 0 ; vobj_id < header->vobjs ; vobj_id++ ) 1243 { 1244 length = write(fdout, (char*)vobj[vobj_id], sizeof(mapping_vobj_t)); 1245 1246 #if XML_PARSER_DEBUG 1247 printf("write vobj %d\n", vobj_id); 1248 printf("write vobj name %s\n", vobj[vobj_id]->name); 1249 printf("write vobj length %x\n", vobj[vobj_id]->length); 1250 printf("write vobj type %d\n", vobj[vobj_id]->type); 1251 #endif 1252 1253 if ( length != sizeof(mapping_vobj_t) ) 1254 { 1255 perror("write vobj"); 1165 1256 exit(1); 1166 1257 }
Note: See TracChangeset
for help on using the changeset viewer.