Changeset 165
- Timestamp:
- Jul 4, 2012, 2:51:18 PM (12 years ago)
- Location:
- soft/giet_vm
- Files:
-
- 1 added
- 8 deleted
- 33 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/Makefile
r163 r165 4 4 LD=mipsel-unknown-elf-ld 5 5 DU=mipsel-unknown-elf-objdump 6 7 6 8 7 #current directory absolute path … … 25 24 SYS_OBJS_LIST = \ 26 25 sys_handler.o \ 27 init.o \28 26 giet.o \ 29 27 switch.o \ … … 33 31 exc_handler.o \ 34 32 irq_handler.o \ 35 task_init.o33 kernel_init.o 36 34 37 35 BOOT_OBJS_LIST = reset.o \ … … 39 37 40 38 #LIB_SRCS = $(wildcard $(LIB_NAME)/*.c) 41 LIB_OBJS_LIST = stdio.o\ 42 mwmr.o\ 39 LIB_OBJS_LIST = stdio.o \ 40 mwmr_channel.o \ 41 barrier.o \ 42 spin_lock.o \ 43 43 common.o 44 44 … … 73 73 @mkdir $(ELF_PATH) 2>$(TRASH) 74 74 75 ## compile the parser76 75 ## mapping compilation 77 76 map.bin: map.xml -
soft/giet_vm/apps/hello/main.c
r160 r165 5 5 unsigned int i; 6 6 char byte; 7 unsigned int proc = procid();7 unsigned int proc = giet_procid(); 8 8 9 9 for( i=0 ; i<1000 ; i++ ) 10 10 { 11 if( tty_printf(" hello from processor %d\n", proc) )11 if( giet_tty_printf(" hello from processor %d\n", proc) ) 12 12 { 13 tty_puts("echec tty_printf\n");14 exit();13 giet_tty_puts("echec tty_printf\n"); 14 giet_exit(); 15 15 } 16 if( tty_getc_irq((void*)&byte) )16 if( giet_tty_getc((void*)&byte) ) 17 17 { 18 tty_puts("echec tty_getc_irq\n");19 exit();18 giet_tty_puts("echec tty_getc_irq\n"); 19 giet_exit(); 20 20 } 21 if(byte == 'q')exit();21 if ( byte == 'q' ) giet_exit(); 22 22 } 23 23 giet_exit(); 24 24 25 25 } // end main -
soft/giet_vm/apps/pgcd/main.c
r160 r165 7 7 unsigned int opy; 8 8 9 tty_printf(" Interactive PGCD \n");9 giet_tty_printf(" Interactive PGCD \n"); 10 10 11 11 while (1) 12 12 { 13 tty_printf("\n*******************\n");14 tty_printf("operand X = ");15 tty_getw_irq(&opx);16 tty_printf("\n");17 tty_printf("operand Y = ");18 tty_getw_irq(&opy);19 tty_printf("\n");13 giet_tty_printf("\n*******************\n"); 14 giet_tty_printf("operand X = "); 15 giet_tty_getw( &opx ); 16 giet_tty_printf("\n"); 17 giet_tty_printf("operand Y = "); 18 giet_tty_getw( &opy ); 19 giet_tty_printf("\n"); 20 20 if( (opx == 0) || (opy == 0) ) 21 21 { 22 tty_printf("operands must be larger than 0\n");22 giet_tty_printf("operands must be larger than 0\n"); 23 23 } 24 24 else … … 29 29 else opy = opy - opx; 30 30 } 31 tty_printf("pgcd = %d\n", opx);31 giet_tty_printf("pgcd = %d\n", opx); 32 32 } 33 33 } -
soft/giet_vm/apps/router/Makefile
r162 r165 2 2 3 3 USE+= stdio.o 4 USE+= mwmr .o4 USE+= mwmr_channel.o 5 5 6 6 USES=$(patsubst %,$(BUILD_PATH)/$(LIB_NAME)/%,$(USE)) -
soft/giet_vm/apps/router/main.c
r160 r165 1 1 #include "stdio.h" 2 #include " srl.h"2 #include "mwmr_channel.h" 3 3 4 4 #define NMAX 200 … … 10 10 unsigned int n; 11 11 unsigned int buf; 12 srl_mwmr_tmwmr;12 mwmr_channel_t* mwmr; 13 13 14 srl_log_printf( TRACE, "*** Starting task producer on processor %d",procid() );15 srl_log_printf( TRACE, " at cycle %d ***\n\n",proctime() );14 giet_tty_printf( "*** Starting task producer on processor %d", giet_procid() ); 15 giet_tty_printf( " at cycle %d ***\n\n", giet_proctime() ); 16 16 17 if( vobj_get_vbase( "router" , "mwmr_in", MWMR, (unsigned int*)&mwmr ) ) 17 if( giet_vobj_get_vbase( "router" , 18 "mwmr_in", 19 VOBJ_TYPE_MWMR, 20 (void*)&mwmr ) ) 18 21 { 19 srl_log_printf( NONE, "\n[ERROR] in producer task :\n"); 20 srl_log_printf( NONE, " undefined <mwmr_in> channel: %d\n", mwmr); 21 srl_log_printf( TRACE, "*** &mwmr_in = %x\n\n", (unsigned int)mwmr ); 22 exit(); 23 } 24 else 25 { 26 srl_log_printf( TRACE, "*** &mwmr_in = %x\n\n", (unsigned int)mwmr ); 22 giet_tty_printf( "\n[ERROR] in producer task :\n"); 23 giet_tty_printf( " undefined <mwmr_in> channel: %d\n", mwmr); 24 giet_tty_printf( "*** &mwmr_in = %x\n\n", (unsigned int)mwmr ); 25 giet_exit(); 27 26 } 28 27 … … 31 30 { 32 31 buf = n; 33 srl_mwmr_write( mwmr, &buf , 1 );34 srl_log_printf( TRACE,"transmitted value : %d\n", buf);32 mwmr_write( mwmr, &buf , 1 ); 33 giet_tty_printf( "transmitted value : %d\n", buf); 35 34 } 36 35 37 srl_log_printf( TRACE, "\n*** Completing producer task at cycle %d ***\n",proctime());38 exit();36 giet_tty_printf( "\n*** Completing producer task at cycle %d ***\n", giet_proctime()); 37 giet_exit(); 39 38 40 39 } // end producer() … … 45 44 unsigned int n; 46 45 unsigned int buf[5]; 47 srl_mwmr_tmwmr;46 mwmr_channel_t* mwmr; 48 47 49 srl_log_printf( TRACE, "*** Starting task consumer on processor %d",procid() );50 srl_log_printf( TRACE, " at cycle %d ***\n\n",proctime() );48 giet_tty_printf( "*** Starting task consumer on processor %d", giet_procid() ); 49 giet_tty_printf( " at cycle %d ***\n\n", giet_proctime() ); 51 50 52 if ( vobj_get_vbase( "router" , "mwmr_out", MWMR, (unsigned int*)&mwmr ) ) 51 if ( giet_vobj_get_vbase( "router" , 52 "mwmr_out", 53 VOBJ_TYPE_MWMR, 54 (void*)&mwmr ) ) 53 55 { 54 srl_log_printf( NONE, "\n[ERROR] in consumer task :\n"); 55 srl_log_printf( NONE, " undefined <mwmr_out> channel\n"); 56 exit(); 57 } 58 else 59 { 60 srl_log_printf( TRACE, "*** &mwmr_out = %x\n\n", (unsigned int)mwmr ); 56 giet_tty_printf( "\n[ERROR] in consumer task :\n"); 57 giet_tty_printf( " undefined <mwmr_out> channel\n"); 58 giet_exit(); 61 59 } 62 60 … … 64 62 for(n = 0 ; n < NMAX ; n = n+5 ) 65 63 { 66 srl_mwmr_read( mwmr, buf , 5 );67 srl_log_printf( TRACE,"received token %d / value = %d\n", n , buf[0]);68 srl_log_printf( TRACE,"received token %d / value = %d\n", n+1, buf[1]);69 srl_log_printf( TRACE,"received token %d / value = %d\n", n+2, buf[2]);70 srl_log_printf( TRACE,"received token %d / value = %d\n", n+3, buf[3]);71 srl_log_printf( TRACE,"received token %d / value = %d\n", n+4, buf[4]);64 mwmr_read( mwmr, buf , 5 ); 65 giet_tty_printf( "received token %d / value = %d\n", n , buf[0]); 66 giet_tty_printf( "received token %d / value = %d\n", n+1, buf[1]); 67 giet_tty_printf( "received token %d / value = %d\n", n+2, buf[2]); 68 giet_tty_printf( "received token %d / value = %d\n", n+3, buf[3]); 69 giet_tty_printf( "received token %d / value = %d\n", n+4, buf[4]); 72 70 } 73 71 74 srl_log_printf( TRACE, "\n*** Completing consumer task at cycle %d ***\n",proctime());75 exit();72 giet_tty_printf( "\n*** Completing consumer task at cycle %d ***\n", giet_proctime()); 73 giet_exit(); 76 74 77 75 } // end consumer() … … 83 81 unsigned int x; 84 82 unsigned int tempo; 85 srl_mwmr_tmwmr_in ;86 srl_mwmr_tmwmr_out ;83 mwmr_channel_t* mwmr_in ; 84 mwmr_channel_t* mwmr_out ; 87 85 88 86 89 srl_log_printf( TRACE, "*** Starting task router on processor %d at cycle %d ***\n\n",90 procid(),proctime() );87 giet_tty_printf( "*** Starting task router on processor %d", giet_procid() ); 88 giet_tty_printf( " at cycle %d ***\n\n", giet_proctime() ); 91 89 92 if ( vobj_get_vbase( "router" , "mwmr_out", MWMR, (unsigned int*)&mwmr_out ) ) 90 if ( giet_vobj_get_vbase( "router" , 91 "mwmr_out", 92 VOBJ_TYPE_MWMR, 93 (void*)&mwmr_out ) ) 93 94 { 94 srl_log( NONE, "\n[ERROR] in router task :\n"); 95 srl_log( NONE, " undefined <mwmr_in> channel\n"); 96 exit(); 97 } 98 else 99 { 100 srl_log_printf( TRACE, "*** &mwmr_out = %x\n\n", (unsigned int)mwmr_out ); 95 giet_tty_printf( "\n[ERROR] in router task :\n"); 96 giet_tty_printf( " undefined <mwmr_in> channel\n"); 97 giet_exit(); 101 98 } 102 99 103 if ( vobj_get_vbase( "router" , "mwmr_in", MWMR, (unsigned int*)&mwmr_in ) ) 100 if ( giet_vobj_get_vbase( "router" , 101 "mwmr_in", 102 VOBJ_TYPE_MWMR, 103 (void*)&mwmr_in ) ) 104 104 { 105 srl_log( NONE, "\n[ERROR] in router task :\n"); 106 srl_log( NONE, " undefined <mwmr_out> channel\n"); 107 exit(); 108 } 109 else 110 { 111 srl_log_printf( TRACE, "*** &mwmr_in = %x\n\n", (unsigned int)mwmr_out ); 105 giet_tty_printf( "\n[ERROR] in router task :\n"); 106 giet_tty_printf( " undefined <mwmr_out> channel\n"); 107 giet_exit(); 112 108 } 113 109 … … 115 111 while(1) 116 112 { 117 srl_mwmr_read( mwmr_in , buf , 2 );118 tempo = rand() >> 6;113 mwmr_read( mwmr_in , buf , 2 ); 114 tempo = giet_rand() >> 6; 119 115 for ( x = 0 ; x < tempo ; x++ ) asm volatile (""); 120 srl_log_printf( TRACE,"token value : %d / temporisation = %d\n", buf[0], tempo);121 srl_log_printf( TRACE,"token value : %d / temporisation = %d\n", buf[1], tempo);122 srl_mwmr_write( mwmr_out, buf , 2 );116 giet_tty_printf( "token value : %d / temporisation = %d\n", buf[0], tempo); 117 giet_tty_printf( "token value : %d / temporisation = %d\n", buf[1], tempo); 118 mwmr_write( mwmr_out, buf , 2 ); 123 119 } 124 120 } -
soft/giet_vm/boot/boot_handler.c
r163 r165 6 6 /////////////////////////////////////////////////////////////////////////////////// 7 7 // The boot_handler.h and boot_handler.c files are part of the GIET nano-kernel. 8 // This code can be used in the boot phase to build all the pages tables then jumps9 // in tothe seg_kernel_init segment with an activated MMU.8 // This code is executed in the boot phase by proc0 to build all the pages tables, 9 // then jump in the seg_kernel_init segment with an activated MMU. 10 10 // 11 // It uses the SoCLib generic MMU (paged virtual memory) to provide two services: 12 // 11 // The SoCLib generic MMU (paged virtual memory) provides two services: 13 12 // 1) classical memory protection, when several independant applications compiled 14 13 // in different virtual spaces are executing on the same hardware platform. … … 16 15 // of the software objects (virtual segments) on the physical memory banks. 17 16 // 18 // It uses the MAPPING_INFO binary data structures, that must be pre-loaded in the19 // boot ROM inthe seg_boot_mapping segment (at address seg_mapping_base).17 // The boot code uses the MAPPING_INFO binary data structures, that must be pre-loaded 18 // in the the seg_boot_mapping segment (at address seg_mapping_base). 20 19 // This MAPPING_INFO data structure defines both the hardware architecture, 21 20 // and the mapping: … … 32 31 // As most applications use only a limited number of segments, the number of PT2s 33 32 // actually used by a given virtual space is generally smaller than 2048, and is 34 // defined in the MAPPING_INFO_BINARY data structure (using the length field).35 // The value is calculated and put in _max_pt e2 indexed by the vspace_id.33 // defined in the MAPPING_INFO_BINARY data structure (using the length field). 34 // The value is calculated and put in _max_pt2 indexed by the vspace_id. 36 35 // The physical alignment constraints, is ensured by the align flag in the MAPPING_INFO 37 36 // structure. … … 41 40 // - a first 8K aligned PT1[2148] array, indexed by the (ix1) field of VPN. 42 41 // The PT1 contains 2048 PTD of 4 bytes => 8K bytes. 43 // - an aray of array PT2[1024][_max_pt e2[vspace_id]], indexed by42 // - an aray of array PT2[1024][_max_pt2[vspace_id]], indexed by 44 43 // the (ix2) field of the VPN, and by the PT2 index (pt2_id). 45 // Each PT2 contains 512 PTE2 of 8bytes => 4Kbytes * _max_pt e2[vspace_id]46 // The size of each page table is 8K + (_max_pt e2[vspace_id])*4K bytes.44 // Each PT2 contains 512 PTE2 of 8bytes => 4Kbytes * _max_pt2[vspace_id] 45 // The size of each page table is 8K + (_max_pt2[vspace_id])*4K bytes. 47 46 // All page tables must be stored in the seg_kernel_pt segment (at address 48 47 // seg_kernel_pt_base) 49 48 //////////////////////////////////////////////////////////////////////////////////// 50 49 51 #include <mips32_registers.h>50 #include "../sys/mips32_registers.h" 52 51 #include <boot_handler.h> 53 52 #include <mapping_info.h> 54 #include <mwmr .h>53 #include <mwmr_channel.h> 55 54 56 55 #include <stdarg.h> … … 62 61 63 62 //////////////////////////////////////////////////////////////////////////// 64 // Global variables63 // Page Tables global variables 65 64 //////////////////////////////////////////////////////////////////////////// 66 65 67 // Page Tables 68 // Next free PT2 index 66 // Next free PT2 index array 69 67 unsigned int _next_free_pt2[GIET_NB_VSPACE_MAX] = 70 68 { [0 ... GIET_NB_VSPACE_MAX-1] = 0 }; 71 69 72 // Max PT2 index73 unsigned int _max_pt e2[GIET_NB_VSPACE_MAX] =70 // Max number of PT2 array 71 unsigned int _max_pt2[GIET_NB_VSPACE_MAX] = 74 72 { [0 ... GIET_NB_VSPACE_MAX-1] = 0 }; 75 73 76 // Page table pointers 74 // Page table pointers array 77 75 page_table_t* _ptabs[GIET_NB_VSPACE_MAX]; 78 76 … … 107 105 108 106 //////////////////////////////////////////////////////////////////////////// 109 // boot_ tty_puts()107 // boot_puts() 110 108 // (it uses TTY0) 111 109 //////////////////////////////////////////////////////////////////////////// 112 void boot_ tty_puts(const char *buffer)110 void boot_puts(const char *buffer) 113 111 { 114 112 unsigned int* tty_address = (unsigned int*)&seg_tty_base; … … 124 122 125 123 //////////////////////////////////////////////////////////////////////////// 126 // boot_ tty_putw()124 // boot_putw() 127 125 // (it uses TTY0) 128 126 //////////////////////////////////////////////////////////////////////////// 129 void boot_ tty_putw(unsigned int val)127 void boot_putw(unsigned int val) 130 128 { 131 129 static const char HexaTab[] = "0123456789ABCDEF"; … … 142 140 val = val >> 4; 143 141 } 144 boot_ tty_puts(buf);142 boot_puts(buf); 145 143 } 146 144 … … 219 217 mapping_vseg_t* vseg = boot_get_vseg_base ( header ); 220 218 mapping_task_t* task = boot_get_task_base ( header );; 221 mapping_vobj_t* vobj= boot_get_vobj_base( header );219 mapping_vobj_t* vobj = boot_get_vobj_base( header ); 222 220 223 221 // header 224 boot_tty_puts("mapping_info"); 225 226 boot_tty_puts("\n - signature = "); 227 boot_tty_putw(header->signature); 228 boot_tty_puts("\n - name = "); 229 boot_tty_puts(header->name); 230 boot_tty_puts("\n - clusters = "); 231 boot_tty_putw(header->clusters); 232 boot_tty_puts("\n - psegs = "); 233 boot_tty_putw(header->psegs); 234 boot_tty_puts("\n - ttys = "); 235 boot_tty_putw(header->ttys); 236 boot_tty_puts("\n - vspaces = "); 237 boot_tty_putw(header->vspaces); 238 boot_tty_puts("\n - globals = "); 239 boot_tty_putw(header->globals); 240 boot_tty_puts("\n - vsegs = "); 241 boot_tty_putw(header->vsegs); 242 boot_tty_puts("\n - tasks = "); 243 boot_tty_putw(header->tasks); 244 boot_tty_puts("\n\n"); 222 boot_puts("mapping_info"); 223 224 boot_puts("\n - signature = "); 225 boot_putw(header->signature); 226 boot_puts("\n - name = "); 227 boot_puts(header->name); 228 boot_puts("\n - clusters = "); 229 boot_putw(header->clusters); 230 boot_puts("\n - psegs = "); 231 boot_putw(header->psegs); 232 boot_puts("\n - ttys = "); 233 boot_putw(header->ttys); 234 boot_puts("\n - fbs = "); 235 boot_putw(header->fbs); 236 boot_puts("\n - vspaces = "); 237 boot_putw(header->vspaces); 238 boot_puts("\n - globals = "); 239 boot_putw(header->globals); 240 boot_puts("\n - vsegs = "); 241 boot_putw(header->vsegs); 242 boot_puts("\n - vobjs = "); 243 boot_putw(header->vobjs); 244 boot_puts("\n - tasks = "); 245 boot_putw(header->tasks); 246 boot_puts("\n\n"); 245 247 246 248 // clusters 247 249 for ( cluster_id = 0 ; cluster_id < header->clusters ; cluster_id++ ) 248 250 { 249 boot_tty_puts("cluster "); 250 boot_tty_putw(cluster_id); 251 252 boot_tty_puts("\n - procs = "); 253 boot_tty_putw(cluster[cluster_id].procs); 254 boot_tty_puts("\n - timers = "); 255 boot_tty_putw(cluster[cluster_id].timers); 256 boot_tty_puts("\n - dmas = "); 257 boot_tty_putw(cluster[cluster_id].dmas); 258 boot_tty_puts("\n\n"); 251 boot_puts("cluster "); 252 boot_putw(cluster_id); 253 254 boot_puts("\n - procs = "); 255 boot_putw(cluster[cluster_id].procs); 256 boot_puts("\n\n"); 259 257 } 260 258 … … 262 260 for ( pseg_id = 0 ; pseg_id < header->psegs ; pseg_id++ ) 263 261 { 264 boot_ tty_puts("pseg ");265 boot_ tty_putw(pseg_id);266 267 boot_ tty_puts("\n - name = ");268 boot_ tty_puts( pseg[pseg_id].name );269 boot_ tty_puts("\n - base = ");270 boot_ tty_putw( pseg[pseg_id].base );271 boot_ tty_puts("\n - length = ");272 boot_ tty_putw( pseg[pseg_id].length );273 boot_ tty_puts("\n\n");262 boot_puts("pseg "); 263 boot_putw(pseg_id); 264 265 boot_puts("\n - name = "); 266 boot_puts( pseg[pseg_id].name ); 267 boot_puts("\n - base = "); 268 boot_putw( pseg[pseg_id].base ); 269 boot_puts("\n - length = "); 270 boot_putw( pseg[pseg_id].length ); 271 boot_puts("\n\n"); 274 272 } 275 273 … … 277 275 for ( vseg_id = 0 ; vseg_id < header->globals ; vseg_id++ ) 278 276 { 279 boot_tty_puts("global vseg "); 280 boot_tty_putw(vseg_id); 281 282 boot_tty_puts("\n - name = "); 283 boot_tty_puts( vseg[vseg_id].name ); 284 boot_tty_puts("\n - vbase = "); 285 boot_tty_putw( vseg[vseg_id].vbase ); 286 boot_tty_puts("\n - length = "); 287 boot_tty_putw( vseg[vseg_id].length ); 288 boot_tty_puts("\n - mode = "); 289 boot_tty_putw( vseg[vseg_id].mode ); 290 boot_tty_puts("\n - ident = "); 291 boot_tty_putw( vseg[vseg_id].ident ); 292 boot_tty_puts("\n - psegname = "); 293 boot_tty_puts( pseg[vseg[vseg_id].psegid].name ); 294 boot_tty_puts("\n"); 295 for ( vobj_id = vseg[vseg_id].vobj_offset ; vobj_id < vseg[vseg_id].vobj_offset + vseg[vseg_id].vobjs ; vobj_id++ ) 296 { 297 boot_tty_puts("vobjs: \n"); 298 boot_tty_putw( vobj[vobj_id].name); 299 boot_tty_puts("\n"); 300 boot_tty_puts("\t name = "); 301 boot_tty_putw( vobj[vobj_id].name); 302 boot_tty_puts("\n"); 303 boot_tty_puts("\t type = "); 304 boot_tty_putw( vobj[vobj_id].type); 305 boot_tty_puts("\n"); 306 boot_tty_puts("\t length = "); 307 boot_tty_putw( vobj[vobj_id].length); 308 boot_tty_puts("\n"); 309 boot_tty_puts("\t align = "); 310 boot_tty_putw( vobj[vobj_id].align); 311 boot_tty_puts("\n"); 312 boot_tty_puts("\t binpath = "); 313 boot_tty_putw( vobj[vobj_id].binpath); 314 boot_tty_puts("\n\n"); 277 boot_puts("global vseg "); 278 boot_putw(vseg_id); 279 280 boot_puts("\n - name = "); 281 boot_puts( vseg[vseg_id].name ); 282 boot_puts("\n - vbase = "); 283 boot_putw( vseg[vseg_id].vbase ); 284 boot_puts("\n - length = "); 285 boot_putw( vseg[vseg_id].length ); 286 boot_puts("\n - mode = "); 287 boot_putw( vseg[vseg_id].mode ); 288 boot_puts("\n - ident = "); 289 boot_putw( vseg[vseg_id].ident ); 290 boot_puts("\n - psegname = "); 291 boot_puts( pseg[vseg[vseg_id].psegid].name ); 292 boot_puts("\n - vobjs = "); 293 boot_putw( vseg[vseg_id].vobjs ); 294 boot_puts("\n - vobj_offset = "); 295 boot_putw( vseg[vseg_id].vobj_offset ); 296 boot_puts("\n"); 297 for ( vobj_id = vseg[vseg_id].vobj_offset ; 298 vobj_id < vseg[vseg_id].vobj_offset + vseg[vseg_id].vobjs ; 299 vobj_id++ ) 300 { 301 boot_puts("\n\t vobj "); 302 boot_puts( vobj[vobj_id].name); 303 boot_puts("\n\t type = "); 304 boot_putw( vobj[vobj_id].type); 305 boot_puts("\n\t length = "); 306 boot_putw( vobj[vobj_id].length); 307 boot_puts("\n\t align = "); 308 boot_putw( vobj[vobj_id].align); 309 boot_puts("\n\t binpath = "); 310 boot_puts( vobj[vobj_id].binpath); 311 boot_puts("\n\n"); 315 312 } 316 313 } … … 319 316 for ( vspace_id = 0 ; vspace_id < header->vspaces ; vspace_id++ ) 320 317 { 321 unsigned int func_id = vspace[vspace_id].vobj_offset + vspace[vspace_id].funcs_offset; 322 boot_tty_puts("vspace "); 323 boot_tty_putw(vspace_id); 324 325 boot_tty_puts("\n - name = "); 326 boot_tty_puts( vspace[vspace_id].name ); 327 boot_tty_puts("\n - funcs = "); 328 boot_tty_puts( vobj[func_id].name ); 329 boot_tty_puts( vspace[vspace_id].name ); 330 boot_tty_puts("\n - ttys = "); 331 boot_tty_putw( vspace[vspace_id].ttys ); 332 boot_tty_puts("\n\n"); 318 unsigned int start_id = vspace[vspace_id].vobj_offset + 319 vspace[vspace_id].start_offset; 320 321 boot_puts("vspace "); 322 boot_putw(vspace_id); 323 324 boot_puts("\n - name = "); 325 boot_puts( vspace[vspace_id].name ); 326 boot_puts("\n - start_vobj = "); 327 boot_puts( vobj[start_id].name ); 328 boot_puts("\n - vsegs = "); 329 boot_putw( vspace[vspace_id].vsegs ); 330 boot_puts("\n - vobjs = "); 331 boot_putw( vspace[vspace_id].vobjs ); 332 boot_puts("\n - tasks = "); 333 boot_putw( vspace[vspace_id].tasks ); 334 boot_puts("\n - vseg_offset = "); 335 boot_putw( vspace[vspace_id].vseg_offset ); 336 boot_puts("\n - vobj_offset = "); 337 boot_putw( vspace[vspace_id].vobj_offset ); 338 boot_puts("\n - task_offset = "); 339 boot_putw( vspace[vspace_id].task_offset ); 340 boot_puts("\n\n"); 333 341 334 342 for ( vseg_id = vspace[vspace_id].vseg_offset ; … … 336 344 vseg_id++ ) 337 345 { 338 boot_tty_puts(" private vseg "); 339 boot_tty_putw( vseg_id ); 340 341 boot_tty_puts("\n - name = "); 342 boot_tty_puts( vseg[vseg_id].name ); 343 boot_tty_puts("\n - vbase = "); 344 boot_tty_putw( vseg[vseg_id].vbase ); 345 boot_tty_puts("\n - length = "); 346 boot_tty_putw( vseg[vseg_id].length ); 347 boot_tty_puts("\n - mode = "); 348 boot_tty_putw( vseg[vseg_id].mode ); 349 boot_tty_puts("\n - ident = "); 350 boot_tty_putw( vseg[vseg_id].ident ); 351 boot_tty_puts("\n - psegname = "); 352 boot_tty_puts( pseg[vseg[vseg_id].psegid].name ); 353 boot_tty_puts("\n"); 354 for ( vobj_id = vseg[vseg_id].vobj_offset ; vobj_id < vseg[vseg_id].vobj_offset + vseg[vseg_id].vobjs ; vobj_id++ ) 346 boot_puts(" private vseg "); 347 boot_putw( vseg_id ); 348 349 boot_puts("\n - name = "); 350 boot_puts( vseg[vseg_id].name ); 351 boot_puts("\n - vbase = "); 352 boot_putw( vseg[vseg_id].vbase ); 353 boot_puts("\n - length = "); 354 boot_putw( vseg[vseg_id].length ); 355 boot_puts("\n - mode = "); 356 boot_putw( vseg[vseg_id].mode ); 357 boot_puts("\n - ident = "); 358 boot_putw( vseg[vseg_id].ident ); 359 boot_puts("\n - psegname = "); 360 boot_puts( pseg[vseg[vseg_id].psegid].name ); 361 boot_puts("\n - vobjs = "); 362 boot_putw( vseg[vseg_id].vobjs ); 363 boot_puts("\n - vobj_offset = "); 364 boot_putw( vseg[vseg_id].vobj_offset ); 365 boot_puts("\n"); 366 367 for ( vobj_id = vseg[vseg_id].vobj_offset ; 368 vobj_id < vseg[vseg_id].vobj_offset + vseg[vseg_id].vobjs ; 369 vobj_id++ ) 355 370 { 356 boot_tty_puts("\t\t vobjs = "); 357 boot_tty_putw( vobj[vobj_id].name); 358 boot_tty_puts("\n"); 359 boot_tty_puts("\t\t name = "); 360 boot_tty_putw( vobj[vobj_id].name); 361 boot_tty_puts("\n"); 362 boot_tty_puts("\t\t type = "); 363 boot_tty_putw( vobj[vobj_id].type); 364 boot_tty_puts("\n"); 365 boot_tty_puts("\t\t length = "); 366 boot_tty_putw( vobj[vobj_id].length); 367 boot_tty_puts("\n"); 368 boot_tty_puts("\t\t align = "); 369 boot_tty_putw( vobj[vobj_id].align); 370 boot_tty_puts("\n"); 371 boot_tty_puts("\t\t binpath = "); 372 boot_tty_putw( vobj[vobj_id].binpath); 373 boot_tty_puts("\n"); 371 boot_puts("\n\t\t vobj "); 372 boot_puts( vobj[vobj_id].name); 373 boot_puts("\n\t\t type = "); 374 boot_putw( vobj[vobj_id].type); 375 boot_puts("\n\t\t length = "); 376 boot_putw( vobj[vobj_id].length); 377 boot_puts("\n\t\t align = "); 378 boot_putw( vobj[vobj_id].align); 379 boot_puts("\n\t\t binpath = "); 380 boot_puts( vobj[vobj_id].binpath); 381 boot_puts("\n\n"); 374 382 } 375 383 } … … 379 387 task_id++ ) 380 388 { 381 boot_tty_puts(" task"); 382 boot_tty_putw( task_id ); 383 384 boot_tty_puts("\n - name = "); 385 boot_tty_puts( task[task_id].name ); 386 boot_tty_puts("\n - clusterid = "); 387 boot_tty_putw( task[task_id].clusterid ); 388 boot_tty_puts("\n - proclocid = "); 389 boot_tty_putw( task[task_id].proclocid ); 390 boot_tty_puts("\n - vobjlocid = "); 391 boot_tty_putw( task[task_id].vobjlocid ); 392 boot_tty_puts("\n - startid = "); 393 boot_tty_putw( task[task_id].startid ); 394 boot_tty_puts("\n - ttylocid = "); 395 boot_tty_putw( task[task_id].ttylocid ); 396 boot_tty_puts("\n\n"); 389 boot_puts(" task"); 390 boot_putw( task_id ); 391 392 boot_puts("\n - name = "); 393 boot_puts( task[task_id].name ); 394 boot_puts("\n - clusterid = "); 395 boot_putw( task[task_id].clusterid ); 396 boot_puts("\n - proclocid = "); 397 boot_putw( task[task_id].proclocid ); 398 boot_puts("\n - vobjlocid = "); 399 boot_putw( task[task_id].vobjlocid ); 400 boot_puts("\n - startid = "); 401 boot_putw( task[task_id].startid ); 402 boot_puts("\n - use_tty = "); 403 boot_putw( task[task_id].use_tty ); 404 boot_puts("\n - use_fb = "); 405 boot_putw( task[task_id].use_fb ); 406 boot_puts("\n\n"); 397 407 } 398 408 } … … 403 413 // boot_pseg_get() 404 414 // This function returns the pointer on a physical segment 405 // identified by the segmentindex.415 // identified by the pseg index. 406 416 ////////////////////////////////////////////////////////////////////////////// 407 417 mapping_pseg_t* boot_pseg_get( unsigned int seg_id) … … 413 423 if ( seg_id >= header->psegs ) 414 424 { 415 boot_ tty_puts("\n[BOOT ERROR] : seg_id argument too large\n");416 boot_ tty_puts(" in function boot_pseg_get()\n");425 boot_puts("\n[BOOT ERROR] : seg_id argument too large\n"); 426 boot_puts(" in function boot_pseg_get()\n"); 417 427 boot_exit(); 418 428 } … … 420 430 return &pseg[seg_id]; 421 431 } // end boot_pseg_get() 422 423 432 424 433 ////////////////////////////////////////////////////////////////////////////// … … 450 459 451 460 452 unsigned int max_pt e2 = _max_pte2[vspace_id];453 if(max_pt e2 == 0)454 { 455 boot_ tty_puts("Unfound page table for vspace ");456 boot_ tty_putw(vspace_id);457 boot_ tty_puts("\n");461 unsigned int max_pt2 = _max_pt2[vspace_id]; 462 if(max_pt2 == 0) 463 { 464 boot_puts("Unfound page table for vspace "); 465 boot_putw(vspace_id); 466 boot_puts("\n"); 458 467 boot_exit(); 459 468 } … … 463 472 { 464 473 pt2_id = _next_free_pt2[vspace_id]; 465 if ( pt2_id == max_pt e2 )466 { 467 boot_ tty_puts("\n[BOOT ERROR] in boot_add_pte() function\n");468 boot_ tty_puts("the length of the ptab vobj is too small\n");474 if ( pt2_id == max_pt2 ) 475 { 476 boot_puts("\n[BOOT ERROR] in boot_add_pte() function\n"); 477 boot_puts("the length of the ptab vobj is too small\n"); 469 478 boot_exit(); 470 479 } … … 487 496 if ( ( *pt_flags & PTE_V) != 0 ) // page already mapped 488 497 { 489 if(global) 490 { 491 boot_tty_puts("\n[BOOT ERROR] in boot_add_pte() function\n"); 492 boot_tty_puts("page already mapped\n"); 493 boot_exit(); 494 }else 495 { 496 /** 497 * The case where a global vseg is already mapped as private vseg of a 498 * vspace_id. Typically used when a vseg is being replicated. 499 */ 500 boot_tty_puts("\n[BOOT] global PTE for vspace "); 501 boot_tty_putw(vspace_id); 502 boot_tty_puts(" already mapped, vpn = "); 503 boot_tty_putw(vpn); 504 boot_tty_puts("\n"); 505 return; 506 } 498 boot_puts("\n[BOOT ERROR] in boot_add_pte() function\n"); 499 boot_puts("page already mapped\n"); 500 boot_exit(); 507 501 } 508 502 … … 549 543 550 544 #if BOOT_DEBUG_PT 551 boot_tty_puts("- vseg "); 552 boot_tty_puts( vseg[vseg_id].name ); 553 boot_tty_puts(" / flags = "); 554 boot_tty_putw( flags ); 555 boot_tty_puts("\n"); 545 boot_puts("- vseg "); 546 boot_puts( vseg[vseg_id].name ); 547 boot_puts(" / flags = "); 548 boot_putw( flags ); 549 boot_puts(" / npages = "); 550 boot_putw( npages ); 551 boot_puts("\n"); 556 552 #endif 557 553 // loop on 4K pages … … 583 579 584 580 #if BOOT_DEBUG_PT 585 boot_ tty_puts("- vseg ");586 boot_ tty_puts( vseg[vseg_id].name );587 boot_ tty_puts(" / flags = ");588 boot_ tty_putw( flags );589 boot_ tty_puts(" / npages = ");590 boot_ tty_putw( npages );591 boot_ tty_puts("\n");581 boot_puts("- vseg "); 582 boot_puts( vseg[vseg_id].name ); 583 boot_puts(" / flags = "); 584 boot_putw( flags ); 585 boot_puts(" / npages = "); 586 boot_putw( npages ); 587 boot_puts("\n"); 592 588 #endif 593 589 // loop on 4K pages … … 606 602 } // end boot_vspace_pt_build() 607 603 608 609 604 /////////////////////////////////////////////////////////////////////////// 610 605 // Align the value "toAlign" to the required alignement indicated by 611 606 // alignPow2 ( the logarithme of 2 the alignement). 612 607 /////////////////////////////////////////////////////////////////////////// 613 unsigned int align_to( unsigned toAlign, unsigned alignPow2) 614 { 615 unsigned mask = (1 << alignPow2) - 1; 616 return ((toAlign + mask ) & ~mask );//page aligned 617 } 618 619 /////////////////////////////////////////////////////////////////////////// 620 // Initialise vobjs 621 // For now only one type is initialised the: PTAB 622 // 623 // param: 624 // vobj: the vobj to initialise 625 // region_id: the vspace in wich the vobj is located or the global space(-1). 626 /////////////////////////////////////////////////////////////////////////// 627 void initailise_vobj(mapping_vobj_t* vobj, unsigned int region_id) 628 { 629 if(vobj->type == PTAB) 630 { 631 if(region_id == ((unsigned int) -1)) 632 { 633 boot_tty_puts( "No PTAB vobjs are allowed in the global region" ); 634 boot_exit(); 635 } 636 if(vobj->length < (PT1_SIZE + PT2_SIZE) ) //at least one pt2 => ( max_pt2 >= 1) 637 { 638 boot_tty_puts("PTAB too small, minumum size is "); 639 boot_tty_putw( PT1_SIZE + PT2_SIZE); 640 boot_exit(); 641 } 642 643 _ptabs[region_id] = (page_table_t*) vobj->paddr; 644 _max_pte2[region_id] = (vobj->length - PT1_SIZE) / PT2_SIZE; 645 646 #if BOOT_DEBUG_VIEW 647 boot_tty_puts("ptabs for vspace "); 648 boot_tty_putw(region_id); 649 boot_tty_puts(" address: "); 650 boot_tty_putw((unsigned)_ptabs[region_id]); 651 boot_tty_puts("\n"); 652 #endif 653 } 608 unsigned int align_to( unsigned int toAlign, 609 unsigned int alignPow2) 610 { 611 unsigned int mask = (1 << alignPow2) - 1; 612 return ((toAlign + mask ) & ~mask ); 654 613 } 655 614 … … 660 619 // It updates the page allocator (nextfreepage field of the pseg), 661 620 // and checks a possible pseg overflow. 662 // region_id: the vspace in wich the vseg is located or the global space(-1).621 // It is a global vseg if vspace_id = (-1) 663 622 /////////////////////////////////////////////////////////////////////////// 664 void boot_vseg_map( mapping_vseg_t* vseg, unsigned int region_id ) 665 { 666 unsigned pages; 667 unsigned vobj_id; 668 unsigned cur_vaddr; 669 unsigned cur_paddr; 623 void boot_vseg_map( mapping_vseg_t* vseg, 624 unsigned int vspace_id ) 625 { 626 unsigned int pages; 627 unsigned int vobj_id; 628 unsigned int cur_vaddr; 629 unsigned int cur_paddr; 670 630 mapping_header_t* header = (mapping_header_t*)&seg_mapping_base; 671 631 mapping_vobj_t* vobj = boot_get_vobj_base( header ); … … 677 637 if ( vseg->ident != 0 ) // identity mapping required 678 638 { 679 // check physical segment overflow 680 if ( (vseg->vbase < pseg->base) || 681 ((vseg->vbase + vseg->length) > (pseg->base + pseg->length)) ) 682 { 683 boot_tty_puts("\n[BOOT ERROR] in boot_vseg_map() function\n"); 684 boot_tty_puts("impossible identity mapping for virtual segment: "); 685 boot_tty_puts( vseg->name ); 686 boot_tty_puts("\n"); 687 boot_exit(); 688 } 689 vseg->pbase = vseg->vbase; 639 vseg->pbase = vseg->vbase; 690 640 } 691 641 else // unconstrained mapping 692 642 { 693 // check physical segment overflow694 if ( (vseg->vbase + vseg->length) > (pseg->base + pseg->length) )695 {696 boot_tty_puts("\n[BOOT ERROR] in boot_vseg_map() function\n");697 boot_tty_puts("physical segment ");698 boot_tty_puts( pseg->name );699 boot_tty_puts(" is too small to map virtual segment");700 boot_tty_puts( vseg->name );701 boot_tty_puts("\n");702 boot_exit();703 }704 643 vseg->pbase = pseg->base + (pseg->next_free_page<<12); 705 644 } 706 645 707 708 //loop on vobj: 709 // + to computes the length of the current vseg 710 // + Align vobjs 711 // + Initialise the vobj 646 // loop on vobjs to computes the length of the vseg, 647 // initialise the vaddr and paddr fields of all vobjs, 648 // and initialise the page table pointers array 712 649 cur_vaddr = vseg->vbase; 713 650 cur_paddr = vseg->pbase; 714 for(vobj_id= vseg->vobj_offset; vobj_id < (vseg->vobj_offset + vseg->vobjs); vobj_id++) 715 { 716 if(vobj[vobj_id].align) 651 652 for( vobj_id = vseg->vobj_offset; 653 vobj_id < (vseg->vobj_offset + vseg->vobjs); 654 vobj_id++) 655 { 656 if ( vobj[vobj_id].align ) 717 657 { 718 658 cur_paddr = align_to(cur_paddr, vobj[vobj_id].align); 719 659 } 720 660 721 // set vaddr/paddr661 // set vaddr/paddr 722 662 vobj[vobj_id].vaddr = cur_vaddr; 723 663 vobj[vobj_id].paddr = cur_paddr; 724 664 725 // set next vaddr/paddr665 // set next vaddr/paddr 726 666 cur_vaddr += vobj[vobj_id].length; 727 667 cur_paddr += vobj[vobj_id].length; 728 initailise_vobj(&vobj[vobj_id], region_id); 668 669 // initialise _ptabs[] and _max_pt2[] 670 if ( vobj[vobj_id].type == VOBJ_TYPE_PTAB ) 671 { 672 if(vobj[vobj_id].length < (PT1_SIZE + PT2_SIZE) ) // max_pt2 >= 1 673 { 674 boot_puts( "\n[BOOT ERROR] in boot_vseg_map() function: " ); 675 boot_puts("PTAB vobj is too small in vspace "); 676 boot_putw(vspace_id); 677 boot_puts("\n"); 678 boot_exit(); 679 } 680 if(vspace_id == ((unsigned int) -1)) // global vseg 681 { 682 boot_puts( "\n[BOOT ERROR] in boot_vseg_map() function: " ); 683 boot_puts( "a PTAB vobj cannot be global" ); 684 boot_exit(); 685 } 686 _ptabs[vspace_id] = (page_table_t*)vobj[vobj_id].paddr; 687 _max_pt2[vspace_id] = (vobj[vobj_id].length - PT1_SIZE) / PT2_SIZE; 688 } 729 689 } 730 690 731 //set the length 732 vseg->length = align_to((cur_paddr - vseg->pbase), 12); 691 //set the vseg length 692 unsigned int plength = pseg->length; 693 unsigned int vlength = cur_paddr - vseg->pbase; 694 vseg->length = align_to(vlength, 12); 695 696 // checking pseg overflow 697 if ( (vseg->pbase < pseg->base) || 698 ((vseg->pbase + vlength) > (pseg->base + plength)) ) 699 { 700 boot_puts("\n[BOOT ERROR] in boot_vseg_map() function\n"); 701 boot_puts("impossible identity mapping for virtual segment: "); 702 boot_puts( vseg->name ); 703 boot_puts("\n"); 704 boot_puts("vseg pbase = "); 705 boot_putw( vseg->pbase ); 706 boot_puts("\n"); 707 boot_puts("vseg length = "); 708 boot_putw( vseg->length ); 709 boot_puts("\n"); 710 boot_puts("pseg pbase = "); 711 boot_putw( pseg->base ); 712 boot_puts("\n"); 713 boot_puts("pseg length = "); 714 boot_putw( pseg->length ); 715 boot_puts("\n"); 716 boot_exit(); 717 } 733 718 734 719 // computes number of pages … … 743 728 744 729 #if BOOT_DEBUG_PT 745 boot_ tty_puts("- vseg ");746 boot_ tty_puts( vseg->name );747 boot_ tty_puts(" : vbase = ");748 boot_ tty_putw( vseg->vbase );749 boot_ tty_puts(" / pbase = ");750 boot_ tty_putw( vseg->pbase );751 boot_ tty_puts("\n");730 boot_puts("- vseg "); 731 boot_puts( vseg->name ); 732 boot_puts(" : vbase = "); 733 boot_putw( vseg->vbase ); 734 boot_puts(" / pbase = "); 735 boot_putw( vseg->pbase ); 736 boot_puts("\n"); 752 737 #endif 753 738 … … 755 740 756 741 ///////////////////////////////////////////////////////////////////// 757 // This function che ks the mapping_info data structure742 // This function checks the mapping_info data structure 758 743 ///////////////////////////////////////////////////////////////////// 759 744 void boot_check_mapping() … … 764 749 if ( header->signature != IN_MAPPING_SIGNATURE ) 765 750 { 766 boot_ tty_puts("\n[BOOT ERROR] Illegal mapping signature: ");767 boot_ tty_putw(header->signature);768 boot_ tty_puts("\n");751 boot_puts("\n[BOOT ERROR] Illegal mapping signature: "); 752 boot_putw(header->signature); 753 boot_puts("\n"); 769 754 boot_exit(); 770 755 } … … 777 762 if ( header->clusters != NB_CLUSTERS ) 778 763 { 779 boot_ tty_puts("\n[BOOT ERROR] Incoherent NB_CLUSTERS");780 boot_ tty_puts("\n - In giet_config, value = ");781 boot_ tty_putw ( NB_CLUSTERS );782 boot_ tty_puts("\n - In mapping_info, value = ");783 boot_ tty_putw ( header->clusters );784 boot_ tty_puts("\n");764 boot_puts("\n[BOOT ERROR] Incoherent NB_CLUSTERS"); 765 boot_puts("\n - In giet_config, value = "); 766 boot_putw ( NB_CLUSTERS ); 767 boot_puts("\n - In mapping_info, value = "); 768 boot_putw ( header->clusters ); 769 boot_puts("\n"); 785 770 boot_exit(); 786 771 } … … 789 774 if ( header->ttys != NB_TTYS ) 790 775 { 791 boot_ tty_puts("\n[BOOT ERROR] Incoherent NB_TTYS");792 boot_ tty_puts("\n - In giet_config, value = ");793 boot_ tty_putw ( NB_TTYS );794 boot_ tty_puts("\n - In mapping_info, value = ");795 boot_ tty_putw ( header->ttys );796 boot_ tty_puts("\n");776 boot_puts("\n[BOOT ERROR] Incoherent NB_TTYS"); 777 boot_puts("\n - In giet_config, value = "); 778 boot_putw ( NB_TTYS ); 779 boot_puts("\n - In mapping_info, value = "); 780 boot_putw ( header->ttys ); 781 boot_puts("\n"); 797 782 boot_exit(); 798 783 } … … 801 786 if ( header->vspaces > GIET_NB_VSPACE_MAX ) 802 787 { 803 boot_ tty_puts("\n[BOOT ERROR] : number of vspaces > GIET_NB_VSPACE_MAX\n");804 boot_ tty_puts("\n");788 boot_puts("\n[BOOT ERROR] : number of vspaces > GIET_NB_VSPACE_MAX\n"); 789 boot_puts("\n"); 805 790 boot_exit(); 806 791 } … … 825 810 unsigned int pseg_id; 826 811 827 // first loop on virtual spaces to map global vsegs 812 // checking mapping_info 813 boot_check_mapping(); 814 815 // physical page allocators must be initialised 816 for ( pseg_id = 0 ; pseg_id < header->psegs ; pseg_id++ ) 817 { 818 pseg[pseg_id].next_free_page = 0; 819 } 828 820 829 821 #if BOOT_DEBUG_PT 830 boot_ tty_puts("\n******* mapping global vsegs ********");822 boot_puts("\n******* mapping global vsegs ********\n"); 831 823 #endif 832 824 833 // physical page allocators must be initialised ??? 834 for ( pseg_id = 0 ; pseg_id < header->psegs ; pseg_id++ ) 835 { 836 pseg[pseg_id].next_free_page = 0; 837 } 838 825 // step 1 : first loop on virtual spaces to map global vsegs 839 826 for ( vseg_id = 0 ; vseg_id < header->globals ; vseg_id++ ) 840 827 { … … 842 829 } 843 830 844 // loop on virtual vspaces to map private vsegs831 // step 2 : loop on virtual vspaces to map private vsegs 845 832 for ( vspace_id = 0 ; vspace_id < header->vspaces ; vspace_id++ ) 846 833 { 847 834 848 835 #if BOOT_DEBUG_PT 849 boot_ tty_puts("\n******* mapping private vsegs in vspace ");850 boot_ tty_puts(vspace[vspace_id].name);851 boot_ tty_puts(" ********\n");836 boot_puts("\n******* mapping private vsegs in vspace "); 837 boot_puts(vspace[vspace_id].name); 838 boot_puts(" ********\n"); 852 839 #endif 853 840 … … 860 847 } 861 848 862 // loop on the vspaces to build the page tables849 // step 3 : loop on the vspaces to build the page tables 863 850 for ( vspace_id = 0 ; vspace_id < header->vspaces ; vspace_id++ ) 864 851 { 865 852 866 853 #if BOOT_DEBUG_PT 867 boot_ tty_puts("\n******* building page table for vspace ");868 boot_ tty_puts(vspace[vspace_id].name);869 boot_ tty_puts(" ********\n");854 boot_puts("\n******* building page table for vspace "); 855 boot_puts(vspace[vspace_id].name); 856 boot_puts(" ********\n"); 870 857 #endif 871 858 872 859 boot_vspace_pt_build( vspace_id ); 860 861 #if BOOT_DEBUG_PT 862 boot_puts(">>> page table physical address = "); 863 boot_putw((unsigned)_ptabs[vspace_id]); 864 boot_puts("\n"); 865 #endif 873 866 } 867 868 boot_puts("\n[BOOT] Page Tables initialisation completed at cycle "); 869 boot_putw( boot_time() ); 870 boot_puts("\n"); 871 874 872 } // end boot_pt_init() 875 876 877 878 ////////////////////////////////////////////////////////////////////////////////////879 // boot_init()880 // This function is executed by one single processor to initialize the page881 // tables, the tasks contexts and the peripherals, for all applications.882 ////////////////////////////////////////////////////////////////////////////////////883 void boot_init()884 {885 // checking mapping_info886 boot_check_mapping();887 888 // building page tables889 boot_pt_init();890 boot_tty_puts("\n[BOOT] Page Tables completed at cycle ");891 boot_tty_putw( boot_time() );892 boot_tty_puts("\n");893 894 } // end boot_init()895 873 896 874 // Local Variables: -
soft/giet_vm/boot/reset.S
r162 r165 1 1 /********************************************************************************/ 2 /* File : reset.S 3 /* Author : Alain Greiner & Mohamed karaoui 4 /* Date : 03/06/2012 */2 /* File : reset.S */ 3 /* Author : Alain Greiner & Mohamed karaoui */ 4 /* Date : 03/06/2012 */ 5 5 /********************************************************************************/ 6 6 /* This boot code is for a multi-cluster, multi-processor architecture, */ 7 /* running one or several multi-tasks software application(s) defined in the*/7 /* running one or several multi-tasks software application(s) defined in */ 8 8 /* the mapping_info data-structure. */ 9 /* It uses the mapping_info data structure to build the page tables.*/10 /* Processor 0 is in charge of building all pages tables.*/9 /* Procesor 0 uses the mapping_info data structure to build all page tables */ 10 /* before jumping to the kernel_init code. */ 11 11 /* Other processors are waiting until the mapping_info signature has been */ 12 12 /* modified by processor 0 (done while executing kernel_init code). */ 13 /* Implementation note: */ 13 14 /* The entry point is 0xbfc00000, but the actual boot code starts at address */ 14 15 /* 0xbfc00500, and a minimal boot exception handler is implemented at address */ … … 17 18 18 19 #include <giet_config.h> 19 #include <mips32_registers.h>20 #include "../sys/mips32_registers.h" 20 21 21 22 #define EXCEP_ORG 0x380 … … 44 45 boot_excep: 45 46 la a0, boot_error_string 46 jal boot_ tty_puts47 jal boot_puts 47 48 nop 48 49 mfc0 a0, CP0_TIME 49 jal boot_ tty_putw50 jal boot_putw 50 51 nop 51 52 la a0, boot_lf_string 52 jal boot_tty_puts 53 jal boot_puts 54 nop 55 56 la a0, boot_pid_string 57 jal boot_puts 58 nop 59 mfc0 k0, CP0_PROCID 60 andi a0, k0, 0xFFF 61 jal boot_putw 62 nop 63 la a0, boot_lf_string 64 jal boot_puts 53 65 nop 54 66 55 67 la a0, boot_epc_string 56 jal boot_ tty_puts68 jal boot_puts 57 69 nop 58 70 mfc0 a0, CP0_EPC 59 60 jal boot_tty_putw 71 jal boot_putw 61 72 nop 62 73 la a0, boot_lf_string 63 jal boot_ tty_puts74 jal boot_puts 64 75 nop 65 76 66 77 la a0, boot_cr_string 67 jal boot_ tty_puts78 jal boot_puts 68 79 nop 69 80 mfc0 a0, CP0_CR 70 jal boot_ tty_putw81 jal boot_putw 71 82 nop 72 83 la a0, boot_lf_string 73 jal boot_ tty_puts84 jal boot_puts 74 85 nop 75 86 76 87 la a0, boot_sr_string 77 jal boot_ tty_puts88 jal boot_puts 78 89 nop 79 90 mfc0 a0, CP0_SR 80 jal boot_ tty_putw91 jal boot_putw 81 92 nop 82 93 la a0, boot_lf_string 83 jal boot_ tty_puts94 jal boot_puts 84 95 nop 85 96 86 97 la a0, boot_bar_string 87 jal boot_ tty_puts98 jal boot_puts 88 99 nop 89 100 mfc0 a0, CP0_BAR 90 jal boot_ tty_putw101 jal boot_putw 91 102 nop 92 103 la a0, boot_lf_string 93 jal boot_ tty_puts104 jal boot_puts 94 105 nop 95 106 … … 101 112 /*******************************************/ 102 113 .align 2 103 114 .org START_ORG 104 115 105 116 boot_start: 106 117 /* get the procid */ 107 118 mfc0 k0, CP0_PROCID 108 andi k0, k0, 0x3FF /* no more than 1024processors... */119 andi k0, k0, 0xFFF /* no more than 4096 processors... */ 109 120 110 111 121 /* Only processor 0 does init */ 122 bne k0, zero, boot_wait_signature 112 123 nop 113 124 114 /* temporary stack for procesor 0 : 16K*/115 116 addiu sp, sp, 0x4000 125 /* Processor 0 get a temporary stack */ 126 la sp, seg_boot_stack_base 127 addiu sp, sp, 0x3000 /* SP <= seg_boot_stack + 12K */ 117 128 118 /* plat-form initialisation*/119 jal boot_init129 /* Processor 0 initialises all Page Tables */ 130 jal boot_pt_init 120 131 nop 121 j to_kinit 132 133 /* jump to kernel_init */ 134 j boot_to_kernel_init 122 135 nop 123 136 124 137 boot_wait_signature: 138 139 /* all other processors are waiting signature change */ 125 140 la k0, seg_mapping_base 126 cache 0x11, 0(k0) 127 lw k0, 0(k0) /* k0 <= mapping_info[0]*/141 cache 0x11, 0(k0) /* invalidate local cache copy */ 142 lw k0, 0(k0) /* k0 <= mapping_info[0] */ 128 143 li k1, OUT_MAPPING_SIGNATURE 129 144 bne k1, k0, boot_wait_signature 130 145 nop 131 146 132 to_kinit: 133 /* All processors initialize PTPR / MODE */ 134 /* and jump to kernel_init code. */ 147 /* all other processors get a temporary stack of 256 bytes */ 148 la sp, seg_boot_stack_base 149 addiu sp, sp, 0x3100 150 mfc0 k0, CP0_PROCID 151 andi k0, k0, 0xFFF 152 sll k0, k0, 8 153 addu sp, sp, k0 /* SP <= seg_boot_stack_base + 12K + (pid+1)*256 */ 135 154 136 /* get the procid */ 137 mfc0 s0, CP0_PROCID 138 andi s0, s0, 0x3FF /* no more than 1024 processors... TOFIX*/ 155 boot_to_kernel_init: 139 156 140 /* load a PTPR*/141 157 /* all processors initialize PTPR with PTAB[0] */ 158 la k1, _ptabs 142 159 lw k1, 0(k1) 143 160 srl k1, k1, 13 144 mtc2 k1, CP2_PTPR /* ptpr<= _ptabs[0] */161 mtc2 k1, CP2_PTPR /* PTPR <= _ptabs[0] */ 145 162 146 /* a ctivatesMMU */147 lik1, 0xF148 mtc2 k1, CP2_MODE /* loadMODE register */163 /* all processors activate MMU */ 164 li k1, 0xF 165 mtc2 k1, CP2_MODE /* MODE register */ 149 166 150 167 /* jump to kernel_init */ 151 168 la k0, seg_kernel_init_base 152 169 j k0 153 170 nop 154 171 155 156 boot_ error_string: .asciiz "\n[BOOT] Fatal Error at cycle"172 boot_error_string: .asciiz "\n[BOOT] Fatal Error in reset.S at cycle " 173 boot_pid_string: .asciiz " PID = " 157 174 boot_sr_string: .asciiz " SR = " 158 175 boot_cr_string: .asciiz " CR = " -
soft/giet_vm/giet_config.h
r160 r165 1 1 /********************************************************************************/ 2 /* File : giet_config.h 3 /* Author : Alain Greiner 4 /* Date : 26/03/2012 2 /* File : giet_config.h */ 3 /* Author : Alain Greiner */ 4 /* Date : 26/03/2012 */ 5 5 /********************************************************************************/ 6 /* Define various configuration parameters for the GIET */6 /* Define various configuration parameters for the GIET */ 7 7 /********************************************************************************/ 8 8 … … 12 12 /* Debug parameters */ 13 13 14 #define BOOT_DEBUG_VIEW 0 /* display the mapping_info on system TTY */ 15 #define BOOT_DEBUG_PT 0 /* display the page tables after mapping */ 16 #define BOOT_DEBUG_CTX 0 /* display the task contexts after mapping */ 17 #define INIT_DEBUG_CTX 1 /* display the task contexts after mapping */ 18 19 #define GIET_DEBUG_SWITCH 0 /* Trace context switchs */ 14 #define BOOT_DEBUG_VIEW 0 /* display the mapping_info on system TTY */ 15 #define BOOT_DEBUG_PT 0 /* display the page tables after mapping */ 16 #define INIT_DEBUG 0 /* display the task contexts after mapping */ 17 #define GIET_DEBUG_SWITCH 0 /* Trace context switchs */ 20 18 21 19 … … 24 22 /* hardware parameters */ 25 23 26 #define NB_CLUSTERS 1 /* number of clusters */27 #define CLUSTER_SPAN 0 /* address increment between clusters */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 */24 #define NB_CLUSTERS 1 /* number of clusters */ 25 #define CLUSTER_SPAN 0 /* address increment between clusters */ 26 #define NB_PROCS 4 /* max number of processors per cluster */ 27 #define NB_TIMERS 4 /* number of timers per cluster */ 28 #define NB_DMAS 1 /* total number of DMA channels */ 29 #define NB_TTYS 7 /* total number of TTY terminals */ 32 30 33 31 /* software parameters */ 34 32 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 */37 #define GIET_NB_PT2_MAX 16 /* max number of level 2 page tables per vspace */38 #define GIET_TICK_VALUE 20000/* context switch period (number of cycles) */33 #define GIET_NB_TASKS_MAX 4 /* max number of tasks per processor */ 34 #define GIET_NB_VSPACE_MAX 3 /* max number of virtual spaces */ 35 #define GIET_NB_PT2_MAX 16 /* max number of level 2 page tables per vspace */ 36 #define GIET_TICK_VALUE 65536 /* context switch period (number of cycles) */ 39 37 40 38 #endif -
soft/giet_vm/libs/barrier.c
r160 r165 11 11 // The barrier itself must have been allocated in a shared data segment. 12 12 /////////////////////////////////////////////////////////////////////////////////// 13 14 #include "barrier.h" 13 15 14 16 /////////////////////////////////////////////////////////////////////////////////// -
soft/giet_vm/libs/barrier.h
r158 r165 15 15 typedef struct giet_barrier_s { 16 16 char name[32]; // barrier name 17 unsigned int init; 18 unsigned int count; 19 } giet_barrier_t 17 unsigned int init; // total number of participants 18 unsigned int count; // number of not yet arrived tasks 19 } giet_barrier_t; 20 20 21 21 ////////////////////////////////////////////////////////////////////////////// 22 // MWMRaccess functions22 // access functions 23 23 ////////////////////////////////////////////////////////////////////////////// 24 24 -
soft/giet_vm/libs/mwmr_channel.c
r159 r165 12 12 // The mwmr_read() and mwmr_write() functions do not require a system call. 13 13 // The channel itself must have been allocated in a non cacheable segment, 14 // if the platform does not provide hardwa te cache coherence.14 // if the platform does not provide hardware cache coherence. 15 15 // 16 16 // ALL MWMR channels must be defined in the mapping_info data structure, … … 37 37 // mwmr_lock_aquire() 38 38 // This blocking function returns only when the lock has been taken. 39 // If the lock is already taken a randomdelay is introduced before retry.40 ////////////////////////////////////////////////////////////////////////////// 41 void mwmr_lock_acquire(unsigned int* plock)39 // If the lock is already taken a fixed delay is introduced before retry. 40 ////////////////////////////////////////////////////////////////////////////// 41 void mwmr_lock_acquire(unsigned int* lock_address) 42 42 { 43 register unsigned int* plock = lock_address; 44 register unsigned int delay = 100; 43 45 asm volatile ( 44 46 "mwmr_lock_try: \n" 45 47 "ll $2, 0(%0) \n" /* $2 <= lock current value */ 46 "bnez $2, mwmr_lock_delay \n" /* retry if lock already taken*/48 "bnez $2, mwmr_lock_delay \n" /* retry after delay if lock busy */ 47 49 "li $3, 1 \n" /* $3 <= argument for sc */ 48 50 "sc $3, 0(%0) \n" /* try to get lock */ 49 51 "bnez $3, mwmr_lock_ok \n" /* exit if atomic */ 50 51 52 "mwmr_lock_delay: \n" 52 "jal rand \n" /* rand() system call */ 53 "nop \n" 54 "andi $4, $2, 0xFF \n" /* $4 <= random delay < 256 cycles */ 55 56 "mwmr_lock_loop: \n" 53 "move $4, %1 \n" /* $4 <= delay */ 54 "mwmr_lock_loop: \n" 55 "beqz $4, mwmr_lock_loop \n" /* test end delay */ 57 56 "addi $4, $4, -1 \n" /* $4 <= $4 - 1 */ 58 "beqz $4, mwmr_lock_loop \n" /* test end delay */ 59 "nop \n" 60 "j mwmr_lock_try \n" /* retry */ 57 "j mwmr_lock_try \n" /* retry ll */ 61 58 "nop \n" 62 59 "mwmr_lock_ok: \n" 63 60 : 64 :"r"(plock) 61 :"r"(plock), "r"(delay) 65 62 :"$2", "$3", "$4"); 66 63 } … … 117 114 { 118 115 mwmr->lock = 0; 119 for ( x = rand()>>8 ; x > 0 ; x-- ) asm volatile ( "nop" );116 for ( x = giet_rand()>>8 ; x > 0 ; x-- ) asm volatile ( "nop" ); 120 117 } 121 118 else // write as many items as possible, release lock and retry after delay … … 135 132 } 136 133 // random delay before retry 137 for ( x = rand()>>6 ; x > 0 ; x-- ) asm volatile ( "nop" );134 for ( x = giet_rand()>>6 ; x > 0 ; x-- ) asm volatile ( "nop" ); 138 135 } 139 136 } … … 188 185 { 189 186 mwmr->lock = 0; 190 for ( x = rand()>>8 ; x > 0 ; x-- ) asm volatile ( "nop" );187 for ( x = giet_rand()>>8 ; x > 0 ; x-- ) asm volatile ( "nop" ); 191 188 } 192 189 else // read as many items as possible, release lock and retry after delay … … 206 203 } 207 204 // random delay before retry 208 for ( x = rand()>>6 ; x > 0 ; x-- ) asm volatile ( "nop" );205 for ( x = giet_rand()>>6 ; x > 0 ; x-- ) asm volatile ( "nop" ); 209 206 } 210 207 } -
soft/giet_vm/libs/spin_lock.c
r159 r165 28 28 // If the lock is already taken a random delay is introduced before retry. 29 29 /////////////////////////////////////////////////////////////////////////////////// 30 void lock_acquire( giet_lock_t* lock )30 void lock_acquire( giet_lock_t* lock ) 31 31 { 32 unsigned in *tplock = &lock->value;32 unsigned int* plock = &lock->value; 33 33 34 34 asm volatile ( … … 41 41 42 42 "giet_lock_delay: \n" 43 "jal rand \n" /*rand() system call */43 "jal giet_rand \n" /* giet_rand() system call */ 44 44 "nop \n" 45 "andi $4, $2, 0xFF \n" /* $4 <= randomdelay < 256 cycles */45 "andi $4, $2, 0xFF \n" /* $4 <= delay < 256 cycles */ 46 46 47 47 "giet_lock_loop: \n" -
soft/giet_vm/libs/spin_lock.h
r159 r165 23 23 ////////////////////////////////////////////////////////////////////////////// 24 24 25 unsigned intlock_acquire( giet_lock_t* lock );25 void lock_acquire( giet_lock_t* lock ); 26 26 27 27 void lock_release( giet_lock_t* lock ); -
soft/giet_vm/libs/stdio.c
r160 r165 17 17 #define SYSCALL_TTY_WRITE 0x02 18 18 #define SYSCALL_TTY_READ 0x03 19 #define SYSCALL_TIMER_WRITE 0x0420 #define SYSCALL_TIMER_READ 0x0521 19 #define SYSCALL_GCD_WRITE 0x06 22 20 #define SYSCALL_GCD_READ 0x07 … … 37 35 38 36 ////////////////////////////////////////////////////////////////////////////////// 39 // 37 // sys_call() 40 38 // This generic C function is used to implement all system calls. 39 // It writes the system call arguments in the proper registers, 40 // and tells GCC what has been modified by system call execution. 41 41 ////////////////////////////////////////////////////////////////////////////////// 42 42 static inline unsigned int sys_call( unsigned int call_no, … … 83 83 84 84 //////////////////////////////////////////////////////////////////////////////////// 85 // procid() 85 // giet_procid() 86 //////////////////////////////////////////////////////////////////////////////////// 86 87 // This function returns the processor identifier. 87 88 //////////////////////////////////////////////////////////////////////////////////// 88 unsigned int procid()89 unsigned int giet_procid() 89 90 { 90 91 return sys_call(SYSCALL_PROCID, … … 92 93 } 93 94 //////////////////////////////////////////////////////////////////////////////////// 94 // proctime() 95 // giet_proctime() 96 //////////////////////////////////////////////////////////////////////////////////// 95 97 // This function returns the local processor time (clock cycles since boot) 96 98 //////////////////////////////////////////////////////////////////////////////////// 97 unsigned int proctime()99 unsigned int giet_proctime() 98 100 { 99 101 return sys_call(SYSCALL_PROCTIME, … … 104 106 105 107 //////////////////////////////////////////////////////////////////////////////////// 106 // tty_putc() 108 // giet_tty_putc() 109 //////////////////////////////////////////////////////////////////////////////////// 107 110 // This function displays a single ascii character on a terminal. 108 111 // The terminal index must be defined in the task context in the boot phase. … … 110 113 // - Returns 1 if the character has been written, 0 otherwise. 111 114 //////////////////////////////////////////////////////////////////////////////////// 112 unsigned int tty_putc(char byte)115 unsigned int giet_tty_putc(char byte) 113 116 { 114 117 return sys_call(SYSCALL_TTY_WRITE, … … 118 121 } 119 122 //////////////////////////////////////////////////////////////////////////////////// 120 // tty_puts() 123 // giet_tty_puts() 124 //////////////////////////////////////////////////////////////////////////////////// 121 125 // This function displays a string on a terminal. 122 126 // The terminal index must be defined in the task context in the boot phase. … … 125 129 // - Returns the number of written characters. 126 130 //////////////////////////////////////////////////////////////////////////////////// 127 unsigned int tty_puts(char *buf)131 unsigned int giet_tty_puts(char *buf) 128 132 { 129 133 unsigned int length = 0; … … 138 142 } 139 143 //////////////////////////////////////////////////////////////////////////////////// 140 // tty_putw() 144 // giet_tty_putw() 145 //////////////////////////////////////////////////////////////////////////////////// 141 146 // This function displays the value of a 32-bit word with decimal characters. 142 147 // The terminal index must be defined in the task context in the boot phase. … … 144 149 // Returns the number of written characters (should be equal to ten). 145 150 //////////////////////////////////////////////////////////////////////////////////// 146 unsigned int tty_putw(unsigned int val)151 unsigned int giet_tty_putw(unsigned int val) 147 152 { 148 153 char buf[10]; … … 160 165 161 166 //////////////////////////////////////////////////////////////////////////////////// 162 // tty_getc() 167 // giet_tty_getc_no_irq() 168 //////////////////////////////////////////////////////////////////////////////////// 163 169 // This blocking function fetches a single ascii character from a terminal. 164 170 // The terminal index must be defined in the task context in the boot phase. … … 166 172 // - Returns necessarily 0 when completed. 167 173 //////////////////////////////////////////////////////////////////////////////////// 168 unsigned int tty_getc(char *byte)174 unsigned int giet_tty_getc_no_irq(char *byte) 169 175 { 170 176 unsigned int ret = 0; … … 179 185 } 180 186 //////////////////////////////////////////////////////////////////////////////////// 181 // tty_getc_irq() 187 // giet_tty_getc() 188 //////////////////////////////////////////////////////////////////////////////////// 182 189 // This blocking function fetches a single ascii character from a terminal. 183 190 // The terminal index must be defined in the task context in the boot phase. … … 185 192 // - Returns 0 when completed. 186 193 //////////////////////////////////////////////////////////////////////////////////// 187 unsigned int tty_getc_irq(char *byte)194 unsigned int giet_tty_getc(char *byte) 188 195 { 189 196 unsigned int ret = 0; … … 198 205 } 199 206 //////////////////////////////////////////////////////////////////////////////////// 200 // tty_gets_irq() 207 // giet_tty_gets() 208 //////////////////////////////////////////////////////////////////////////////////// 201 209 // This blocking function fetches a string from a terminal to a fixed length buffer. 202 210 // The terminal index must be defined in the task context in the boot phase. … … 211 219 // removed from the target buffer. 212 220 //////////////////////////////////////////////////////////////////////////////////// 213 unsigned int tty_gets_irq(char *buf, unsigned int bufsize) 221 unsigned int giet_tty_gets( char* buf, 222 unsigned int bufsize ) 214 223 { 215 224 unsigned int ret; … … 240 249 } 241 250 //////////////////////////////////////////////////////////////////////////////////// 242 // tty_getw_irq() 251 // giet_tty_getw() 252 //////////////////////////////////////////////////////////////////////////////////// 243 253 // This blocking function fetches a string of decimal characters (most 244 254 // significant digit first) to build a 32-bit unsigned integer. … … 256 266 // bits range, the zero value is returned. 257 267 //////////////////////////////////////////////////////////////////////////////////// 258 unsigned int tty_getw_irq(unsigned int *val)268 unsigned int giet_tty_getw(unsigned int *val) 259 269 { 260 270 unsigned char buf[32]; … … 281 291 buf[max] = byte; 282 292 max++; 283 tty_putc(byte);293 giet_tty_putc(byte); 284 294 } 285 295 else if ((byte == 0x0A) || (byte == 0x0D)) /* LF or CR character */ … … 292 302 { 293 303 max--; /* cancel the character */ 294 tty_putc(0x08);295 tty_putc(0x20);296 tty_putc(0x08);304 giet_tty_putc(0x08); 305 giet_tty_putc(0x20); 306 giet_tty_putc(0x08); 297 307 } 298 308 } … … 301 311 for (i = 0; i < max; i++) /* cancel the string */ 302 312 { 303 tty_putc(0x08);304 tty_putc(0x20);305 tty_putc(0x08);313 giet_tty_putc(0x08); 314 giet_tty_putc(0x20); 315 giet_tty_putc(0x08); 306 316 } 307 tty_putc(0x30);317 giet_tty_putc(0x30); 308 318 *val = 0; /* return 0 value */ 309 319 return 0; … … 329 339 for (i = 0; i < max; i++) /* cancel the string */ 330 340 { 331 tty_putc(0x08);332 tty_putc(0x20);333 tty_putc(0x08);334 } 335 tty_putc(0x30);341 giet_tty_putc(0x08); 342 giet_tty_putc(0x20); 343 giet_tty_putc(0x08); 344 } 345 giet_tty_putc(0x30); 336 346 *val = 0; /* return 0 value */ 337 347 } … … 339 349 } 340 350 //////////////////////////////////////////////////////////////////////////////////// 341 // tty_printf() 351 // giet_tty_printf() 352 //////////////////////////////////////////////////////////////////////////////////// 342 353 // This function is a simplified version of the mutek_printf() function. 343 354 // The terminal index must be defined in the calling task context. … … 351 362 // - Returns 0 if success, > 0 if error. 352 363 //////////////////////////////////////////////////////////////////////////////////// 353 unsigned int tty_printf(char *format, ...)364 unsigned int giet_tty_printf(char *format, ...) 354 365 { 355 366 va_list ap; … … 450 461 } 451 462 452 ///// Timer device related system calls ///// 453 454 #define TIMER_VALUE 0 455 #define TIMER_MODE 1 456 #define TIMER_PERIOD 2 457 #define TIMER_RESETIRQ 3 458 459 /* 460 * timer_set_mode() 461 * 462 * This function defines the operation mode of a timer. The possible values for 463 * this mode are: 464 * - 0x0 : Timer not activated 465 * - 0x1 : Timer activated, but no interrupt is generated 466 * - 0x3 : Timer activarted and periodic interrupts generated 467 * 468 * - Returns 0 if success, > 0 if error. 469 */ 470 unsigned int timer_set_mode(unsigned int val) 471 { 472 return sys_call(SYSCALL_TIMER_WRITE, 473 TIMER_MODE, 474 val, 475 0, 0); 476 } 477 478 /* 479 * timer_set_period() 480 * 481 * This function defines the period value of a timer to enable a periodic 482 * interrupt. 483 * - Returns 0 if success, > 0 if error. 484 */ 485 unsigned int timer_set_period(unsigned int val) 486 { 487 return sys_call(SYSCALL_TIMER_WRITE, 488 TIMER_PERIOD, 489 val, 490 0, 0); 491 } 492 493 /* 494 * timer_reset_irq() 495 * 496 * This function resets the interrupt signal issued by a timer. 497 * - Returns 0 if success, > 0 if error. 498 */ 499 unsigned int timer_reset_irq() 500 { 501 return sys_call(SYSCALL_TIMER_WRITE, 502 TIMER_RESETIRQ, 503 0, 0, 0); 504 } 505 506 /* 507 * timer_get_time() 508 * 509 * This function returns the current timing value of a timer. 510 * - Returns 0 if success, > 0 if error. 511 */ 512 unsigned int timer_get_time(unsigned int *time) 513 { 514 return sys_call(SYSCALL_TIMER_READ, 515 TIMER_VALUE, 516 (unsigned int)time, 517 0, 0); 518 } 519 520 ///// GCD (Greatest Common Divider) device related system calls 463 ///// GCD (Greatest Common Divider) related system calls 521 464 522 465 #define GCD_OPA 0 … … 526 469 527 470 ////////////////////////////////////////////////////////////////////////////////// 528 // gcd_set_opa() 471 // giet_gcd_set_opa() 472 ////////////////////////////////////////////////////////////////////////////////// 529 473 // This function sets the operand A in the GCD coprocessor. 530 474 // - Returns 0 if success, > 0 if error. 531 475 ////////////////////////////////////////////////////////////////////////////////// 532 unsigned int g cd_set_opa(unsigned int val)476 unsigned int giet_gcd_set_opa(unsigned int val) 533 477 { 534 478 return sys_call(SYSCALL_GCD_WRITE, … … 538 482 } 539 483 ////////////////////////////////////////////////////////////////////////////////// 540 // gcd_set_opb() 484 // giet_gcd_set_opb() 485 ////////////////////////////////////////////////////////////////////////////////// 541 486 // This function sets operand B in the GCD coprocessor. 542 487 // - Returns 0 if success, > 0 if error. 543 488 ////////////////////////////////////////////////////////////////////////////////// 544 unsigned int g cd_set_opb(unsigned int val)489 unsigned int giet_gcd_set_opb(unsigned int val) 545 490 { 546 491 return sys_call(SYSCALL_GCD_WRITE, … … 550 495 } 551 496 ////////////////////////////////////////////////////////////////////////////////// 552 // gcd_start() 497 // giet_gcd_start() 498 ////////////////////////////////////////////////////////////////////////////////// 553 499 // This function starts the computation in the GCD coprocessor. 554 500 // - Returns 0 if success, > 0 if error. 555 501 ////////////////////////////////////////////////////////////////////////////////// 556 unsigned int g cd_start()502 unsigned int giet_gcd_start() 557 503 { 558 504 return sys_call(SYSCALL_GCD_WRITE, … … 561 507 } 562 508 ////////////////////////////////////////////////////////////////////////////////// 563 // gcd_get_status() 509 // giet_gcd_get_status() 510 ////////////////////////////////////////////////////////////////////////////////// 564 511 // This function gets the status fromn the GCD coprocessor. 565 512 // - The value is 0 when the coprocessor is idle (computation completed). 566 513 ////////////////////////////////////////////////////////////////////////////////// 567 unsigned int g cd_get_status(unsigned int *val)514 unsigned int giet_gcd_get_status(unsigned int *val) 568 515 { 569 516 return sys_call(SYSCALL_GCD_READ, … … 573 520 } 574 521 ////////////////////////////////////////////////////////////////////////////////// 575 // gcd_get_result() 522 // giet_gcd_get_result() 523 ////////////////////////////////////////////////////////////////////////////////// 576 524 // This function gets the result of the computation from the GCD coprocessor. 577 525 ////////////////////////////////////////////////////////////////////////////////// 578 unsigned int g cd_get_result(unsigned int *val)526 unsigned int giet_gcd_get_result(unsigned int *val) 579 527 { 580 528 return sys_call(SYSCALL_GCD_READ, … … 587 535 588 536 ////////////////////////////////////////////////////////////////////////////////// 589 // ioc_write() 537 // giet_ioc_write() 538 ////////////////////////////////////////////////////////////////////////////////// 590 539 // Transfer data from a memory buffer to a file on the block_device. 591 540 // lba : Logical Block Address (first block index) … … 594 543 // - Returns 0 if success, > 0 if error (e.g. memory buffer not in user space). 595 544 ////////////////////////////////////////////////////////////////////////////////// 596 unsigned int ioc_write(unsigned int lba, void *buffer, unsigned int count) 545 unsigned int giet_ioc_write( unsigned int lba, 546 void* buffer, 547 unsigned int count) 597 548 { 598 549 return sys_call(SYSCALL_IOC_WRITE, … … 603 554 } 604 555 ////////////////////////////////////////////////////////////////////////////////// 605 // ioc_read() 556 // giet_ioc_read() 557 ////////////////////////////////////////////////////////////////////////////////// 606 558 // Transfer data from a file on the block_device to a memory buffer. 607 559 // lba : Logical Block Address (first block index) … … 610 562 // - Returns 0 if success, > 0 if error (e.g. memory buffer not in user space). 611 563 ////////////////////////////////////////////////////////////////////////////////// 612 unsigned int ioc_read(unsigned int lba, void *buffer, unsigned int count) 564 unsigned int giet_ioc_read( unsigned int lba, 565 void* buffer, 566 unsigned int count ) 613 567 { 614 568 return sys_call(SYSCALL_IOC_READ, … … 619 573 } 620 574 ////////////////////////////////////////////////////////////////////////////////// 621 // ioc_completed() 575 // giet_ioc_completed() 576 ////////////////////////////////////////////////////////////////////////////////// 622 577 // This blocking function returns 0 when the I/O transfer is 623 578 // successfully completed, and returns 1 if an address error has been detected. 624 579 ////////////////////////////////////////////////////////////////////////////////// 625 unsigned int ioc_completed()580 unsigned int giet_ioc_completed() 626 581 { 627 582 return sys_call(SYSCALL_IOC_COMPLETED, … … 632 587 633 588 ////////////////////////////////////////////////////////////////////////////////// 634 // fb_sync_write() 589 // giet_fb_sync_write() 590 ////////////////////////////////////////////////////////////////////////////////// 635 591 // This blocking function use a memory copy strategy to transfer data from a 636 592 // user buffer to the frame buffer device in kernel space. … … 640 596 // - Returns 0 if success, > 0 if error (e.g. memory buffer not in user space). 641 597 ////////////////////////////////////////////////////////////////////////////////// 642 unsigned int fb_sync_write(unsigned int offset, void *buffer, unsigned int length) 598 unsigned int giet_fb_sync_write( unsigned int offset, 599 void* buffer, 600 unsigned int length ) 643 601 { 644 602 return sys_call(SYSCALL_FB_SYNC_WRITE, … … 649 607 } 650 608 ////////////////////////////////////////////////////////////////////////////////// 651 // fb_sync_read() 609 // giet_fb_sync_read() 610 ////////////////////////////////////////////////////////////////////////////////// 652 611 // This blocking function use a memory copy strategy to transfer data from the 653 612 // frame buffer device in kernel space to an user buffer. … … 657 616 // - Returns 0 if success, > 0 if error (e.g. memory buffer not in user space). 658 617 ////////////////////////////////////////////////////////////////////////////////// 659 unsigned int fb_sync_read(unsigned int offset, void *buffer, unsigned int length) 618 unsigned int giet_fb_sync_read( unsigned int offset, 619 void* buffer, 620 unsigned int length ) 660 621 { 661 622 return sys_call(SYSCALL_FB_SYNC_READ, … … 666 627 } 667 628 ////////////////////////////////////////////////////////////////////////////////// 668 // fb_write() 629 // giet_fb_write() 630 ////////////////////////////////////////////////////////////////////////////////// 669 631 // This non-blocking function use the DMA coprocessor to transfer data from a 670 632 // user buffer to the frame buffer device in kernel space. … … 676 638 // - Returns 0 if success, > 0 if error (e.g. memory buffer not in user space). 677 639 ////////////////////////////////////////////////////////////////////////////////// 678 unsigned int fb_write(unsigned int offset, void *buffer, unsigned int length) 640 unsigned int giet_fb_write( unsigned int offset, 641 void* buffer, 642 unsigned int length ) 679 643 { 680 644 return sys_call(SYSCALL_FB_WRITE, … … 685 649 } 686 650 ////////////////////////////////////////////////////////////////////////////////// 687 // fb_read() 651 // giet_fb_read() 652 ////////////////////////////////////////////////////////////////////////////////// 688 653 // This non-blocking function use the DMA coprocessor to transfer data from the 689 654 // frame buffer device in kernel space to an user buffer. … … 695 660 // - Returns 0 if success, > 0 if error (e.g. memory buffer not in user space). 696 661 ////////////////////////////////////////////////////////////////////////////////// 697 unsigned int fb_read( unsigned intoffset,698 void *buffer,699 unsigned intlength )662 unsigned int giet_fb_read( unsigned int offset, 663 void* buffer, 664 unsigned int length ) 700 665 { 701 666 return sys_call(SYSCALL_FB_READ, … … 706 671 } 707 672 ////////////////////////////////////////////////////////////////////////////////// 708 // fb_completed() 673 // giet_fb_completed() 674 ////////////////////////////////////////////////////////////////////////////////// 709 675 // This blocking function returns when the transfer is completed. 710 676 // - Returns 0 if success, > 0 if error. 711 677 ////////////////////////////////////////////////////////////////////////////////// 712 unsigned int fb_completed()678 unsigned int giet_fb_completed() 713 679 { 714 680 return sys_call(SYSCALL_FB_COMPLETED, … … 716 682 } 717 683 718 ///// Platform or mappingrelated system calls /////719 720 ////////////////////////////////////////////////////////////////////////////////// 721 // mwmr_base()722 // TODO!723 // This function returns in argument bufferthe virtual base address724 // of a MWMR communication channel, identified by the two arguments725 // vspace_name and channel_name.726 // As the GIET does not support dynamic allocation, the MWMR channel727 // must be declared in the mapping_info data structure to be initialised728 // in the boot phase.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)684 ///// Miscellaneous related system calls ///// 685 686 ////////////////////////////////////////////////////////////////////////////////// 687 // giet_vobj_get_vbase() 688 ////////////////////////////////////////////////////////////////////////////////// 689 // This function writes in argument (vobj_vaddr) the virtual base address 690 // of a vobj (defined in the mapping_info data structure), identified by 691 // the two arguments (vspace_name and vobj_name). 692 // The (vobj_type) argument is redundant, and used for coherence checking. 693 // - Returns the address if success, 0 if error ( not defined or wrong type ) 694 ////////////////////////////////////////////////////////////////////////////////// 695 unsigned int giet_vobj_get_vbase( char* vspace_name, 696 char* vobj_name, 697 unsigned int vobj_type, 698 unsigned int* vobj_vaddr ) 733 699 { 734 700 return sys_call(SYSCALL_VOBJ_GET_VBASE, … … 736 702 (unsigned int)vobj_name, 737 703 (unsigned int)vobj_type, 738 (unsigned int)vobj_buffer); 739 } 740 //////////////////////////////////////////////////////////////////////////////////// 741 // proc_number() 704 (unsigned int)vobj_vaddr); 705 } 706 707 //////////////////////////////////////////////////////////////////////////////////// 708 // giet_proc_number() 709 //////////////////////////////////////////////////////////////////////////////////// 742 710 // This function returns in the buffer argument the number of processors 743 711 // in the cluster specified by the cluster_id argument. 744 712 // - Returns 0 if success, > 0 if error ( cluster index too large ) 745 713 //////////////////////////////////////////////////////////////////////////////////// 746 unsigned int proc_number( unsigned intcluster_id,747 unsigned int*buffer )714 unsigned int giet_proc_number( unsigned int cluster_id, 715 unsigned int* buffer ) 748 716 { 749 717 return sys_call(SYSCALL_PROC_NUMBER, … … 756 724 757 725 ////////////////////////////////////////////////////////////////////////////////// 758 // exit() 726 // giet_task_exit() 727 ////////////////////////////////////////////////////////////////////////////////// 759 728 // This function stops execution of the calling task with a TTY message, 760 729 // and enter an infinite loop. 761 730 // The task is blocked, but it still consume processor cycles ... 762 731 ////////////////////////////////////////////////////////////////////////////////// 763 void exit() 764 { 765 unsigned int proc_index = procid(); 732 void giet_exit() 733 { 766 734 sys_call(SYSCALL_EXIT, 767 proc_index, 768 0, 0, 0); 735 0, 0, 0, 0); 769 736 } 770 737 /////////////////////////////////////////////////////////////////////////////////// 771 // 738 // giet_rand() 772 739 // This function returns a pseudo-random value derived from the processor cycle 773 740 // count. This value is comprised between 0 & 65535. 774 741 /////////////////////////////////////////////////////////////////////////////////// 775 unsigned int rand()742 unsigned int giet_rand() 776 743 { 777 744 unsigned int x = sys_call(SYSCALL_PROCTIME, … … 783 750 } 784 751 ////////////////////////////////////////////////////////////////////////////////// 785 // 752 // giet_ctx_switch() 786 753 // The user task calling this function is descheduled and 787 754 // the processor is allocated to another task. 788 755 ////////////////////////////////////////////////////////////////////////////////// 789 unsigned int ctx_switch()756 unsigned int giet_ctx_switch() 790 757 { 791 758 return sys_call(SYSCALL_CTX_SWITCH, -
soft/giet_vm/libs/stdio.h
r160 r165 12 12 13 13 /* MIPS32 related functions */ 14 unsigned int procid(); 15 unsigned int proctime(); 16 unsigned int procnumber(); 14 unsigned int giet_procid(); 15 unsigned int giet_proctime(); 17 16 18 17 /* TTY device related functions */ 19 unsigned int tty_putc(char byte); 20 unsigned int tty_puts(char *buf); 21 unsigned int tty_putw(unsigned int val); 22 unsigned int tty_getc(char *byte); 23 unsigned int tty_getc_irq(char *byte); 24 unsigned int tty_gets_irq(char *buf, unsigned int bufsize); 25 unsigned int tty_getw_irq(unsigned int *val); 26 unsigned int tty_printf(char *format,...); 27 28 /* Timer device related functions */ 29 unsigned int timer_set_mode(unsigned int mode); 30 unsigned int timer_set_period(unsigned int period); 31 unsigned int timer_reset_irq(); 32 unsigned int timer_get_time(unsigned int *time); 18 unsigned int giet_tty_putc(char byte); 19 unsigned int giet_tty_puts(char *buf); 20 unsigned int giet_tty_putw(unsigned int val); 21 unsigned int giet_tty_getc_no_irq(char *byte); 22 unsigned int giet_tty_getc(char *byte); 23 unsigned int giet_tty_gets(char *buf, unsigned int bufsize); 24 unsigned int giet_tty_getw(unsigned int *val); 25 unsigned int giet_tty_printf(char *format,...); 33 26 34 27 /* GCD coprocessor related functions */ 35 unsigned int g cd_set_opa(unsigned int val);36 unsigned int g cd_set_opb(unsigned int val);37 unsigned int g cd_start();38 unsigned int g cd_get_result(unsigned int *val);39 unsigned int g cd_get_status(unsigned int *val);28 unsigned int giet_gcd_set_opa(unsigned int val); 29 unsigned int giet_gcd_set_opb(unsigned int val); 30 unsigned int giet_gcd_start(); 31 unsigned int giet_gcd_get_result(unsigned int *val); 32 unsigned int giet_gcd_get_status(unsigned int *val); 40 33 41 34 /* Block device related functions */ 42 unsigned int ioc_read(unsigned int lba, void *buffer, unsigned int count); 43 unsigned int ioc_write(unsigned int lba, void *buffer, unsigned int count); 44 unsigned int ioc_completed(); 35 unsigned int giet_ioc_read( unsigned int lba, 36 void* buffer, 37 unsigned int count); 38 unsigned int giet_ioc_write(unsigned int lba, 39 void* buffer, 40 unsigned int count); 41 unsigned int giet_ioc_completed(); 45 42 46 43 /* Frame buffer device related functions */ 47 unsigned int fb_sync_read(unsigned int offset, void *buffer, unsigned int length); 48 unsigned int fb_sync_write(unsigned int offset, void *buffer, unsigned int length); 49 unsigned int fb_read(unsigned int offset, void *buffer, unsigned int length); 50 unsigned int fb_write(unsigned int offset, void *buffer, unsigned int length); 51 unsigned int fb_completed(); 52 53 /* Software barrier related functions */ 54 unsigned int barrier_init(unsigned int index, unsigned int count); 55 unsigned int barrier_wait(unsigned int index); 44 unsigned int giet_fb_sync_read( unsigned int offset, 45 void* buffer, 46 unsigned int length ); 47 unsigned int giet_fb_sync_write(unsigned int offset, 48 void* buffer, 49 unsigned int length ); 50 unsigned int giet_fb_read( unsigned int offset, 51 void* buffer, 52 unsigned int length ); 53 unsigned int giet_fb_write( unsigned int offset, 54 void* buffer, 55 unsigned int length ); 56 unsigned int giet_fb_completed(); 56 57 57 58 /* Misc */ 58 void exit(); 59 unsigned int rand(); 59 unsigned int giet_vobj_get_vbase( char* vspace_name, 60 char* vobj_name, 61 unsigned int vobj_type, 62 unsigned int* vobj_vaddr ); 63 void giet_exit(); 64 unsigned int giet_rand(); 60 65 unsigned int ctx_switch(); 61 unsigned int vobj_get_vbase( char* vspace_name, char* vobj_name, 62 unsigned int vobj_type, unsigned int* vobj_buffer); 66 unsigned int giet_procnumber(); 63 67 64 68 /* 65 69 * memcpy function 66 * 67 * This function is likely not to be called directly but GCC can automatically 68 * issue call to it during compilation so we must provide it. 'static inline' 69 * so the function's code is directly included when used. 70 * 70 * This function is required because it can be gnerated by GCC 71 * during compilation so we must provide it. 71 72 * Code taken from MutekH. 72 73 */ -
soft/giet_vm/map.xml
r161 r165 5 5 clusters = "1" 6 6 psegs = "9" 7 ttys = "9" 8 vspaces = "4" 7 ttys = "7" 8 fbs = "0" 9 vspaces = "3" 9 10 globals = "13" > 10 11 11 12 <clusterset> 12 <cluster procs = "4" 13 timers = "4" 14 dmas = "4" /> 13 <cluster index = "0" 14 procs = "4" /> 15 15 </clusterset> 16 16 … … 59 59 psegname = "PSEG_ROM" 60 60 ident = "1" > 61 <vobj name = "seg_boot" 62 type = "ELF" 63 length = "0x00008000" 64 binpath = "build/boot.elf" 65 /> 61 <vobj name = "seg_boot" 62 type = "ELF" 63 length = "0x00008000" 64 binpath = "build/boot.elf" /> 66 65 </vseg> 67 66 … … 71 70 psegname = "PSEG_ROM" 72 71 ident = "1" > 73 <vobj name = "boot_stack"74 type = "BUFFER"75 length = "0x00004000" />72 <vobj name = "boot_stack" 73 type = "BUFFER" 74 length = "0x00004000" /> 76 75 </vseg> 77 76 … … 81 80 psegname = "PSEG_ROM" 82 81 ident = "1" > 83 <vobj name = "seg_mapping" 84 type = "ELF" 85 length = "0x00004000" 86 binpath = "map.bin" 87 /> 82 <vobj name = "seg_mapping" 83 type = "ELF" 84 length = "0x00004000" 85 binpath = "map.bin" /> 88 86 </vseg> 89 87 … … 105 103 psegname = "PSEG_RAK" 106 104 ident = "1" > 107 <vobj name = "seg_kernel_data" 108 type = "ELF" 109 length = "0x00010000" 110 binpath = "build/sys.elf" 111 /> 105 <vobj name = "seg_kernel_data" 106 type = "ELF" 107 length = "0x00010000" 108 binpath = "build/sys.elf" /> 112 109 </vseg> 113 110 … … 117 114 psegname = "PSEG_RAK" 118 115 ident = "1" > 119 <vobj name = "seg_kernel_uncdata" 120 type = "ELF" 121 length = "0x00010000" 122 binpath = "build/sys.elf" 123 /> 116 <vobj name = "seg_kernel_uncdata" 117 type = "ELF" 118 length = "0x00010000" 119 binpath = "build/sys.elf" /> 124 120 </vseg> 125 121 … … 129 125 psegname = "PSEG_RAK" 130 126 ident = "1" > 131 <vobj name = "seg_kernel_init" 132 type = "ELF" 133 length = "0x00010000" 134 binpath = "build/sys.elf" 135 /> 127 <vobj name = "seg_kernel_init" 128 type = "ELF" 129 length = "0x00010000" 130 binpath = "build/sys.elf" /> 136 131 </vseg> 137 132 … … 142 137 psegname = "PSEG_TTY" 143 138 ident = "1" > 144 <vobj name = "tty"145 type = "PERI"146 length = "0x00000100" />139 <vobj name = "tty" 140 type = "PERI" 141 length = "0x00000100" /> 147 142 </vseg> 148 143 … … 152 147 psegname = "PSEG_TIM" 153 148 ident = "1" > 154 <vobj name = "timer"155 type = "PERI"156 length = "0x00000080" />149 <vobj name = "timer" 150 type = "PERI" 151 length = "0x00000080" /> 157 152 </vseg> 158 153 … … 162 157 psegname = "PSEG_IOC" 163 158 ident = "1" > 164 <vobj name = "ioc"165 type = "PERI"166 length = "0x00000020" />159 <vobj name = "ioc" 160 type = "PERI" 161 length = "0x00000020" /> 167 162 </vseg> 168 163 … … 172 167 psegname = "PSEG_DMA" 173 168 ident = "1" > 174 <vobj name = "dma"175 type = "PERI"176 length = "0x00000100" />169 <vobj name = "dma" 170 type = "PERI" 171 length = "0x00000100" /> 177 172 </vseg> 178 173 … … 182 177 psegname = "PSEG_FBF" 183 178 ident = "1" > 184 <vobj name = "fb"185 type = "PERI"186 length = "0x00004000" />179 <vobj name = "fb" 180 type = "PERI" 181 length = "0x00004000" /> 187 182 </vseg> 188 183 … … 192 187 psegname = "PSEG_ICU" 193 188 ident = "1" > 194 <vobj name = "icu"195 type = "PERI"196 length = "0x00000100" />189 <vobj name = "icu" 190 type = "PERI" 191 length = "0x00000100" /> 197 192 </vseg> 198 193 </globalset> 199 194 200 195 <vspaceset> 201 <vspace name = "router" 202 funcs = "seg_data_router" 203 ttys = "4" > 196 <vspace name = "router" 197 startname = "seg_data_router" > 204 198 205 199 <vseg name = "seg_data_router" 206 200 vbase = "0x00800000" 207 201 mode = "__WU" 208 psegname = "PSEG_RAU" 209 ident = "0" > 210 <vobj name = "seg_data_router" 211 type = "ELF" 212 length = "0x00010000" 213 binpath = "build/router.elf" 214 /> 202 psegname = "PSEG_RAU" > 203 <vobj name = "seg_data_router" 204 type = "ELF" 205 length = "0x00010000" 206 binpath = "build/router.elf" /> 215 207 </vseg> 216 208 … … 218 210 vbase = "0x00400000" 219 211 mode = "CX_U" 220 psegname = "PSEG_RAU" 221 ident = "0" > 222 <vobj name = "seg_code_router" 223 type = "ELF" 224 length = "0x00010000" 225 binpath = "build/router.elf" 226 /> 212 psegname = "PSEG_RAU" > 213 <vobj name = "seg_code_router" 214 type = "ELF" 215 length = "0x00010000" 216 binpath = "build/router.elf" /> 227 217 </vseg> 228 218 … … 230 220 vbase = "0x00300000" 231 221 mode = "C___" 232 psegname = "PSEG_RAU" 233 ident = "0" > 234 <vobj name = "ptab" 235 type = "PTAB" 236 length = "0x00010000" 237 align = "13" 238 /> 222 psegname = "PSEG_RAU" > 223 <vobj name = "ptab_router" 224 type = "PTAB" 225 length = "0x00010000" 226 align = "13" /> 239 227 </vseg> 240 228 … … 243 231 mode = "C_WU" 244 232 psegname = "PSEG_RAU" > 245 <vobj name = "stack_producer"246 type = "BUFFER"247 length = "0x00010000" />233 <vobj name = "stack_producer" 234 type = "BUFFER" 235 length = "0x00010000" /> 248 236 </vseg> 249 237 … … 252 240 mode = "C_WU" 253 241 psegname = "PSEG_RAU" > 254 <vobj name = "stack_consumer"255 type = "BUFFER"256 length = "0x00010000" />242 <vobj name = "stack_consumer" 243 type = "BUFFER" 244 length = "0x00010000" /> 257 245 </vseg> 258 246 … … 261 249 mode = "C_WU" 262 250 psegname = "PSEG_RAU" > 263 <vobj name = "stack_router_A"264 type = "BUFFER"265 length = "0x00010000" />251 <vobj name = "stack_router_A" 252 type = "BUFFER" 253 length = "0x00010000" /> 266 254 </vseg> 267 255 … … 270 258 mode = "C_WU" 271 259 psegname = "PSEG_RAU" > 272 <vobj name = "stack_router_B"273 type = "BUFFER"274 length = "0x00010000" />275 </vseg> 276 277 <vseg name = "seg_mwmr_ in"260 <vobj name = "stack_router_B" 261 type = "BUFFER" 262 length = "0x00010000" /> 263 </vseg> 264 265 <vseg name = "seg_mwmr_channels" 278 266 vbase = "0x00050000" 279 267 mode = "__WU" 280 268 psegname = "PSEG_RAU" > 281 <vobj name = "mwmr_in" 282 type = "MWMR" 283 length = "0x00000020"/> 284 </vseg> 285 286 <vseg name = "seg_mwmr_out" 287 vbase = "0x00060000" 288 mode = "__WU" 289 psegname = "PSEG_RAU"> 290 <vobj name = "mwmr_out" 291 type = "MWMR" 292 length = "0x00000020"/> 269 <vobj name = "mwmr_in" 270 type = "MWMR" 271 length = "0x00000020" /> 272 <vobj name = "mwmr_out" 273 type = "MWMR" 274 length = "0x00000020" /> 293 275 </vseg> 294 276 … … 298 280 stackname = "stack_producer" 299 281 startid = "0" 300 ttylocid = "0" /> 282 usetty = "1" /> 283 301 284 <task name = "consumer" 302 285 clusterid = "0" … … 304 287 stackname = "stack_consumer" 305 288 startid = "1" 306 ttylocid = "1" /> 289 usetty = "1" /> 290 307 291 <task name = "router_A" 308 292 clusterid = "0" … … 310 294 stackname = "stack_router_A" 311 295 startid = "2" 312 ttylocid = "2" /> 296 usetty = "1" /> 297 313 298 <task name = "router_B" 314 299 clusterid = "0" … … 316 301 stackname = "stack_router_B" 317 302 startid = "2" 318 ttylocid = "3" />303 usetty = "1" /> 319 304 </vspace> 320 305 321 <vspace name = "hello" 322 funcs = "seg_data_hello" 323 ttys = "1" > 306 <vspace name = "hello" 307 startname = "seg_data_hello" > 324 308 325 309 <vseg name = "seg_data_hello" 326 310 vbase = "0x00800000" 327 311 mode = "C_WU" 328 psegname = "PSEG_RAU" 329 ident = "0" > 330 <vobj name = "seg_data_hello" 331 type = "ELF" 332 length = "0x00010000" 333 binpath = "build/hello.elf"/> 312 psegname = "PSEG_RAU" > 313 <vobj name = "seg_data_hello" 314 type = "ELF" 315 length = "0x00010000" 316 binpath = "build/hello.elf" /> 334 317 </vseg> 335 318 … … 337 320 vbase = "0x00400000" 338 321 mode = "CX_U" 339 psegname = "PSEG_RAU" 340 ident = "0" > 341 <vobj name = "seg_code_hello" 342 type = "ELF" 343 length = "0x00010000" 344 binpath = "build/hello.elf"/> 322 psegname = "PSEG_RAU" > 323 <vobj name = "seg_code_hello" 324 type = "ELF" 325 length = "0x00010000" 326 binpath = "build/hello.elf" /> 345 327 </vseg> 346 328 … … 348 330 vbase = "0x00300000" 349 331 mode = "C___" 350 psegname = "PSEG_RAU" 351 ident = "0" > 352 <vobj name = "ptab" 353 type = "PTAB" 354 length = "0x00010000" 355 align = "13" 356 /> 332 psegname = "PSEG_RAU" > 333 <vobj name = "ptab" 334 type = "PTAB" 335 length = "0x00010000" 336 align = "13" /> 357 337 </vseg> 358 338 … … 361 341 mode = "C_WU" 362 342 psegname = "PSEG_RAU" > 363 <vobj name = "stack"364 type = "BUFFER"365 length = "0x00010000" />343 <vobj name = "stack" 344 type = "BUFFER" 345 length = "0x00010000" /> 366 346 </vseg> 367 347 … … 372 352 stackname = "stack" 373 353 startid = "0" 374 ttylocid = "0" />354 usetty = "1" /> 375 355 </vspace> 376 356 377 <vspace name = "pgcd" 378 funcs = "seg_data_pgcd" 379 ttys = "1" > 357 <vspace name = "pgcd" 358 startname = "seg_data_pgcd" > 380 359 381 360 <vseg name = "seg_data_pgcd" 382 361 vbase = "0x00800000" 383 362 mode = "C_WU" 384 psegname = "PSEG_RAU" 385 ident = "0" > 386 <vobj name = "seg_data_pgcd" 387 type = "ELF" 388 length = "0x00010000" 389 binpath = "build/pgcd.elf" /> 363 psegname = "PSEG_RAU" > 364 <vobj name = "seg_data_pgcd" 365 type = "ELF" 366 length = "0x00010000" 367 binpath = "build/pgcd.elf" /> 390 368 </vseg> 391 369 … … 393 371 vbase = "0x00300000" 394 372 mode = "C___" 395 psegname = "PSEG_RAU" 396 ident = "0" > 397 <vobj name = "ptab" 398 type = "PTAB" 399 length = "0x00010000" 400 align = "13" 401 /> 373 psegname = "PSEG_RAU" > 374 <vobj name = "ptab" 375 type = "PTAB" 376 length = "0x00010000" 377 align = "13" /> 402 378 </vseg> 403 379 … … 405 381 vbase = "0x00400000" 406 382 mode = "CX_U" 407 psegname = "PSEG_RAU" 408 ident = "0" > 409 <vobj name = "seg_code_pgcd" 410 type = "ELF" 411 length = "0x00010000" 412 binpath = "build/pgcd.elf" /> 383 psegname = "PSEG_RAU" > 384 <vobj name = "seg_code_pgcd" 385 type = "ELF" 386 length = "0x00010000" 387 binpath = "build/pgcd.elf" /> 413 388 </vseg> 414 389 … … 417 392 mode = "C_WU" 418 393 psegname = "PSEG_RAU" > 419 <vobj name = "stack" 420 type = "BUFFER" 421 length = "0x00010000" /> 422 </vseg> 423 394 <vobj name = "stack" 395 type = "BUFFER" 396 length = "0x00010000" /> 397 </vseg> 424 398 425 399 <task name = "main_pgcd" … … 428 402 stackname = "stack" 429 403 startid = "0" 430 ttylocid = "0" /> 431 </vspace> 432 433 <vspace name = "numsplit" 434 funcs = "seg_data_numsplit" 435 ttys = "2" > 436 437 <vseg name = "seg_data_numsplit" 438 vbase = "0x00800000" 439 mode = "__WU" 440 psegname = "PSEG_RAU" 441 ident = "0" > 442 <vobj name = "seg_data_numsplit" 443 type = "ELF" 444 length = "0x00010000" 445 binpath = "build/numsplit.elf" 446 /> 447 </vseg> 448 449 <vseg name = "seg_code_numsplit" 450 vbase = "0x00400000" 451 mode = "CX_U" 452 psegname = "PSEG_RAU" 453 ident = "0" > 454 <vobj name = "seg_code_numsplit" 455 type = "ELF" 456 length = "0x00010000" 457 binpath = "build/numsplit.elf" 458 /> 459 </vseg> 460 461 <vseg name = "seg_ptab" 462 vbase = "0x00300000" 463 mode = "C___" 464 psegname = "PSEG_RAU" 465 ident = "0" > 466 <vobj name = "ptab" 467 type = "PTAB" 468 length = "0x00010000" 469 align = "13" 470 /> 471 </vseg> 472 473 <vseg name = "seg_stack_producer" 474 vbase = "0x00010000" 475 mode = "C_WU" 476 psegname = "PSEG_RAU" > 477 <vobj name = "stack_producer" 478 type = "BUFFER" 479 length = "0x00010000" /> 480 </vseg> 481 482 <vseg name = "seg_stack_consumer" 483 vbase = "0x00020000" 484 mode = "C_WU" 485 psegname = "PSEG_RAU" > 486 <vobj name = "stack_consumer" 487 type = "BUFFER" 488 length = "0x00010000" /> 489 </vseg> 490 491 <vseg name = "seg_mwmr" 492 vbase = "0x00050000" 493 mode = "__WU" 494 psegname = "PSEG_RAU"> 495 <vobj name = "mwmr" 496 type = "MWMR" 497 length = "0x00000080"/> 498 </vseg> 499 500 <task name = "producer" 501 clusterid = "0" 502 proclocid = "0" 503 stackname = "stack_producer" 504 startid = "0" 505 ttylocid = "1" /> 506 507 <task name = "consumer" 508 clusterid = "0" 509 proclocid = "1" 510 stackname = "stack_consumer" 511 startid = "1" 512 ttylocid = "0" /> 404 usetty = "1" /> 513 405 </vspace> 514 406 </vspaceset> -
soft/giet_vm/memo/Makefile
r163 r165 7 7 HDRS += $(wildcard include/libelfpp/dpp/*) 8 8 9 INCLUDES = -Iinclude/libelfpp -Iinclude/libelfpp/elfpp -Iinclude/ 10 9 INCLUDES = -Iinclude/libelfpp -Iinclude/libelfpp/elfpp -Iinclude/ -I../xml 11 10 memo.x: $(SRCS) $(HDRS) 12 11 g++ -Wall -g $(SRCS) $(INCLUDES) -o memo.x -
soft/giet_vm/memo/src/memo.cpp
r163 r165 39 39 #include "memo.h" 40 40 41 42 41 //#define MOVER_DEBUG 43 42 … … 56 55 #ifdef MOVER_DEBUG 57 56 std::cout << "Binary file path: " << m_path << std::endl; 58 //print_mapping_info(m_data);57 print_mapping_info(m_data); 59 58 #endif 60 59 … … 141 140 } 142 141 142 ////////////////////////////////////////// 143 143 void* MeMo::load_bin(std::string filename) 144 144 { … … 167 167 } 168 168 169 169 ///////////// 170 170 MeMo::~MeMo() 171 171 { … … 216 216 MAPPING_CLUSTER_SIZE*header->clusters + 217 217 MAPPING_PSEG_SIZE*header->psegs + 218 MAPPING_VSPACE_SIZE*header->vs egs +219 MAPPING_VS PACE_SIZE*header->vspaces);218 MAPPING_VSPACE_SIZE*header->vspaces + 219 MAPPING_VSEG_SIZE*header->vsegs); 220 220 } 221 221 … … 233 233 234 234 // header 235 std::cout << std::hex << "mapping_info" << std:: endl235 std::cout << std::hex << "mapping_info" << std::dec << std::endl 236 236 << " + signature = " << header->signature << std::endl 237 << " + name = " << header->name << std::endl 238 << " + clusters = " << header->clusters << std::endl 239 << " + psegs = " << header->psegs << std::endl 240 << " + ttys = " << header->ttys << std::endl 241 << " + vspaces = " << header->vspaces << std::endl 242 << " + globals = " << header->globals << std::endl 243 << " + vsegs = " << header->vsegs << std::endl 244 << " + tasks = " << header->tasks << std::endl; 237 << " + name = " << header->name << std::endl 238 << " + clusters = " << header->clusters << std::endl 239 << " + psegs = " << header->psegs << std::endl 240 << " + ttys = " << header->ttys << std::endl 241 << " + fbs = " << header->fbs << std::endl 242 << " + vspaces = " << header->vspaces << std::endl 243 << " + globals = " << header->globals << std::endl 244 << " + vsegs = " << header->vsegs << std::endl 245 << " + vobjs = " << header->vsegs << std::endl 246 << " + tasks = " << header->tasks << std::endl; 245 247 246 248 // psegs 247 249 for ( size_t pseg_id = 0 ; pseg_id < header->psegs ; pseg_id++ ) 248 250 { 249 std::cout << "pseg " << pseg_id << std::endl 250 << " + name = " << pseg[pseg_id].name << std::endl 251 << " + base = " << pseg[pseg_id].base << std::endl 252 << " + length = " << pseg[pseg_id].length << std::endl ; 251 std::cout << "pseg " << pseg[pseg_id].name << std::hex << std::endl 252 << " + base = " << pseg[pseg_id].base << std::endl 253 << " + length = " << pseg[pseg_id].length << std::endl ; 253 254 } 254 255 … … 256 257 for ( size_t vseg_id = 0 ; vseg_id < header->globals ; vseg_id++ ) 257 258 { 258 std::cout << "global vseg: " << vseg_id << std::endl 259 << " + name = " << vseg[vseg_id].name << std::endl 260 << " + vbase = " << vseg[vseg_id].vbase << std::endl 261 << " + length = " << vseg[vseg_id].length << std::endl 262 << " + mode = " << (size_t)vseg[vseg_id].mode << std::endl 263 << " + ident = " << (bool)vseg[vseg_id].ident << std::endl 264 << " + psegname" << pseg[vseg[vseg_id].psegid].name << std::endl; 265 for(size_t vobj_id = vseg[vseg_id].vobj_offset ; vobj_id < vseg[vseg_id].vobj_offset + vseg[vseg_id].vobjs ; vobj_id++ ) 266 { 267 std::cout << "\t vobjs = "<< vobj[vobj_id].name << std::endl; 268 std::cout<<"\t name =" << vobj[vobj_id].name <<std::endl; 269 std::cout<<"\t type =" << vobj[vobj_id].type <<std::endl; 270 std::cout<<"\t length =" << vobj[vobj_id].length <<std::endl; 271 std::cout<<"\t align =" << vobj[vobj_id].align <<std::endl; 272 std::cout<<"\t binpath =" << vobj[vobj_id].binpath <<std::endl; 273 std::cout<<"\t \n"; 274 } 275 } 276 259 std::cout << std::endl; 260 std::cout << "global vseg " << vseg[vseg_id].name << std::hex << std::endl 261 << " + vbase = " << vseg[vseg_id].vbase << std::endl 262 << " + length = " << vseg[vseg_id].length << std::endl 263 << " + mode = " << (size_t)vseg[vseg_id].mode << std::endl 264 << " + ident = " << (bool)vseg[vseg_id].ident << std::endl 265 << " + psegname = " << pseg[vseg[vseg_id].psegid].name << std::endl; 266 for( size_t vobj_id = vseg[vseg_id].vobj_offset ; 267 vobj_id < vseg[vseg_id].vobj_offset + vseg[vseg_id].vobjs ; 268 vobj_id++ ) 269 { 270 std::cout << "\t vobj " << vobj[vobj_id].name << std::endl 271 << "\t + index = " << std::dec << vobj_id << std::endl 272 << "\t + type = " << vobj[vobj_id].type << std::endl 273 << "\t + length = " << vobj[vobj_id].length << std::endl 274 << "\t + align = " << vobj[vobj_id].align << std::endl 275 << "\t + binpath = " << vobj[vobj_id].binpath << std::endl 276 << "\t + init = " << vobj[vobj_id].init << std::endl; 277 } 278 } 277 279 278 280 // vspaces 279 281 for ( size_t vspace_id = 0 ; vspace_id < header->vspaces ; vspace_id++ ) 280 282 { 281 std::cout << "***vspace: " << vspace_id << "***" << std::endl 282 << " + name = " << vspace[vspace_id].name << std::endl 283 << " + ttys = " << vspace[vspace_id].ttys << std::endl; 283 std::cout << "***vspace " << vspace[vspace_id].name << std::endl 284 << " + vsegs = " << vspace[vspace_id].vsegs << std::endl 285 << " + vobjs = " << vspace[vspace_id].vobjs << std::endl 286 << " + tasks = " << vspace[vspace_id].tasks << std::endl; 284 287 285 288 for ( size_t vseg_id = vspace[vspace_id].vseg_offset ; … … 287 290 vseg_id++ ) 288 291 { 289 std::cout << " private vseg: ";290 std::cout << vseg_id<< std::endl291 << " + name = " << vseg[vseg_id].name<< std::endl292 << " + vbase = " << vseg[vseg_id].vbase<< std::endl293 << " + length = " << vseg[vseg_id].length<< std::endl294 << " + mode = " << (size_t)vseg[vseg_id].mode << std::endl295 << " + ident = " << (bool)vseg[vseg_id].ident << std::endl296 << " + psegname = " << pseg[vseg[vseg_id].psegid].name << std::endl << std::endl;297 for(size_t vobj_id = vseg[vseg_id].vobj_offset ; vobj_id < vseg[vseg_id].vobj_offset + vseg[vseg_id].vobjs ;vobj_id++ )292 std::cout << "\t vseg " << vseg[vseg_id].name << std::endl 293 << "\t + vbase = " << vseg[vseg_id].vbase << std::endl 294 << "\t + length = " << vseg[vseg_id].length << std::endl 295 << "\t + mode = " << (size_t)vseg[vseg_id].mode << std::endl 296 << "\t + ident = " << (bool)vseg[vseg_id].ident << std::endl 297 << "\t + psegname = " << pseg[vseg[vseg_id].psegid].name << std::endl; 298 for(size_t vobj_id = vseg[vseg_id].vobj_offset ; 299 vobj_id < vseg[vseg_id].vobj_offset + vseg[vseg_id].vobjs ; 300 vobj_id++ ) 298 301 { 299 std::cout<<"\t\t vobjs =" << vobj[vobj_id].name <<std::endl; 300 std::cout<<"\t\t name =" << vobj[vobj_id].name <<std::endl; 301 std::cout<<"\t\t type =" << vobj[vobj_id].type <<std::endl; 302 std::cout<<"\t\t length =" << vobj[vobj_id].length <<std::endl; 303 std::cout<<"\t\t align =" << vobj[vobj_id].align <<std::endl; 304 std::cout<<"\t\t binpath =" << vobj[vobj_id].binpath <<std::endl; 302 std::cout << "\t\t vobj " << vobj[vobj_id].name << std::endl 303 << "\t\t + index = " << std::dec << vobj_id << std::endl 304 << "\t\t + type = " << vobj[vobj_id].type << std::endl 305 << "\t\t + length = " << vobj[vobj_id].length << std::endl 306 << "\t\t + align = " << vobj[vobj_id].align << std::endl 307 << "\t\t + binpath = " << vobj[vobj_id].binpath << std::endl 308 << "\t\t + init = " << vobj[vobj_id].init << std::endl; 305 309 } 306 310 } … … 309 313 } // end print_mapping_info() 310 314 311 ////////////////////////////////////////// /////////////////////////////////315 ////////////////////////////////////////// 312 316 void MeMo::pseg_map( mapping_pseg_t* pseg) 313 317 { … … 317 321 318 322 319 ////////////////////////////////////////// /////////////////////////////////323 ////////////////////////////////////////// 320 324 void MeMo::vseg_map( mapping_vseg_t* vseg) 321 325 { 322 323 326 mapping_vobj_t* vobj = get_vobj_base( (mapping_header_t*) m_data ); 324 327 PSeg *ps = &(m_psegh.get(vseg->psegid));// get physical segment pointer(PSegHandler::get) … … 354 357 #endif 355 358 356 if(cur_vobj->type == ELF)359 if(cur_vobj->type == VOBJ_TYPE_ELF) 357 360 { 358 361 if(!first) … … 475 478 476 479 477 /////////////////////////////// //////////////////////////////////////480 /////////////////////////////// 478 481 void MeMo::buildMap(void* desc) 479 482 { … … 485 488 486 489 // get the psegs 490 487 491 #ifdef MOVER_DEBUG 488 492 std::cout << "\n******* Storing Pseg information *********\n" << std::endl; 489 493 #endif 494 490 495 for ( size_t pseg_id = 0 ; pseg_id < header->psegs ; pseg_id++ ) 491 496 { … … 494 499 495 500 // map global vsegs 501 496 502 #ifdef MOVER_DEBUG 497 503 std::cout << "\n******* mapping global vsegs *********\n" << std::endl; 498 504 #endif 505 499 506 for ( size_t vseg_id = 0 ; vseg_id < header->globals ; vseg_id++ ) 500 507 { … … 502 509 } 503 510 504 // secondloop on virtual spaces to map private vsegs511 // loop on virtual spaces to map private vsegs 505 512 for (size_t vspace_id = 0 ; vspace_id < header->vspaces ; vspace_id++ ) 506 513 { -
soft/giet_vm/sys/common.c
r160 r165 9 9 /////////////////////////////////////////////////////////////////////////////////// 10 10 11 #include <sys_handler.h> 11 12 #include <common.h> 12 13 #include <drivers.h> 13 14 #include <stdarg.h> 15 16 //////////////////////////////////////////////////////////////////////////// 17 // _get_lock() 18 //////////////////////////////////////////////////////////////////////////// 19 inline void _get_lock( unsigned int* plock ) 20 { 21 register unsigned int delay = (_proctime() & 0xF) << 4; 22 23 asm volatile ( 24 "_lock_llsc: \n" 25 "ll $2, 0(%0) \n" /* $2 <= _ioc_lock current value */ 26 "bnez $2, _lock_delay \n" /* delay if _ioc_lock already taken */ 27 "li $3, 1 \n" /* $3 <= argument for sc */ 28 "sc $3, 0(%0) \n" /* try to set _ioc_lock */ 29 "bnez $3, _lock_ok \n" /* exit if atomic */ 30 "_lock_delay: \n" 31 "move $4, %1 \n" /* $4 <= delay */ 32 "_lock_loop: \n" 33 "addi $4, $4, -1 \n" /* $4 <= $4 - 1 */ 34 "beqz $4, _lock_loop \n" /* test end delay */ 35 "j _lock_llsc \n" /* retry */ 36 "_lock_ok: \n" 37 : 38 :"r"(plock), "r"(delay) 39 :"$2", "$3", "$4"); 40 } 41 42 //////////////////////////////////////////////////////////////////////////// 43 // _release_lock() 44 //////////////////////////////////////////////////////////////////////////// 45 inline void _release_lock( unsigned int* plock ) 46 { 47 *plock = 0; 48 } 14 49 15 50 //////////////////////////////////////////////////////////////////////////// … … 156 191 return ret; 157 192 } 193 158 194 /////////////////////////////////////////////////////////////////////////////////// 159 195 // _it_mask() … … 163 199 { 164 200 asm volatile( 165 "mfc0 $2, $12 \n" 166 "ori $2, $2, 1 \n" 167 "mtc0 $2, $12 \n" 168 ::: "$2" 201 "lui $27, 0xFFFF \n" 202 "ori $27, $27, 0xFFFE \n" 203 "mfc0 $26, $12 \n" 204 "and $26, $26, $27 \n" 205 "mtc0 $26, $12 \n" 206 ::: "$26", "$27" 169 207 ); 170 208 } … … 176 214 { 177 215 asm volatile( 178 "mfc0 $2 , $12\n"179 " addi $2, $2, -1\n"180 "mtc0 $2 , $12\n"181 ::: "$2 "216 "mfc0 $26, $12 \n" 217 "ori $26, $26, 1 \n" 218 "mtc0 $26, $12 \n" 219 ::: "$26" 182 220 ); 183 221 } 222 184 223 ///////////////////////////////////////////////////////////////////////////// 185 224 // access functions to mapping_info data structure -
soft/giet_vm/sys/common.h
r160 r165 45 45 unsigned int _get_cr(); 46 46 47 void _get_lock(unsigned int* lock); 48 void _release_lock(unsigned int* lock); 49 47 50 mapping_cluster_t* _get_cluster_base( mapping_header_t* header ); 48 51 mapping_pseg_t* _get_pseg_base( mapping_header_t* header ); -
soft/giet_vm/sys/ctx_handler.c
r164 r165 25 25 // ctx[3] <- $3 ctx[11]<- $11 ctx[19]<- $19 ctx[27]<- HI ctx[35]<- PTPR 26 26 // ctx[4] <- $4 ctx[12]<- $12 ctx[20]<- $20 ctx[28]<- $28 ctx[36]<- MODE 27 // ctx[5] <- $5 ctx[13]<- $13 ctx[21]<- $21 ctx[29]<- $29 ctx[37]<- reserved27 // ctx[5] <- $5 ctx[13]<- $13 ctx[21]<- $21 ctx[29]<- $29 ctx[37]<- FBDMA 28 28 // ctx[6] <- $6 ctx[14]<- $14 ctx[22]<- $22 ctx[30]<- $30 ctx[38]<- reserved 29 29 // ctx[7] <- $7 ctx[15]<- $15 ctx[23]<- $23 ctx[31]<- $31 ctx[39]<- reserved … … 64 64 unsigned int *next_context; 65 65 66 unsigned int tasks; 67 unsigned int proc_id; 68 69 proc_id = _procid(); 70 tasks = _scheduler[proc_id].tasks; 66 unsigned int pid = _procid(); 67 unsigned int time = _proctime(); 68 unsigned int tasks = _scheduler[pid].tasks; 71 69 72 70 // return if only one task */ … … 74 72 75 73 // compute the task context base address for the current task 76 curr_task_id = _scheduler[p roc_id].current;77 curr_context = &(_scheduler[p roc_id].context[curr_task_id][0]);74 curr_task_id = _scheduler[pid].current; 75 curr_context = &(_scheduler[pid].context[curr_task_id][0]); 78 76 79 77 // select the next task using a round-robin scheduling policy … … 81 79 82 80 // compute the task context base address for the next task 83 next_context = &(_scheduler[proc_id].context[next_task_id][0]); 84 85 // update the scheduler state, and makes the task switch 86 _scheduler[proc_id].current = next_task_id; 87 _task_switch( curr_context, next_context ); 81 next_context = &(_scheduler[pid].context[next_task_id][0]); 88 82 89 83 #if GIET_DEBUG_SWITCH 90 unsigned int time = _proctime();84 _get_lock( &_tty_put_lock ); 91 85 _puts( "\n[GIET] Context switch for processor "); 92 _putw( p roc_id );86 _putw( pid ); 93 87 _puts( " at cycle "); 94 88 _putw( time ); … … 103 97 _putw( next_task_id ); 104 98 _puts("\n"); 99 _release_lock( &_tty_put_lock ); 105 100 #endif 101 102 // update the scheduler state, and makes the task switch 103 _scheduler[pid].current = next_task_id; 104 _task_switch( curr_context, next_context ); 106 105 107 106 } // end _ctx_switch -
soft/giet_vm/sys/ctx_handler.h
r158 r165 11 11 { 12 12 unsigned int context[GIET_NB_TASKS_MAX][64]; // task contexts 13 unsigned int tasks; // actual number of tasks14 unsigned int current; // current task index13 unsigned int tasks; // actual number of tasks 14 unsigned int current; // current task index 15 15 } static_scheduler_t; 16 16 -
soft/giet_vm/sys/drivers.c
r160 r165 16 16 // 17 17 // The following global parameters must be defined in the giet_config.h file: 18 // - NB_PROCS : number of PROCS per cluster (if not zero) 19 // - NB_DMAS : number of DMA channels per cluster (if not zero) 20 // - NB_TIMERS : number of TIMERS per cluster (if not zero) 21 // - NB_TTYS : number of TTY terminals per cluster (if not zero) 18 // - NB_CLUSTERS : number of clusters 19 // - NB_PROCS : number of PROCS per cluster 20 // - NB_TIMERS : number of TIMERS per cluster 21 // - NB_DMAS : number of DMA channels 22 // - NB_TTYS : number of TTY terminals 23 // - NB_TIMERS : number of TIMERS per cluster 24 // - CLUSTER_SPAN : address increment between clusters 22 25 // 23 26 // The following base addresses must be defined in the sys.ld file: … … 58 61 #endif 59 62 63 #if (NB_TTYS < 1) 64 # error: NB_TTYS cannot be smaller than 1! 65 #endif 66 67 #if (NB_TIMERS < NB_PROCS) 68 # error: NB_TIMERS must be larger or equal to NB_PROCS! 69 #endif 70 71 #if (NB_PROCS > 8) 72 # error: NB_PROCS cannot be larger than 8! 73 #endif 74 75 #if (NB_DMAS < 1) 76 # error: NB_DMAS cannot be 0! 77 #endif 78 79 60 80 ///////////////////////////////////////////////////////////////////////////// 61 81 // Global (uncachable) variables … … 71 91 in_unckdata volatile unsigned int _ioc_lock = 0; 72 92 73 in_unckdata volatile unsigned int _tty_lock[NB_TTYS] = { [0 ... NB_TTYS-1] = 0 };74 93 in_unckdata volatile unsigned char _tty_get_buf[NB_TTYS]; 75 94 in_unckdata volatile unsigned char _tty_get_full[NB_TTYS] = { [0 ... NB_TTYS-1] = 0 }; 95 in_unckdata unsigned int _tty_put_lock; 76 96 77 97 ////////////////////////////////////////////////////////////////////////////// 78 98 // VciMultiTimer driver 79 99 ////////////////////////////////////////////////////////////////////////////// 80 // The number of independant timers per cluster is defined by the 81 // configuration parameter NB_TIMERS. 100 // There is one MULTI-TIMER component per cluster. 101 // The number of timers per cluster must be larger or equal to the number 102 // processors (NB_TIMERS >= NB_PROCS), because each processor uses a private 103 // yimer for context switch. 82 104 // The total number of timers is NB_CLUSTERS * NB_TIMERS 83 // The global timer index = cluster_id*NB_TIMER + timer_id105 // The global timer index = cluster_id*NB_TIMERS + timer_id 84 106 ////////////////////////////////////////////////////////////////////////////// 85 107 … … 87 109 // _timer_write() 88 110 // 89 // Write a 32-bit word in a memory mapped register of a timer device. 90 // Returns 0 if success, > 0 if error. 91 ////////////////////////////////////////////////////////////////////////////// 92 unsigned int _timer_write( unsigned int global_timer_index, 111 // Write a 32-bit word in a memory mapped register of a timer device, 112 // identified by the cluster index and the local timer index. 113 // Returns 0 if success, > 0 if error. 114 ////////////////////////////////////////////////////////////////////////////// 115 unsigned int _timer_write( unsigned int cluster_index, 116 unsigned int timer_index, 93 117 unsigned int register_index, 94 118 unsigned int value ) 95 119 { 96 volatile unsigned int *timer_address; 97 98 unsigned int cluster_id = global_timer_index / NB_TIMERS; 99 unsigned int timer_id = global_timer_index % NB_TIMERS; 100 101 /* parameters checking */ 102 if ( register_index >= TIMER_SPAN) return 1; 103 if ( global_timer_index >= NB_CLUSTERS*NB_TIMERS ) return 1; 120 unsigned int* timer_address; 121 122 // parameters checking 123 if ( register_index >= TIMER_SPAN) return 1; 124 if ( cluster_index >= NB_CLUSTERS) return 1; 125 if ( timer_index >= NB_TIMERS ) return 1; 104 126 105 127 timer_address = (unsigned int*)&seg_timer_base + 106 ( cluster_i d* CLUSTER_SPAN ) +107 ( timer_i d* TIMER_SPAN );108 109 timer_address[register_index] = value; / * write word */128 ( cluster_index * CLUSTER_SPAN ) + 129 ( timer_index * TIMER_SPAN ); 130 131 timer_address[register_index] = value; // write word 110 132 111 133 return 0; … … 115 137 // _timer_read() 116 138 // 117 // Read a 32-bit word in a memory mapped register of a timer device. 118 // Returns 0 if success, > 0 if error. 119 ////////////////////////////////////////////////////////////////////////////// 120 unsigned int _timer_read(unsigned int global_timer_index, 139 // Read a 32-bit word in a memory mapped register of a timer device, 140 // identified by the cluster index and the local timer index. 141 // Returns 0 if success, > 0 if error. 142 ////////////////////////////////////////////////////////////////////////////// 143 unsigned int _timer_read(unsigned int cluster_index, 144 unsigned int timer_index, 121 145 unsigned int register_index, 122 146 unsigned int *buffer) 123 147 { 124 volatile unsigned int *timer_address; 125 126 unsigned int cluster_id = global_timer_index / NB_TIMERS; 127 unsigned int timer_id = global_timer_index % NB_TIMERS; 128 129 /* parameters checking */ 130 if ( register_index >= TIMER_SPAN) return 1; 131 if ( global_timer_index >= NB_CLUSTERS*NB_TIMERS ) return 1; 148 unsigned int *timer_address; 149 150 // parameters checking 151 if ( register_index >= TIMER_SPAN) return 1; 152 if ( cluster_index >= NB_CLUSTERS) return 1; 153 if ( timer_index >= NB_TIMERS ) return 1; 132 154 133 155 timer_address = (unsigned int*)&seg_timer_base + 134 ( cluster_i d* CLUSTER_SPAN ) +135 ( timer_i d* TIMER_SPAN );136 137 *buffer = timer_address[register_index]; / * read word */156 ( cluster_index * CLUSTER_SPAN ) + 157 ( timer_index * TIMER_SPAN ); 158 159 *buffer = timer_address[register_index]; // read word 138 160 139 161 return 0; … … 146 168 // The system terminal is TTY[0]. 147 169 // The TTYs are allocated to applications by the GIET in the boot phase. 148 // The nummber of TTYs allocated to each application, and the TTYused by each170 // The nummber of TTYs allocated to each application, and used by each 149 171 // task can be defined in the mapping_info data structure. 150 172 // For each user task, the tty_id is stored in the context of the task (slot 34), … … 152 174 // The TTY address is always computed as : seg_tty_base + tty_id*TTY_SPAN 153 175 /////////////////////////////////////////////////////////////////////////////////// 154 155 ///////////////////////////////////////////////////////////////////////////////////156 // tty_get_lock()157 //158 // This blocking function is intended to be used by the _tty_write() function159 // to provide exclusive access to the TTY. It is not used yet, because it appears160 // that it creates livelock situations...161 ///////////////////////////////////////////////////////////////////////////////////162 static inline void _tty_get_lock( unsigned int tty_id )163 {164 register unsigned int delay = (_proctime() & 0xF) << 4;165 register unsigned int *plock = (unsigned int*)&_tty_lock[tty_id];166 167 asm volatile (168 "_tty_llsc: \n"169 "ll $2, 0(%0) \n" /* $2 <= _tty_lock current value */170 "bnez $2, _tty_delay \n" /* delay if _tty_lock already taken */171 "li $3, 1 \n" /* $3 <= argument for sc */172 "sc $3, 0(%0) \n" /* try to set _tty_lock */173 "bnez $3, _tty_ok \n" /* exit if atomic */174 "_tty_delay: \n"175 "move $4, %1 \n" /* $4 <= delay */176 "_tty_loop: \n"177 "addi $4, $4, -1 \n" /* $4 <= $4 - 1 */178 "beqz $4, _tty_loop \n" /* test end delay */179 "j _tty_llsc \n" /* retry */180 "_tty_ok: \n"181 :182 :"r"(plock), "r"(delay)183 :"$2", "$3", "$4");184 }185 176 186 177 ////////////////////////////////////////////////////////////////////////////// … … 194 185 // The function returns the number of characters that have been written. 195 186 ////////////////////////////////////////////////////////////////////////////// 196 unsigned int _tty_write(const char *buffer, unsigned int length) 187 unsigned int _tty_write( const char *buffer, 188 unsigned int length) 197 189 { 198 190 volatile unsigned int *tty_address; … … 212 204 for (nwritten = 0; nwritten < length; nwritten++) 213 205 { 214 / * check tty's status */206 // check tty's status 215 207 if ((tty_address[TTY_STATUS] & 0x2) == 0x2) 216 208 break; 217 209 else 218 / * write character */210 // write character 219 211 tty_address[TTY_WRITE] = (unsigned int)buffer[nwritten]; 220 212 } … … 226 218 // 227 219 // This non-blocking function uses the TTY_GET_IRQ[tty_id] interrupt and 228 // the associated //kernel buffer, that has been written by the ISR.220 // the associated kernel buffer, that has been written by the ISR. 229 221 // It fetches one single character from the _tty_get_buf[tty_id] kernel 230 222 // buffer, writes this character to the user buffer, and resets the … … 232 224 // Returns 0 if the kernel buffer is empty, 1 if the buffer is full. 233 225 ////////////////////////////////////////////////////////////////////////////// 234 unsigned int _tty_read_irq(char *buffer, unsigned int length) 226 unsigned int _tty_read_irq( char *buffer, 227 unsigned int length) 235 228 { 236 229 unsigned int proc_id; … … 262 255 // register of the TTY controler, and writes this character to the user buffer. 263 256 // It doesn't use the TTY_GET_IRQ interrupt and the associated kernel buffer. 264 // It doesn't take the lock protecting exclusive access...265 257 // Returns 0 if the register is empty, 1 if the register is full. 266 258 //////////////////////////////////////////////////////////////////////////////// 267 unsigned int _tty_read(char *buffer, unsigned int length) 259 unsigned int _tty_read( char *buffer, 260 unsigned int length) 268 261 { 269 262 volatile unsigned int *tty_address; … … 296 289 // _icu_write() 297 290 // 298 // Write a 32-bit word in a memory mapped register of the ICU device. The 299 // base address is deduced by the proc_id. 300 // Returns 0 if success, > 0 if error. 301 //////////////////////////////////////////////////////////////////////////////// 302 unsigned int _icu_write(unsigned int register_index, unsigned int value) 303 { 304 volatile unsigned int *icu_address; 305 unsigned int proc_id; 306 307 /* parameters checking */ 308 if (register_index >= ICU_END) 309 return 1; 310 311 proc_id = _procid(); 312 icu_address = (unsigned int*)&seg_icu_base + (proc_id * ICU_SPAN); 313 icu_address[register_index] = value; /* write word */ 291 // Write a 32-bit word in a memory mapped register of the MULTI_ICU device, 292 // identified by the cluster index, and a processor local index. 293 // Returns 0 if success, > 0 if error. 294 //////////////////////////////////////////////////////////////////////////////// 295 unsigned int _icu_write( unsigned int cluster_index, 296 unsigned int proc_index, 297 unsigned int register_index, 298 unsigned int value ) 299 { 300 unsigned int *icu_address; 301 302 // parameters checking 303 if ( register_index >= ICU_SPAN) return 1; 304 if ( cluster_index >= NB_CLUSTERS) return 1; 305 if ( proc_index >= NB_PROCS ) return 1; 306 307 icu_address = (unsigned int*)&seg_icu_base + 308 ( cluster_index * CLUSTER_SPAN ) + 309 ( proc_index * ICU_SPAN ); 310 311 icu_address[register_index] = value; // write word 314 312 return 0; 315 313 } … … 318 316 // _icu_read() 319 317 // 320 // Read a 32-bit word in a memory mapped register of the ICU device. The 321 // ICU base address is deduced by the proc_id. 322 // Returns 0 if success, > 0 if error. 323 //////////////////////////////////////////////////////////////////////////////// 324 unsigned int _icu_read(unsigned int register_index, unsigned int *buffer) 325 { 326 volatile unsigned int *icu_address; 327 unsigned int proc_id; 328 329 /* parameters checking */ 330 if (register_index >= ICU_END) 331 return 1; 332 333 proc_id = _procid(); 334 icu_address = (unsigned int*)&seg_icu_base + (proc_id * ICU_SPAN); 335 *buffer = icu_address[register_index]; /* read word */ 318 // Read a 32-bit word in a memory mapped register of the MULTI_ICU device, 319 // identified by the cluster index and a processor local index. 320 // Returns 0 if success, > 0 if error. 321 //////////////////////////////////////////////////////////////////////////////// 322 unsigned int _icu_read( unsigned int cluster_index, 323 unsigned int proc_index, 324 unsigned int register_index, 325 unsigned int* buffer ) 326 { 327 unsigned int *icu_address; 328 329 // parameters checking 330 if ( register_index >= ICU_SPAN) return 1; 331 if ( cluster_index >= NB_CLUSTERS) return 1; 332 if ( proc_index >= NB_PROCS ) return 1; 333 334 icu_address = (unsigned int*)&seg_icu_base + 335 ( cluster_index * CLUSTER_SPAN ) + 336 ( proc_index * ICU_SPAN ); 337 338 *buffer = icu_address[register_index]; // read word 336 339 return 0; 337 340 } … … 341 344 //////////////////////////////////////////////////////////////////////////////// 342 345 // The Greater Dommon Divider is a -very- simple hardware coprocessor 343 // performing the computation of aGCD of two 32 bits integers.346 // performing the computation of the GCD of two 32 bits integers. 344 347 // It has no DMA capability. 345 348 //////////////////////////////////////////////////////////////////////////////// … … 351 354 // Returns 0 if success, > 0 if error. 352 355 //////////////////////////////////////////////////////////////////////////////// 353 unsigned int _gcd_write(unsigned int register_index, unsigned int value) 356 unsigned int _gcd_write( unsigned int register_index, 357 unsigned int value) 354 358 { 355 359 volatile unsigned int *gcd_address; 356 360 357 / * parameters checking */361 // parameters checking 358 362 if (register_index >= GCD_END) 359 363 return 1; 360 364 361 365 gcd_address = (unsigned int*)&seg_gcd_base; 362 gcd_address[register_index] = value; /* write word */ 366 367 gcd_address[register_index] = value; // write word 363 368 return 0; 364 369 } … … 370 375 // Returns 0 if success, > 0 if error. 371 376 //////////////////////////////////////////////////////////////////////////////// 372 unsigned int _gcd_read(unsigned int register_index, unsigned int *buffer) 377 unsigned int _gcd_read( unsigned int register_index, 378 unsigned int *buffer) 373 379 { 374 380 volatile unsigned int *gcd_address; 375 381 376 / * parameters checking */382 // parameters checking 377 383 if (register_index >= GCD_END) 378 384 return 1; 379 385 380 386 gcd_address = (unsigned int*)&seg_gcd_base; 381 *buffer = gcd_address[register_index]; /* read word */ 387 388 *buffer = gcd_address[register_index]; // read word 382 389 return 0; 383 390 } … … 386 393 // VciBlockDevice driver 387 394 //////////////////////////////////////////////////////////////////////////////// 388 // The VciBlockDevice is a si mpleexternal storage contrÃŽler.395 // The VciBlockDevice is a single channel external storage contrÃŽler. 389 396 // The three functions below use the three variables _ioc_lock _ioc_done, and 390 // _ioc_status for synchron sation.397 // _ioc_status for synchronisation. 391 398 // As the IOC component can be used by several programs running in parallel, 392 399 // the _ioc_lock variable guaranties exclusive access to the device. The … … 429 436 "move $4, %1 \n" /* $4 <= delay */ 430 437 "_ioc_loop: \n" 438 "beqz $4, _ioc_loop \n" /* test end delay */ 431 439 "addi $4, $4, -1 \n" /* $4 <= $4 - 1 */ 432 " beqz $4, _ioc_loop \n" /* test end delay*/433 " j _ioc_llsc \n" /* retry */440 "j _ioc_llsc \n" /* retry ll */ 441 "nop \n" 434 442 "_ioc_ok: \n" 435 443 : -
soft/giet_vm/sys/drivers.h
r158 r165 6 6 /////////////////////////////////////////////////////////////////////////////////// 7 7 8 #ifndef _ DRIVERS_H_9 #define _ DRIVERS_H_8 #ifndef _GIET_SYS_DRIVERS_H_ 9 #define _GIET_SYS_DRIVERS_H_ 10 10 11 11 /////////////////////////////////////////////////////////////////////////////////// … … 22 22 extern volatile unsigned char _tty_get_buf[]; 23 23 extern volatile unsigned char _tty_get_full[]; 24 extern unsigned int _tty_put_lock; 24 25 25 26 /////////////////////////////////////////////////////////////////////////////////// 26 // Prototypes of the driversfunctions.27 // Prototypes of the external functions. 27 28 /////////////////////////////////////////////////////////////////////////////////// 28 29 29 unsigned int _timer_write(unsigned int global, unsigned int reg, unsigned int value); 30 unsigned int _timer_read(unsigned int global, unsigned int reg, unsigned int *buffer); 30 unsigned int _timer_write( unsigned int cluster_id, 31 unsigned int timer_id, 32 unsigned int register_id, 33 unsigned int value); 31 34 32 unsigned int _tty_write(const char *buffer, unsigned int length); 33 unsigned int _tty_read(char *buffer, unsigned int length); 34 unsigned int _tty_read_irq(char *buffer, unsigned int length); 35 unsigned int _timer_read( unsigned int cluster_id, 36 unsigned int timer_id, 37 unsigned int register_id, 38 unsigned int* buffer); 35 39 36 unsigned int _ioc_write(unsigned int lba, const void *buffer, unsigned int count); 37 unsigned int _ioc_read(unsigned int lba, void *buffer, unsigned int count); 40 unsigned int _icu_write( unsigned int cluster_id, 41 unsigned int proc_id, 42 unsigned int register_id, 43 unsigned int value); 44 45 unsigned int _icu_read( unsigned int cluster_id, 46 unsigned int proc_id, 47 unsigned int register_id, 48 unsigned int* buffer); 49 50 unsigned int _tty_write( const char* buffer, 51 unsigned int length); 52 53 unsigned int _tty_read( char* buffer, 54 unsigned int length); 55 56 unsigned int _tty_read_irq( char* buffer, 57 unsigned int length); 58 59 unsigned int _ioc_write( unsigned int lba, 60 const void* buffer, 61 unsigned int count); 62 63 unsigned int _ioc_read( unsigned int lba, 64 void* buffer, 65 unsigned int count); 66 38 67 unsigned int _ioc_completed(); 39 68 40 unsigned int _ icu_write(unsigned int register_index, unsigned int value);41 unsigned int _icu_read(unsigned int register_index, unsigned int *buffer);69 unsigned int _gcd_write( unsigned int register_index, 70 unsigned int value); 42 71 43 unsigned int _gcd_ write(unsigned int register_index, unsigned int value);44 unsigned int _gcd_read(unsigned int register_index, unsigned int *buffer);72 unsigned int _gcd_read( unsigned int register_index, 73 unsigned int* buffer); 45 74 46 unsigned int _fb_sync_write(unsigned int offset, const void *buffer, unsigned int length); 47 unsigned int _fb_sync_read(unsigned int offset, const void *buffer, unsigned int length); 48 unsigned int _fb_write(unsigned int offset, const void *buffer, unsigned int length); 49 unsigned int _fb_read(unsigned int offset, const void *buffer, unsigned int length); 75 unsigned int _fb_sync_write(unsigned int offset, 76 const void* buffer, 77 unsigned int length); 78 79 unsigned int _fb_sync_read( unsigned int offset, 80 const void* buffer, 81 unsigned int length); 82 83 unsigned int _fb_write( unsigned int offset, 84 const void* buffer, 85 unsigned int length); 86 87 unsigned int _fb_read( unsigned int offset, 88 const void* buffer, 89 unsigned int length); 90 50 91 unsigned int _fb_completed(); 51 92 -
soft/giet_vm/sys/giet.s
r158 r165 26 26 mfc0 $27, $13 /* $27 <= Cause register */ 27 27 la $26, _cause_vector /* $26 <= _cause_vector */ 28 andi $27, $27, 0x3c /* $27 <= XCODE*4 */29 addu $26, $26, $27 /* $26 <= &_cause_vector[XCODE] */28 andi $27, $27, 0x3c /* $27 <= XCODE*4 */ 29 addu $26, $26, $27 /* $26 <= &_cause_vector[XCODE] */ 30 30 lw $26, ($26) /* $26 <= _cause_vector[XCODE] */ 31 31 jr $26 /* Jump indexed by XCODE */ -
soft/giet_vm/sys/irq_handler.c
r160 r165 29 29 // This functions uses an external ICU component (Interrupt Controler Unit) 30 30 // that concentrates up to 32 input interrupts lines. This component 31 // can support up to NB_PROCS _MAXoutput IRQ.31 // can support up to NB_PROCS output IRQ. 32 32 // 33 33 // This component returns the highest priority active interrupt index (smaller … … 38 38 // The interrupt vector (32 ISR addresses array stored at _interrupt_vector 39 39 // address) is initialised with the default ISR address. The actual ISR 40 // addresses are supposed to be written in the interrupt vector array by the41 // boot code.40 // addresses are supposed to be written in the interrupt vector array 41 // during system initialisation. 42 42 /////////////////////////////////////////////////////////////////////////////////// 43 43 void _int_demux(void) 44 44 { 45 int interrupt_index; 46 _isr_func_t isr; 47 48 // interrupt vector initialisation 49 50 51 /* retrieves the highest priority active interrupt index */ 52 if (!_icu_read(ICU_IT_VECTOR, (unsigned int*)&interrupt_index)) 45 int interrupt_index; 46 _isr_func_t isr; 47 unsigned int pid = _procid(); 48 49 // retrieves the highest priority active interrupt index 50 if (!_icu_read( pid / NB_PROCS, 51 pid % NB_PROCS, 52 ICU_IT_VECTOR, 53 (unsigned int*)&interrupt_index ) ) 53 54 { 54 /* no interrupt is active */ 55 if (interrupt_index == -1) 55 if (interrupt_index == -1) // no interrupt is active 56 56 return; 57 57 58 /* call the ISR corresponding to this index */59 58 isr = _interrupt_vector[interrupt_index]; 60 59 isr(); 61 60 } 61 else 62 { 63 _puts("\n[GIET ERROR] In _demux function : wrong arguments in _icu_read()\n"); 64 _exit(); 65 } 62 66 } 63 67 /////////////////////////////////////////////////////////////////////////////////// … … 70 74 _puts("\n\n!!! Default ISR !!!\n"); 71 75 } 76 72 77 /////////////////////////////////////////////////////////////////////////////////// 73 78 // _isr_dma() 74 // This ISR acknowledges the interrupt from the dma controller, depending on75 // the proc_id. It reset the global variable _dma_busy[i] for software76 // signaling, after copying the DMAstatus into the _dma_status[i] variable.77 /////////////////////////////////////////////////////////////////////////////////// 78 void _isr_dma ()79 // This ISR handles up to 8 IRQs generated by 8 independant channels of the 80 // multi_dma component. It acknowledges the interrupt and reset the synchronisation 81 // variable _dma_busy[i], after copying the status into the _dma_status[i] variable. 82 /////////////////////////////////////////////////////////////////////////////////// 83 void _isr_dma_indexed( unsigned int dma_id ) 79 84 { 80 85 volatile unsigned int* dma_address; 81 unsigned int proc_id; 82 83 proc_id = _procid(); 84 dma_address = (unsigned int*)&seg_dma_base + (proc_id * DMA_SPAN); 85 86 _dma_status[proc_id] = dma_address[DMA_LEN]; /* save status */ 87 _dma_busy[proc_id] = 0; /* release DMA */ 88 dma_address[DMA_RESET] = 0; /* reset IRQ */ 89 } 86 87 dma_address = (unsigned int*)&seg_dma_base + (dma_id * DMA_SPAN); 88 89 dma_address[DMA_RESET] = 0; /* reset IRQ */ 90 91 _dma_status[dma_id] = dma_address[DMA_LEN]; /* save status */ 92 _dma_busy[dma_id] = 0; /* release DMA */ 93 } 94 95 void _isr_dma_0() { _isr_dma_indexed(0); } 96 void _isr_dma_1() { _isr_dma_indexed(1); } 97 void _isr_dma_2() { _isr_dma_indexed(2); } 98 void _isr_dma_3() { _isr_dma_indexed(3); } 99 void _isr_dma_4() { _isr_dma_indexed(4); } 100 void _isr_dma_5() { _isr_dma_indexed(5); } 101 void _isr_dma_6() { _isr_dma_indexed(6); } 102 void _isr_dma_7() { _isr_dma_indexed(7); } 103 90 104 /////////////////////////////////////////////////////////////////////////////////// 91 105 // _isr_ioc() … … 103 117 _ioc_done = 1; /* signals completion */ 104 118 } 119 105 120 /////////////////////////////////////////////////////////////////////////////////// 106 121 // _isr_timer_* (* = 0,1,2,3,4,5,6,7) -
soft/giet_vm/sys/irq_handler.h
r158 r165 18 18 void _isr_default(); 19 19 20 void _isr_dma(); 20 void _isr_dma_0(); 21 void _isr_dma_1(); 22 void _isr_dma_2(); 23 void _isr_dma_3(); 24 void _isr_dma_4(); 25 void _isr_dma_5(); 26 void _isr_dma_6(); 27 void _isr_dma_7(); 21 28 22 29 void _isr_ioc(); 23 30 24 void _isr_timer0(); 25 void _isr_timer1(); 26 void _isr_timer2(); 27 void _isr_timer3(); 31 void _isr_timer_0(); 32 void _isr_timer_1(); 33 void _isr_timer_2(); 34 void _isr_timer_3(); 35 void _isr_timer_4(); 36 void _isr_timer_5(); 37 void _isr_timer_6(); 38 void _isr_timer_7(); 28 39 29 40 void _isr_tty_get(); -
soft/giet_vm/sys/mips32_registers.h
r158 r165 73 73 #define CP2_PARAMS $15 74 74 #define CP2_RELEASE $16 75 #define CP2_DATA_LO 76 #define CP2_DATA_HI 75 #define CP2_DATA_LO $17 76 #define CP2_DATA_HI $18 77 77 #define CP2_ICACHE_INVAL_PA $19 78 78 #define CP2_DCACHE_INVAL_PA $20 … … 87 87 #define CTX_PTPR_ID 35 88 88 #define CTX_MODE_ID 36 89 #define CTX_FBDMA_ID 37 90 #define CTX_TASK_ID 63 89 91 90 92 -
soft/giet_vm/sys/sys.ld
r160 r165 10 10 seg_kernel_uncdata_base = 0x80020000; /* system uncacheable data */ 11 11 seg_kernel_init_base = 0x80030000; /* system page table */ 12 seg_mapping_base = 0xBFC0C000; /* boot mapping_info */ 12 13 13 14 … … 22 23 seg_fb_base = 0x96000000; /* FrameBuffer device */ 23 24 seg_icu_base = 0x9F000000; /* ICU device */ 24 25 /*****************************************/26 seg_mapping_base = 0xBFC0C000; /* boot mapping_info */27 25 28 26 /* … … 65 63 seg_kernel_init : 66 64 { 67 *(.kinitentry)68 65 *(.kinit) 69 66 } -
soft/giet_vm/sys/sys_handler.c
r163 r165 83 83 _puts(" on processor "); 84 84 _putw( proc_id ); 85 _puts("\n\n"); 85 86 86 87 /* infinite loop */ … … 96 97 unsigned int ret; 97 98 asm volatile("mfc0 %0, $15, 1" : "=r"(ret)); 98 return (ret & 0x 3FF);99 return (ret & 0xFFF); 99 100 } 100 101 ////////////////////////////////////////////////////////////////////////////// … … 132 133 ///////////////////////////////////////////////////////////////////////////// 133 134 // _vobj_get_vbase() 135 // This function writes in vobj_buffer the virtual base address of a vobj 136 // identified by the (vspace_name / vobj_name ) couple. 137 // The vobj_type argument is redundant, and for checking purpose. 134 138 // returns 0: success, else: failed. 135 // return the virtual base address of a vobj identified by the (vspace_name / channel_name ) couple.136 // The "type" argument is here for checking purpose.137 139 ///////////////////////////////////////////////////////////////////////////// 138 unsigned int _vobj_get_vbase( char* vspace_name, char* vobj_name, 139 unsigned vobj_type, unsigned int* vobj_buffer) 140 unsigned int _vobj_get_vbase( char* vspace_name, 141 char* vobj_name, 142 unsigned int vobj_type, 143 unsigned int* vobj_vaddr ) 140 144 { 141 145 mapping_header_t* header = (mapping_header_t*)&seg_mapping_base; … … 153 157 { 154 158 // scan vobjs 155 for(vobj_id= vspace[vspace_id].vobj_offset; vobj_id < (vspace[vspace_id].vobj_offset + vspace[vspace_id].vobjs); vobj_id++) 159 for( vobj_id = vspace[vspace_id].vobj_offset; 160 vobj_id < (vspace[vspace_id].vobj_offset + vspace[vspace_id].vobjs); 161 vobj_id++) 156 162 { 157 163 … … 159 165 { 160 166 if(vobj[vobj_id].type != vobj_type) 161 return -1; //wrong type167 return -1; //wrong type 162 168 163 *vobj_ buffer = (unsigned int)vobj[vobj_id].vaddr;169 *vobj_vaddr = (unsigned int)vobj[vobj_id].vaddr; 164 170 return 0; 165 171 } … … 167 173 } 168 174 } 169 return -2; //not found175 return -2; //not found 170 176 } 171 177 -
soft/giet_vm/xml/mapping_info.h
r160 r165 57 57 enum 58 58 { 59 ELF = 0, //loadable code object60 PTAB, //page table61 PERI, //hardware component62 MWMR, //MWMR channel63 LOCK, //Lock64 BUFFER, //Any "no intialiasation needed" objects (stacks...)65 BARRIER //Barrier59 VOBJ_TYPE_ELF = 0, // loadable code object 60 VOBJ_TYPE_PTAB = 1, // page table 61 VOBJ_TYPE_PERI = 2, // hardware component 62 VOBJ_TYPE_MWMR = 3, // MWMR channel 63 VOBJ_TYPE_LOCK = 4, // Lock 64 VOBJ_TYPE_BUFFER = 5, // Any "no intialiasation needed" objects (stacks...) 65 VOBJ_TYPE_BARRIER = 6, // Barrier 66 66 }; 67 67 … … 74 74 unsigned int psegs; // number of psegs 75 75 unsigned int ttys; // number of TTY terminals 76 unsigned int fbs; // number of Frame Buffer DMA channels 76 77 unsigned int globals; // number of vsegs mapped in all vspaces 77 78 unsigned int vspaces; // number of virtual spaces 78 79 unsigned int vsegs; // total number of virtual segments (for all vspaces) 79 unsigned int vobjs; // total number of virtual memoryobjects (for all vspaces)80 unsigned int vobjs; // total number of virtual objects (for all vspaces) 80 81 unsigned int tasks; // total number of tasks (for all vspaces) 81 82 char name[32]; // mapping name … … 86 87 { 87 88 unsigned int procs; // number of processors in cluster 88 unsigned int timers; // number of timers in cluster89 unsigned int dmas; // number of DMA channels in cluster90 89 } mapping_cluster_t; 91 90 … … 103 102 { 104 103 char name[32]; // virtual space name 105 unsigned int funcs_offset; // offset of the vobj containing the function entry table (relative to vobj_offset) 106 unsigned int vsegs; // number of private virtual segments 107 unsigned int vobjs; // number of vobjs channels 108 unsigned int tasks; // number of tasks 109 unsigned int ttys; // number of required TTY terminals 104 unsigned int start_offset; // offset of the vobj containing the start vector 105 unsigned int vsegs; // number of vsegs in vspace 106 unsigned int vobjs; // number of vobjs in vspace 107 unsigned int tasks; // number of tasks in vspace 110 108 unsigned int vseg_offset; // index of first vseg in vspace 111 109 unsigned int vobj_offset; // index of first vobjs in vspace … … 121 119 unsigned int length; // size (bytes) 122 120 unsigned int psegid; // physical segment index 123 unsigned char mode; // C-X-W-U flags 124 unsigned char ident; // identity mapping if non zero 125 unsigned int vobjs; // number of vobjs channels 126 unsigned int vobj_offset; // index of first vobjs in vspace 127 unsigned char reserved; // unused 121 unsigned int mode; // C-X-W-U flags 122 unsigned int ident; // identity mapping if non zero 123 unsigned int vobjs; // number of vobjs in vseg 124 unsigned int vobj_offset; // index of first vobjs in vseg 128 125 } mapping_vseg_t; 129 126 … … 135 132 unsigned int proclocid; // processor local index (inside cluster) 136 133 unsigned int vobjlocid; // stack vobj index in vspace 137 unsigned int startid; // index in start_vector (in seg_data) 138 unsigned int ttylocid; // tty index (inside the vspace) 134 unsigned int startid; // index in start_vector 135 unsigned int use_tty; // TTY terminal required 136 unsigned int use_fb; // DMA channel to frame buffer required 139 137 } mapping_task_t; 140 138 … … 143 141 { 144 142 char name[32]; // vobj name (unique in a vspace) 145 char binpath[64]; // path for the binary code ("*. bin")143 char binpath[64]; // path for the binary code ("*.elf") 146 144 unsigned int type; // type of vobj 147 145 unsigned int length; // size (bytes) 148 146 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) 147 unsigned int vaddr; // virtual base addresse of the vobj 148 unsigned int paddr; // physical base addresse of the vobj 149 unsigned int init; // init value (number of participants for a barrier) 151 150 } mapping_vobj_t; 152 151 -
soft/giet_vm/xml/xml_driver.c
r160 r165 111 111 fprintf( fpout, " psegs = \"%d\"\n", header->psegs); 112 112 fprintf( fpout, " ttys = \"%d\"\n", header->ttys); 113 fprintf( fpout, " fbs = \"%d\"\n", header->fbs); 113 114 fprintf( fpout, " vspaces = \"%d\"\n", header->vspaces); 114 fprintf( fpout, " globals = \"%d\" />\n\n", header->globals);115 fprintf( fpout, " globals = \"%d\" >\n\n", header->globals); 115 116 116 117 ///////////////////// clusters /////////////////////////////////////////////// … … 119 120 for ( cluster_id = 0 ; cluster_id < header->clusters ; cluster_id++ ) 120 121 { 121 fprintf( fpout, " <cluster procs = \"%d\"\n", cluster[cluster_id].procs); 122 fprintf( fpout, " timers = \"%d\"\n", cluster[cluster_id].timers); 123 fprintf( fpout, " dmas = \"%d\" />\n\n", cluster[cluster_id].dmas); 122 fprintf( fpout, " <cluster index = \"%d\"\n", cluster_id); 123 fprintf( fpout, " procs = \"%d\" />\n\n", cluster[cluster_id].procs); 124 124 } 125 125 fprintf( fpout, " </clusterset>\n" ); … … 148 148 fprintf( fpout, " mode = \"%s\"\n", mode_str[vseg[vseg_id].mode]); 149 149 fprintf( fpout, " psegname = \"%s\"\n", pseg[pseg_id].name); 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"); 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); 153 vobj_id++ ) 154 { 155 fprintf( fpout, " <vobj name = \"%s\"\n", vobj[vobj_id].name); 156 fprintf( fpout, " type = \"%s\"\n", vobj_type[vobj[vobj_id].type]); 157 fprintf( fpout, " length = \"0x%x\"\n", vobj[vobj_id].length); 158 fprintf( fpout, " align = \"%d\"\n", vobj[vobj_id].align); 159 fprintf( fpout, " init = \"%d\" \n", vobj[vobj_id].init); 160 fprintf( fpout, " binpath = \"%s\" />\n", vobj[vobj_id].binpath); 161 } 162 fprintf( fpout, " </vseg>\n\n"); 165 163 } 166 164 fprintf( fpout, " </globalset>\n" ); … … 171 169 for ( vspace_id = 0 ; vspace_id < header->vspaces ; vspace_id++ ) 172 170 { 173 unsigned int func_id = vspace[vspace_id].vobj_offset + vspace[vspace_id].funcs_offset; 174 fprintf( fpout, " <vspace name = \"%s\"\n", vspace[vspace_id].name); 175 fprintf( fpout, " funcs = \"%s\"\n", vobj[func_id].name); 176 fprintf( fpout, " ttys = \"%d\" >\n\n", vspace[vspace_id].ttys); 171 unsigned int func_id = vspace[vspace_id].vobj_offset + vspace[vspace_id].start_offset; 172 fprintf( fpout, " <vspace name = \"%s\"\n", vspace[vspace_id].name); 173 fprintf( fpout, " startname = \"%s\" >\n\n", vobj[func_id].name); 177 174 178 175 for ( vseg_id = vspace[vspace_id].vseg_offset ; … … 185 182 fprintf( fpout, " mode = \"%s\"\n", mode_str[vseg[vseg_id].mode]); 186 183 fprintf( fpout, " psegname = \"%s\"\n", pseg[pseg_id].name); 187 fprintf( fpout, " ident = \"%d\" >\n", vseg[vseg_id].ident);184 fprintf( fpout, " ident = \"%d\" >\n", vseg[vseg_id].ident); 188 185 189 186 for ( vobj_id = vseg[vseg_id].vobj_offset ; 190 vobj_id < (vseg[vseg_id].vobj_offset + vseg[vseg_id].vobjs) ; vobj_id++ ) 187 vobj_id < (vseg[vseg_id].vobj_offset + vseg[vseg_id].vobjs) ; 188 vobj_id++ ) 191 189 { 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"); 190 fprintf( fpout, " <vobj name = \"%s\"\n", vobj[vobj_id].name); 191 fprintf( fpout, " type = \"%s\" \n", vobj_type[vobj[vobj_id].type]); 192 fprintf( fpout, " length = \"0x%x\" \n", vobj[vobj_id].length); 193 fprintf( fpout, " align = \"%d\" \n", vobj[vobj_id].align); 194 fprintf( fpout, " init = \"%d\" \n", vobj[vobj_id].init); 195 fprintf( fpout, " binpath = \"%s\" />\n", vobj[vobj_id].binpath); 201 196 } 202 fprintf( fpout, " \t\t</vseg>\n\n");197 fprintf( fpout, " </vseg>\n\n"); 203 198 } 204 199 for ( task_id = vspace[vspace_id].task_offset ; 205 task_id < (vspace[vspace_id].task_offset + vspace[vspace_id].tasks) ; task_id++ ) 200 task_id < (vspace[vspace_id].task_offset + vspace[vspace_id].tasks) ; 201 task_id++ ) 206 202 { 207 203 unsigned int vobj_id = task[task_id].vobjlocid + vspace[vspace_id].vobj_offset; … … 212 208 fprintf( fpout, " stackname = \"%s\"\n", vobj[vobj_id].name); 213 209 fprintf( fpout, " startid = \"%d\"\n", task[task_id].startid); 214 fprintf( fpout, " ttylocid = \"%d\" />\n\n", task[task_id].ttylocid); 210 fprintf( fpout, " usetty = \"%d\"\n", task[task_id].use_tty); 211 fprintf( fpout, " usefb = \"%d\" />\n\n", task[task_id].use_fb); 215 212 } 216 fprintf( fpout, " </vspace>\n ");213 fprintf( fpout, " </vspace>\n\n"); 217 214 } 218 215 fprintf( fpout, " </vspaceset>\n" ); -
soft/giet_vm/xml/xml_parser.c
r162 r165 52 52 unsigned int vobj_index = 0; 53 53 unsigned int vobj_loc_index = 0; 54 unsigned int vobj_loc_vspace_index = 0; 54 unsigned int vobj_count = 0; 55 56 unsigned int tty_index = 1; 57 unsigned int fb_index = 0; 55 58 56 char one_elf_found = 0;//bool: wether a first vobj of type elf was found57 58 59 ////////////////////////////////////////////////// 59 60 unsigned int getIntValue( xmlTextReaderPtr reader, … … 144 145 unsigned int vobj_id; 145 146 unsigned int vobj_min = vspace[vspace_id]->vobj_offset; 146 unsigned int vobj_max = vobj_min + vobj_loc_ vspace_index;147 unsigned int vobj_max = vobj_min + vobj_loc_index; 147 148 148 149 for ( vobj_id = vobj_min ; vobj_id < vobj_max ; vobj_id++ ) … … 199 200 printf(" clusterid = %x\n", value); 200 201 #endif 202 if ( value >= header->clusters ) 203 { 204 printf("[XML ERROR] <clusterid> too large for task (%d,%d)\n", 205 vspace_index, task_loc_index); 206 exit(1); 207 } 201 208 task[task_index]->clusterid = value; 202 209 } … … 215 222 printf(" proclocid = %x\n", value); 216 223 #endif 224 if ( value >= cluster[task[task_index]->clusterid]->procs ) 225 { 226 printf("[XML ERROR] <proclocid> too large for task (%d,%d)\n", 227 vspace_index, task_loc_index); 228 exit(1); 229 } 217 230 task[task_index]->proclocid = value; 218 231 } … … 233 246 #if XML_PARSER_DEBUG 234 247 printf(" stackname = %s\n", str); 235 printf(" vsegid= %d\n", index);248 printf(" stackid = %d\n", index); 236 249 #endif 237 250 task[task_index]->vobjlocid = index; … … 239 252 else 240 253 { 241 printf("[XML ERROR] illegal or missing < psegname> for vseg %d\n",242 vseg_loc_index);254 printf("[XML ERROR] illegal or missing <stackname> for task (%d,%d)\n", 255 vspace_index, task_loc_index); 243 256 exit(1); 244 257 } … … 246 259 else 247 260 { 248 printf("[XML ERROR] illegal or missing < vsegname> for task (%d,%d)\n",261 printf("[XML ERROR] illegal or missing <stackname> for task (%d,%d)\n", 249 262 vspace_index, task_loc_index); 250 263 exit(1); … … 267 280 } 268 281 269 /////////// get ttylocid attribute270 value = getIntValue(reader," ttylocid", &ok);271 if ( ok ) 272 { 273 #if XML_PARSER_DEBUG 274 printf(" ttylocid= %x\n", value);275 #endif 276 if ( value >= vspace[vspace_index]->ttys)277 { 278 printf("[XML ERROR] The tty locid valueis too large for task (%d,%d)\n",282 /////////// get use_tty attribute (optionnal : 0 if missing) 283 value = getIntValue(reader,"usetty", &ok); 284 if ( ok ) 285 { 286 #if XML_PARSER_DEBUG 287 printf(" usetty = %x\n", value); 288 #endif 289 if ( (value != 0) && (tty_index >= header->ttys) ) 290 { 291 printf("[XML ERROR] The tty index is too large for task (%d,%d)\n", 279 292 vspace_index, task_loc_index); 280 293 exit(1); 281 294 } 282 task[task_index]->ttylocid = value; 295 task[task_index]->use_tty = value; 296 if (value != 0) tty_index++; 283 297 } 284 298 else 285 299 { 286 printf("[XML ERROR] illegal or missing <ttylocid> attribute for task (%d,%d)\n", 300 task[task_index]->use_tty = 0; 301 } 302 303 /////////// get use_fb attribute (optionnal : 0 if missing) 304 value = getIntValue(reader,"usefb", &ok); 305 if ( ok ) 306 { 307 #if XML_PARSER_DEBUG 308 printf(" usefb = %x\n", value); 309 #endif 310 if ( (value != 0) && (fb_index >= header->fbs) ) 311 { 312 printf("[XML ERROR] The fb channel index is too large for task (%d,%d)\n", 287 313 vspace_index, task_loc_index); 288 exit(1); 314 exit(1); 315 } 316 task[task_index]->use_fb = value; 317 if (value != 0) fb_index++; 318 } 319 else 320 { 321 task[task_index]->use_fb = 0; 289 322 } 290 323 … … 293 326 } // end taskNode() 294 327 328 ////////////////////////////////////////// 295 329 void vobjNode ( xmlTextReaderPtr reader ) 296 330 { … … 307 341 } 308 342 309 if(one_elf_found != 0) 310 { 311 printf("[XML ERROR] a vobj of the type ELF must be defined alone in a vseg (%d,%d)\n", 312 vspace_index, vobj_loc_vspace_index); 313 exit(1); 314 315 } 316 317 #if XML_PARSER_DEBUG 318 printf(" vobj %d\n", vobj_loc_index); 343 #if XML_PARSER_DEBUG 344 printf(" vobj %d\n", vobj_loc_index); 319 345 #endif 320 346 … … 326 352 { 327 353 #if XML_PARSER_DEBUG 328 printf(" name = %s\n", str);354 printf(" name = %s\n", str); 329 355 #endif 330 356 strncpy( vobj[vobj_index]->name, str, 31); … … 337 363 } 338 364 339 340 // get type attribute 365 //////// get type attribute 341 366 str = getStringValue(reader, "type", &ok); 342 367 #if XML_PARSER_DEBUG 343 printf(" type = %s\n", str); 344 #endif 345 if (ok && (strcmp(str, "ELF") == 0)){ 346 vobj[vobj_index]->type = ELF; 347 one_elf_found = 1; 348 if(vobj_loc_index != 0) //check that this vobj is the first 349 { 350 printf("[XML ERROR] a vobj of the type ELF must be defined alone in a vobj (%d,%d)\n", 351 vspace_index, vobj_loc_vspace_index); 352 exit(1); 353 354 } 355 } 356 else if (ok && (strcmp(str, "PTAB") == 0)) vobj[vobj_index]->type = PTAB; 357 else if (ok && (strcmp(str, "PERI") == 0)) vobj[vobj_index]->type = PERI; 358 else if (ok && (strcmp(str, "MWMR") == 0)) vobj[vobj_index]->type = MWMR; 359 else if (ok && (strcmp(str, "LOCK") == 0)) vobj[vobj_index]->type = LOCK; 360 else if (ok && (strcmp(str, "BUFFER") == 0)) vobj[vobj_index]->type = BUFFER; 361 else if (ok && (strcmp(str, "BARRIER") == 0)) vobj[vobj_index]->type = BARRIER; 368 printf(" type = %s\n", str); 369 #endif 370 if (ok && (strcmp(str, "ELF") == 0)) 371 { 372 vobj[vobj_index]->type = VOBJ_TYPE_ELF; 373 374 //check that this vobj is the first in vseg 375 if(vobj_count != 0) 376 { 377 printf("[XML ERROR] an ELF vobj must be alone in a vseg (%d,%d)\n", 378 vspace_index, vobj_loc_index); 379 exit(1); 380 } 381 } 382 else if (ok && (strcmp(str, "PTAB") == 0)) vobj[vobj_index]->type = VOBJ_TYPE_PTAB; 383 else if (ok && (strcmp(str, "PERI") == 0)) vobj[vobj_index]->type = VOBJ_TYPE_PERI; 384 else if (ok && (strcmp(str, "MWMR") == 0)) vobj[vobj_index]->type = VOBJ_TYPE_MWMR; 385 else if (ok && (strcmp(str, "LOCK") == 0)) vobj[vobj_index]->type = VOBJ_TYPE_LOCK; 386 else if (ok && (strcmp(str, "BUFFER") == 0)) vobj[vobj_index]->type = VOBJ_TYPE_BUFFER; 387 else if (ok && (strcmp(str, "BARRIER") == 0)) vobj[vobj_index]->type = VOBJ_TYPE_BARRIER; 362 388 else 363 389 { 364 390 printf("[XML ERROR] illegal or missing <type> attribute for vobj (%d,%d)\n", 365 vspace_index, vobj_loc_vspace_index); 366 exit(1); 367 } 368 369 370 ////////// get length attribute (0 if missing) 391 vspace_index, vobj_loc_index); 392 exit(1); 393 } 394 395 ////////// get length attribute 371 396 value = getIntValue(reader,"length", &ok); 372 397 if ( ok ) 373 398 { 374 399 #if XML_PARSER_DEBUG 375 printf(" length = %d\n", value);400 printf(" length = %d\n", value); 376 401 #endif 377 402 vobj[vobj_index]->length = value; … … 379 404 else 380 405 { 381 vobj[vobj_index]->length = 0; 382 } 383 384 ////////// get align attribute (0 if missing) 406 printf("[XML ERROR] illegal or missing <length> attribute for vobj (%d,%d)\n", 407 vspace_index, vobj_loc_index); 408 exit(1); 409 } 410 411 ////////// get align attribute (optional : 0 if missing) 385 412 value = getIntValue(reader,"align", &ok); 386 413 if ( ok ) 387 414 { 388 415 #if XML_PARSER_DEBUG 389 printf(" align = %d\n", value);416 printf(" align = %d\n", value); 390 417 #endif 391 418 vobj[vobj_index]->align = value; … … 396 423 } 397 424 398 ////////// get binpath attribute ( '\0' if missing)425 ////////// get binpath attribute (optional : '\0' if missing) 399 426 str = getStringValue(reader, "binpath", &ok); 400 427 if ( ok ) 401 428 { 402 429 #if XML_PARSER_DEBUG 403 printf(" binpath = %s\n", str);430 printf(" binpath = %s\n", str); 404 431 #endif 405 432 strncpy(vobj[vobj_index]->binpath, str, 63); … … 410 437 } 411 438 439 ////////// get init attribute (optional : 0 if missing) 440 value = getIntValue(reader,"init", &ok); 441 if ( ok ) 442 { 443 #if XML_PARSER_DEBUG 444 printf(" init = %d\n", value); 445 #endif 446 vobj[vobj_index]->init = value; 447 } 448 else 449 { 450 vobj[vobj_index]->init = 0; 451 } 452 412 453 vobj_index++; 454 vobj_count++; 413 455 vobj_loc_index++; 414 vobj_loc_vspace_index++; 415 } 416 417 418 /////////////////////////////////////////////////////////////// 456 } // end vobjNode() 457 458 ////////////////////////////////////////// 419 459 void vsegNode ( xmlTextReaderPtr reader ) 420 460 { … … 422 462 unsigned int value; 423 463 char* str; 424 vobj_loc_index = 0; 425 one_elf_found= 0;464 465 vobj_count = 0; 426 466 427 467 if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return; … … 442 482 vseg[vseg_index]->vobj_offset = vobj_index; 443 483 #if XML_PARSER_DEBUG 444 printf(" -vobj_offset = %d\n", vobj_index);484 printf(" vobj_offset = %d\n", vobj_index); 445 485 #endif 446 486 … … 477 517 } 478 518 479 480 ////////// get ident attribute (0 if missing) 519 ////////// get ident attribute (optional : 0 if missing) 481 520 value = getIntValue(reader,"ident", &ok); 482 521 if ( ok ) … … 492 531 } 493 532 494 495 533 ////////// get psegname attribute 496 534 str = getStringValue(reader,"psegname", &ok); … … 520 558 } 521 559 522 // get mode attribute560 //////// get mode attribute 523 561 str = getStringValue(reader,"mode", &ok); 524 562 #if XML_PARSER_DEBUG … … 548 586 } 549 587 550 551 588 ////////// set the length attribute to 0 552 //the final value will be set by the VLoader553 589 vseg[vseg_index]->length = value; 554 590 … … 564 600 { 565 601 // checking source file consistency? 566 vseg[vseg_index]->vobjs = vobj_ loc_index;602 vseg[vseg_index]->vobjs = vobj_count; 567 603 vseg_index++; 568 604 vseg_loc_index++; … … 576 612 status = xmlTextReaderRead ( reader ); 577 613 } 578 579 580 614 } // end vsegNode() 581 615 … … 585 619 char* str; 586 620 unsigned int ok; 587 unsigned int value; 588 vobj_loc_ vspace_index = 0;621 622 vobj_loc_index = 0; 589 623 vseg_loc_index = 0; 590 624 task_loc_index = 0; … … 601 635 602 636 #if XML_PARSER_DEBUG 603 printf(" vspace %d\n", vspace_index);637 printf("\n vspace %d\n", vspace_index); 604 638 #endif 605 639 606 640 vspace[vspace_index] = (mapping_vspace_t*)malloc(sizeof(mapping_vspace_t)); 607 641 608 ////////// set vseg_offsetand task_offset attributes 642 ////////// get name attribute 643 str = getStringValue(reader, "name", &ok); 644 if ( ok ) 645 { 646 #if XML_PARSER_DEBUG 647 printf(" name = %s\n", str); 648 #endif 649 strncpy(vspace[vspace_index]->name, str, 31); 650 } 651 else 652 { 653 printf("[XML ERROR] illegal or missing <name> attribute for vspace %d\n", 654 vspace_index); 655 exit(1); 656 } 657 658 ////////// set vseg_offset and task_offset attributes 609 659 vspace[vspace_index]->vseg_offset = vseg_index; 610 660 vspace[vspace_index]->vobj_offset = vobj_index; … … 612 662 613 663 #if XML_PARSER_DEBUG 614 printf("- vseg_offset = %d\n", vseg_index); 615 printf("- vobj_offset = %d\n", vobj_index); 616 printf("- task_offset = %d\n", task_index); 617 #endif 618 619 ////////// get name attribute 620 str = getStringValue(reader, "name", &ok); 621 if ( ok ) 622 { 623 #if XML_PARSER_DEBUG 624 printf(" name = %s\n", str); 625 #endif 626 strncpy(vspace[vspace_index]->name, str, 31); 627 } 628 else 629 { 630 printf("[XML ERROR] illegal or missing <name> attribute for vspace %d", 664 printf(" vseg_offset = %d\n", vseg_index); 665 printf(" vobj_offset = %d\n", vobj_index); 666 printf(" task_offset = %d\n", task_index); 667 #endif 668 669 ////////// get startname attribute 670 str = getStringValue(reader, "startname", &ok); 671 if ( ok ) 672 { 673 //used after parsing the vobjs 674 } 675 else 676 { 677 printf("[XML ERROR] illegal or missing <startname> attribute for vspace %d\n", 631 678 vspace_index); 632 exit(1);633 }634 635 ////////// get funcs_entry attribute636 str = getStringValue(reader, "funcs", &ok);637 if ( ok )638 {639 #if XML_PARSER_DEBUG640 printf(" name = %s\n", str);641 #endif642 //used after parsing all the vobjs643 }644 else645 {646 printf("[XML ERROR] illegal or missing <name> attribute for vspace %d",647 vspace_index);648 exit(1);649 }650 651 // get ttys attribute652 value = getIntValue(reader,"ttys", &ok);653 #if XML_PARSER_DEBUG654 printf(" ttys = %d\n", value);655 #endif656 if ( ok )657 {658 vspace[vspace_index]->ttys = value;659 }660 else661 {662 printf("[XML ERROR] illegal or missing <ttys> attribute for vspace %d",663 vspace_index);664 679 exit(1); 665 680 } … … 675 690 else if ( strcmp(tag,"vspace") == 0 ) 676 691 { 677 vspace[vspace_index]->vobjs = vobj_loc_ vspace_index;692 vspace[vspace_index]->vobjs = vobj_loc_index; 678 693 vspace[vspace_index]->tasks = task_loc_index ; 679 694 vspace[vspace_index]->vsegs = vseg_loc_index ; 695 696 // get index of the vobj containing the start vector 680 697 int index = getVobjLocId( vspace_index, str ); 681 698 if(index == -1) 682 699 { 683 printf(" Error funcs entry vobjnot found %s\n",str);700 printf("[XML ERROR] vobj containing the start vector not found %s\n",str); 684 701 exit(-1); 685 702 } 686 vspace[vspace_index]->funcs_offset = index; 703 else 704 { 705 vspace[vspace_index]->start_offset = index; 706 #if XML_PARSER_DEBUG 707 printf(" startname = %s\n", str); 708 printf(" startid = %d\n", index); 709 #endif 710 } 711 712 // checking startid values for all tasks in vspace 713 int task_id; 714 int task_min = vspace[vspace_index]->task_offset; 715 int task_max = task_min + vspace[vspace_index]->tasks; 716 for ( task_id = task_min ; task_id < task_max ; task_id++ ) 717 { 718 if ( task[task_id]->startid >= vspace[vspace_index]->tasks ) 719 { 720 printf("[XML ERROR] <startid> too large for task (%d,%d)\n", 721 vspace_index, task_id ); 722 exit(1); 723 } 724 } 687 725 688 726 vspace_index++; … … 722 760 str = getStringValue( reader, "name", &ok ); 723 761 #if XML_PARSER_DEBUG 724 printf(" -name = %s\n", str);762 printf(" name = %s\n", str); 725 763 #endif 726 764 if ( ok ) … … 737 775 value = getIntValue( reader, "base", &ok ); 738 776 #if XML_PARSER_DEBUG 739 printf(" -base = %x\n", value);777 printf(" base = %x\n", value); 740 778 #endif 741 779 if ( ok ) … … 752 790 value = getIntValue( reader, "length", &ok ); 753 791 #if XML_PARSER_DEBUG 754 printf(" -length = %x\n\n", value);792 printf(" length = %x\n\n", value); 755 793 #endif 756 794 if ( ok ) … … 789 827 cluster[cluster_index] = (mapping_cluster_t*)malloc(sizeof(mapping_cluster_t)); 790 828 829 // get index attribute (optional) 830 value = getIntValue(reader,"index",&ok); 831 #if XML_PARSER_DEBUG 832 printf(" index = %d\n", value); 833 #endif 834 if ( ok && (value != cluster_index) ) 835 { 836 printf("[XML ERROR] wrong cluster index / expected value is %d", 837 cluster_index); 838 exit(1); 839 } 840 791 841 // get procs attribute 792 842 value = getIntValue(reader,"procs",&ok); 793 843 #if XML_PARSER_DEBUG 794 printf(" -procs = %d\n", value);844 printf(" procs = %d\n", value); 795 845 #endif 796 846 if ( ok ) … … 805 855 } 806 856 807 // get timers attribute808 value = getIntValue(reader,"timers",&ok);809 #if XML_PARSER_DEBUG810 printf(" - timers = %d\n", value);811 #endif812 if ( ok )813 {814 cluster[cluster_index]->timers = value;815 }816 else817 {818 printf("[XML ERROR] illegal or missing <timers> attribute for cluster %d",819 cluster_index);820 exit(1);821 }822 823 // get dmas attribute824 value = getIntValue(reader,"dmas",&ok);825 #if XML_PARSER_DEBUG826 printf(" - dmas = %d\n\n", value);827 #endif828 if ( ok )829 {830 cluster[cluster_index]->dmas = value;831 }832 else833 {834 printf("[XML ERROR] illegal or missing <dmas> attribute for cluster %d",835 cluster_index);836 exit(1);837 }838 839 857 cluster_index++; 840 858 } // end clusterNode() … … 846 864 847 865 #if XML_PARSER_DEBUG 848 printf(" clusters set\n");866 printf("\n clusters set\n"); 849 867 #endif 850 868 … … 922 940 923 941 #if XML_PARSER_DEBUG 924 printf(" global vsegs set\n");942 printf(" globals set\n"); 925 943 #endif 926 944 … … 961 979 962 980 #if XML_PARSER_DEBUG 963 printf(" vspaces set\n");981 printf("\n vspaces set\n"); 964 982 #endif 965 983 … … 1011 1029 header = (mapping_header_t*)malloc(sizeof(mapping_header_t)); 1012 1030 1013 // get name attribute1031 ////////// get name attribute 1014 1032 name = getStringValue(reader, "name", &ok); 1015 1033 if ( ok ) 1016 1034 { 1017 1035 #if XML_PARSER_DEBUG 1018 printf(" -name = %s\n", name);1036 printf(" name = %s\n", name); 1019 1037 #endif 1020 1038 strncpy( header->name, name, 31); … … 1026 1044 } 1027 1045 1028 // get clusters attribute1046 /////////// get clusters attribute 1029 1047 value = getIntValue(reader, "clusters", &ok); 1030 1048 if ( ok ) … … 1036 1054 } 1037 1055 #if XML_PARSER_DEBUG 1038 printf(" -clusters = %d\n", value);1056 printf(" clusters = %d\n", value); 1039 1057 #endif 1040 1058 header->clusters = value; … … 1046 1064 } 1047 1065 1048 // get psegs attribute1066 ////////// get psegs attribute 1049 1067 value = getIntValue(reader, "psegs", &ok); 1050 1068 if ( ok ) … … 1056 1074 } 1057 1075 #if XML_PARSER_DEBUG 1058 printf(" -psegs = %d\n", value);1076 printf(" psegs = %d\n", value); 1059 1077 #endif 1060 1078 header->psegs = value; … … 1066 1084 } 1067 1085 1068 // get ttys attribute1086 ///////// get ttys attribute 1069 1087 value = getIntValue(reader, "ttys", &ok); 1070 1088 if ( ok ) 1071 1089 { 1072 1090 #if XML_PARSER_DEBUG 1073 printf(" -ttys = %d\n", value);1091 printf(" ttys = %d\n", value); 1074 1092 #endif 1075 1093 header->ttys = value; … … 1081 1099 } 1082 1100 1083 // get vspaces attribute 1101 ///////// get fbs attribute 1102 value = getIntValue(reader, "fbs", &ok); 1103 if ( ok ) 1104 { 1105 #if XML_PARSER_DEBUG 1106 printf(" fbs = %d\n", value); 1107 #endif 1108 header->fbs = value; 1109 } 1110 else 1111 { 1112 printf("[XML ERROR] illegal or missing <fbs> attribute in header\n"); 1113 exit(1); 1114 } 1115 1116 ///////// get vspaces attribute 1084 1117 value = getIntValue(reader, "vspaces", &ok); 1085 1118 if ( ok ) … … 1091 1124 } 1092 1125 #if XML_PARSER_DEBUG 1093 printf(" -vspaces = %d\n", value);1126 printf(" vspaces = %d\n", value); 1094 1127 #endif 1095 1128 header->vspaces = value; … … 1101 1134 } 1102 1135 1103 // get globals attribute1136 ////////// get globals attribute 1104 1137 value = getIntValue(reader, "globals", &ok); 1105 1138 if ( ok ) … … 1111 1144 } 1112 1145 #if XML_PARSER_DEBUG 1113 printf(" -globals = %d\n", value);1146 printf(" globals = %d\n", value); 1114 1147 #endif 1115 1148 header->globals = value;
Note: See TracChangeset
for help on using the changeset viewer.