Changeset 232 for soft/giet_vm


Ignore:
Timestamp:
Mar 5, 2013, 4:00:09 PM (12 years ago)
Author:
meunier
Message:

Ajout du malloc dans le Giet.

Location:
soft/giet_vm
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/Makefile

    r218 r232  
    11export # export all variable to sub-Makefile
    2 CC=mipsel-unknown-elf-gcc
    3 AS=mipsel-unknown-elf-as
    4 LD=mipsel-unknown-elf-ld
    5 DU=mipsel-unknown-elf-objdump
     2CC = mipsel-unknown-elf-gcc
     3AS = mipsel-unknown-elf-as
     4LD = mipsel-unknown-elf-ld
     5DU = mipsel-unknown-elf-objdump
    66
    77MAP_XML      = mappings/4c_1p_four.xml
    88
    99SYS_OBJS     = build/sys/vm_handler.o \
    10                        build/sys/sys_handler.o \
     10               build/sys/sys_handler.o \
    1111               build/sys/giet.o \
    12                build/sys/switch.o \
     12               build/sys/switch.o \
    1313               build/sys/common.o \
    1414               build/sys/ctx_handler.o \
     
    3838               build/libs/utils.o
    3939
    40 CFLAGS=-Wall -ffreestanding -mno-gpopt -mips32 -g
     40CFLAGS = -Wall -ffreestanding -mno-gpopt -mips32 -g
    4141
    4242INCLUDE = -Iboot -Isys -Ixml -Ilibs -I.
    4343
    44 TRASH= /dev/null||true
     44all: map.bin soft.elf
    4545
    46 all: map.bin soft.elf
    47        
    4846## merge all *.elf and map.bin to soft.elf
    4947soft.elf: build/boot/boot.elf \
     
    107105
    108106build/hello/main.o: hello/main.c
    109         $(CC) $(INCLUDE) $(CFLAGS)  -c -o $@ $<
     107        $(CC) $(INCLUDE) $(CFLAGS) -c -o $@ $<
    110108
    111109### pgcd compilation
     
    115113
    116114build/pgcd/main.o: pgcd/main.c
    117         $(CC) $(INCLUDE) $(CFLAGS)  -c -o $@ $<
     115        $(CC) $(INCLUDE) $(CFLAGS) -c -o $@ $<
    118116
    119117### libs compilation
    120118build/libs/utils.o: libs/utils.c giet_config.h
    121         $(CC) $(CFLAGS) $(INCLUDE)  -c -o $@ $<
     119        $(CC) $(CFLAGS) $(INCLUDE) -c -o $@ $<
    122120
    123121build/libs/stdio.o: libs/stdio.c giet_config.h 
    124         $(CC) $(CFLAGS) $(INCLUDE)  -c -o $@ $<
     122        $(CC) $(CFLAGS) $(INCLUDE) -c -o $@ $<
    125123
    126124build/libs/mwmr_channel.o: libs/mwmr_channel.c
    127         $(CC) $(CFLAGS) $(INCLUDE)  -c -o $@ $<
     125        $(CC) $(CFLAGS) $(INCLUDE) -c -o $@ $<
     126
     127build/libs/malloc.o: libs/malloc.c libs/malloc.h libs/malloc_private.h giet_config.h
     128        $(CC) $(CFLAGS) $(INCLUDE) -c -o $@ $<
     129
    128130
    129131
    130132### clean
    131133clean:
    132         rm -f *.o *.elf *.bin *.txt core  giet_vsegs.ld hard_config.h *~ 2>$(TRASH)
    133         $(MAKE) -s clean -C xml 2>$(TRASH)
    134         $(MAKE) -s clean -C memo 2>$(TRASH)
    135         rm -r build/boot/* 2>$(TRASH)
    136         rm -r build/sys/* 2>$(TRASH)
    137         rm -r build/libs/* 2>$(TRASH)
    138         rm -r build/pgcd/* 2>$(TRASH)
    139         rm -r build/hello/* 2>$(TRASH)
    140         rm -r build/display/* 2>$(TRASH)
    141         rm -r build/router/* 2>$(TRASH)
     134        rm -f *.o *.elf *.bin *.txt core  giet_vsegs.ld hard_config.h *~
     135        $(MAKE) -s clean -C xml
     136        $(MAKE) -s clean -C memo
     137        rm -rf build/boot/*
     138        rm -rf build/sys/*
     139        rm -rf build/libs/*
     140        rm -rf build/pgcd/*
     141        rm -rf build/hello/*
     142        rm -rf build/display/*
     143        rm -rf build/router/*
  • soft/giet_vm/boot/boot_init.c

    r230 r232  
    13871387                //FIXME: the vspace_id should be the same for all ports: put it in the coproc?
    13881388                unsigned int vspace_id = cp_port[cp_port_id].vspaceid;
    1389                 unsigned int vobj_id = cp_port[cp_port_id].vobjlocid + vspace[vspace_id].vobj_offset;
     1389                unsigned int vobj_id = cp_port[cp_port_id].mwmr_vobjid + vspace[vspace_id].vobj_offset;
    13901390
    13911391                mwmr_channel_t * pmwmr = (mwmr_channel_t *) (vobj[vobj_id].paddr);
     
    16691669
    16701670            // ctx_sp :  Get the vobj containing the stack
    1671             unsigned int vobj_id = task[task_id].vobjlocid + vspace[vspace_id].vobj_offset;
     1671            unsigned int vobj_id = task[task_id].stack_vobjid + vspace[vspace_id].vobj_offset;
    16721672            unsigned int ctx_sp = vobj[vobj_id].vaddr + vobj[vobj_id].length;
    16731673
     
    17061706            boot_scheduler_set_context(gpid, ltid, CTX_LTID_ID, ltid);
    17071707            boot_scheduler_set_context(gpid, ltid, CTX_VSID_ID, vspace_id);
     1708            boot_scheduler_set_context(gpid, ltid, CTX_GTID_ID, task_id);
    17081709            boot_scheduler_set_context(gpid, ltid, CTX_RUN_ID, 1);
    17091710
  • soft/giet_vm/giet_config.h

    r218 r232  
    2929
    3030#define GIET_NB_VSPACE_MAX      64                      /* max number of virtual spaces */
    31 #define GIET_TICK_VALUE     0x1000              /* context switch period (number of cycles) */
     31#define GIET_TICK_VALUE     0x100000            /* context switch period (number of cycles) */
    3232
    3333#endif
  • soft/giet_vm/libs/stdio.c

    r228 r232  
    2121#define SYSCALL_GCD_WRITE       0x06
    2222#define SYSCALL_GCD_READ        0x07
    23 #define SYSCALL_TASK_ID         0x09
     23#define SYSCALL_HEAP_INFO       0x08
     24#define SYSCALL_PROC_TASK_ID    0x09
     25#define SYSCALL_GLOBAL_TASK_ID  0x0A
    2426#define SYSCALL_CTX_SWITCH      0x0D
    2527#define SYSCALL_EXIT            0x0E
     
    742744
    743745//////////////////////////////////////////////////////////////////////////////////
    744 // giet_get_task_id()
    745 // The user task calling this function is descheduled and
    746 // the processor is allocated to another task.
    747 //////////////////////////////////////////////////////////////////////////////////
    748 unsigned int giet_task_id() {
    749     return sys_call(SYSCALL_TASK_ID, 0, 0, 0, 0);
    750 }
    751 
     746// giet_proc_task_id()
     747// This functions returns the local task id, i.e. the processor task id (ranging
     748// from 0 to n-1(p) for each processor if p has n tasks)
     749//////////////////////////////////////////////////////////////////////////////////
     750unsigned int giet_proc_task_id() {
     751    return sys_call(SYSCALL_PROC_TASK_ID, 0, 0, 0, 0);
     752}
     753
     754//////////////////////////////////////////////////////////////////////////////////
     755// giet_heap_info()
     756// This function returns the base address and size of the current task's heap
     757//////////////////////////////////////////////////////////////////////////////////
     758unsigned int giet_heap_info(unsigned int * vaddr, unsigned int * length) {
     759    return sys_call(SYSCALL_HEAP_INFO, (unsigned int) vaddr, (unsigned int) length, 0, 0);
     760}
     761
     762
     763//////////////////////////////////////////////////////////////////////////////////
     764// giet_global_task_id()
     765// This functions returns the global task id, which is unique in all the giet
     766//////////////////////////////////////////////////////////////////////////////////
     767unsigned int giet_global_task_id() {
     768    return sys_call(SYSCALL_GLOBAL_TASK_ID, 0, 0, 0, 0);
     769}
    752770
    753771// Local Variables:
  • soft/giet_vm/libs/stdio.h

    r228 r232  
    5050unsigned int giet_rand();
    5151unsigned int giet_context_switch();
    52 unsigned int giet_task_id();
     52unsigned int giet_proc_task_id();
     53unsigned int giet_heap_info(unsigned int * vaddr, unsigned int * size);
     54unsigned int giet_global_task_id();
     55
    5356unsigned int giet_procnumber();
    5457
  • soft/giet_vm/mappings/1c_4p_four.xml

    r215 r232  
    147147
    148148            <vseg name = "seg_data"     vbase = "0x00800000" mode = "__WU" clusterid = "0" psegname  = "PSEG_RAM" >
    149                 <vobj name = "data"     type = "ELF" length  = "0x00010000" binpath = "build/router/router.elf" />
    150             </vseg>
    151             <vseg name = "seg_code"     vbase = "0x00400000" mode = "CX_U" clusterid = "0" psegname  = "PSEG_RAM" >
    152                 <vobj name = "code"     type = "ELF" length  = "0x00010000" binpath = "build/router/router.elf" />
    153             </vseg>
    154             <vseg name = "seg_ptab"     vbase = "0x00300000" mode = "C___" clusterid = "0" psegname  = "PSEG_RAM" >
    155                 <vobj name = "ptab"     type = "PTAB" length  = "0x00012000" align   = "13" />
     149                <vobj name = "data"     type = "ELF" length = "0x00010000" binpath = "build/router/router.elf" />
     150            </vseg>
     151            <vseg name = "seg_code"     vbase = "0x00400000" mode = "CX_U" clusterid = "0" psegname  = "PSEG_RAM" >
     152                <vobj name = "code"     type = "ELF" length = "0x00010000" binpath = "build/router/router.elf" />
     153            </vseg>
     154            <vseg name = "seg_ptab"     vbase = "0x00300000" mode = "C___" clusterid = "0" psegname  = "PSEG_RAM" >
     155                <vobj name = "ptab"     type = "PTAB" length = "0x00012000" align   = "13" />
    156156            </vseg>
    157157            <vseg name = "seg_stack_p"  vbase = "0x00010000" mode = "C_WU" clusterid = "0" psegname  = "PSEG_RAM" >
    158                 <vobj name = "stack_p"  type = "BUFFER" length  = "0x00010000" />
    159                         </vseg>
    160             <vseg name = "seg_stack_c"  vbase = "0x00020000" mode = "C_WU" clusterid = "0" psegname  = "PSEG_RAM" >
    161                 <vobj name = "stack_c"  type = "BUFFER" length  = "0x00010000" />
     158                <vobj name = "stack_p"  type = "BUFFER" length = "0x00010000" />
     159                <vobj name = "heap_p"   type = "BUFFER" length = "0x00010000" />
     160                           </vseg>
     161            <vseg name = "seg_stack_c"  vbase = "0x00030000" mode = "C_WU" clusterid = "0" psegname  = "PSEG_RAM" >
     162                <vobj name = "stack_c"  type = "BUFFER" length = "0x00010000" />
     163                <vobj name = "heap_c"   type = "BUFFER" length = "0x00010000" />
    162164                                                </vseg>
    163             <vseg name = "seg_stack_rA" vbase = "0x00030000" mode = "C_WU" clusterid = "0" psegname  = "PSEG_RAM" >
    164                 <vobj name = "stack_rA" type = "BUFFER" length  = "0x00010000" />
    165             </vseg>
    166             <vseg name = "seg_stack_rB" vbase = "0x00040000" mode = "C_WU" clusterid = "0" psegname  = "PSEG_RAM" >
     165            <vseg name = "seg_stack_rA" vbase = "0x00050000" mode = "C_WU" clusterid = "0" psegname  = "PSEG_RAM" >
     166                <vobj name = "stack_rA" type = "BUFFER" length = "0x00010000" />
     167                <vobj name = "heap_rA"  type = "BUFFER" length = "0x00010000" />
     168            </vseg>
     169            <vseg name = "seg_stack_rB" vbase = "0x00070000" mode = "C_WU" clusterid = "0" psegname  = "PSEG_RAM" >
    167170                <vobj name = "stack_rB" type = "BUFFER" length  = "0x00010000" />
    168             </vseg>
    169             <vseg name = "seg_mwmrs"    vbase = "0x00050000" mode = "__WU" clusterid = "0" psegname  = "PSEG_RAM" >
    170                 <vobj name = "mwmr_in"  type = "MWMR" length  = "0x00000020" init = "1" />
    171                 <vobj name = "mwmr_out" type = "MWMR" length  = "0x00000020" init = "1" />
    172             </vseg>
    173 
    174             <task name = "producer" clusterid = "0" proclocid = "0" stackname = "stack_p"  startid = "0" usetty = "1" />
    175             <task name = "consumer" clusterid = "0" proclocid = "1" stackname = "stack_c"  startid = "1" usetty = "1" />
    176             <task name = "router_A" clusterid = "0" proclocid = "2" stackname = "stack_rA" startid = "2" usetty = "1" />
    177             <task name = "router_B" clusterid = "0" proclocid = "3" stackname = "stack_rB" startid = "2" usetty = "1" />
     171                <vobj name = "heap_rB"  type = "BUFFER" length = "0x00010000" />
     172            </vseg>
     173            <vseg name = "seg_mwmrs"    vbase = "0x00090000" mode = "__WU" clusterid = "0" psegname  = "PSEG_RAM" >
     174                <vobj name = "mwmr_in"  type = "MWMR" length = "0x00000020" init = "1" />
     175                <vobj name = "mwmr_out" type = "MWMR" length = "0x00000020" init = "1" />
     176            </vseg>
     177
     178            <task name = "producer" clusterid = "0" proclocid = "0" stackname = "stack_p"  heapname = "heap_p"  startid = "0" usetty = "1" />
     179            <task name = "consumer" clusterid = "0" proclocid = "1" stackname = "stack_c"  heapname = "heap_c"  startid = "1" usetty = "1" />
     180            <task name = "router_A" clusterid = "0" proclocid = "2" stackname = "stack_rA" heapname = "heap_rA" startid = "2" usetty = "1" />
     181            <task name = "router_B" clusterid = "0" proclocid = "3" stackname = "stack_rB" heapname = "heap_rB" startid = "2" usetty = "1" />
    178182
    179183        </vspace>
  • soft/giet_vm/mappings/4c_1p_display.xml

    r218 r232  
    171171    <vspaceset>
    172172        <vspace name = "display" startname = "data" >
    173             <vseg name = "seg_data"        vbase = "0x00800000" mode = "C_WU" clusterid = "3" psegname = "PSEG_RAM" >
    174                 <vobj name = "data"        type = "ELF" length = "0x00010000" binpath = "build/display/display.elf" />
     173            <vseg name = "seg_data"  vbase = "0x00800000" mode = "C_WU" clusterid = "3" psegname = "PSEG_RAM" >
     174                <vobj name = "data"  type       = "ELF" length = "0x00010000" binpath = "build/display/display.elf" />
    175175                        </vseg>
    176             <vseg name = "seg_ptab"        vbase = "0x00300000" mode = "C___" clusterid = "3" psegname = "PSEG_RAM" >
    177                 <vobj name = "ptab"        type = "PTAB" length  = "0x00012000" align   = "13" />
     176            <vseg name = "seg_ptab"  vbase = "0x00300000" mode = "C___" clusterid = "3" psegname = "PSEG_RAM" >
     177                <vobj name = "ptab"  type       = "PTAB" length  = "0x00012000" align   = "13" />
    178178            </vseg>
    179             <vseg name = "seg_code"        vbase = "0x00400000" mode = "CX_U" clusterid = "3" psegname = "PSEG_RAM" >
    180                 <vobj name = "code"        type = "ELF" length = "0x00010000" binpath = "build/display/display.elf" />
     179            <vseg name = "seg_code"  vbase = "0x00400000" mode = "CX_U" clusterid = "3" psegname = "PSEG_RAM" >
     180                <vobj name = "code"  type       = "ELF" length = "0x00010000" binpath = "build/display/display.elf" />
    181181            </vseg>
    182             <vseg name = "seg_stack"       vbase = "0x00010000" mode = "C_WU" clusterid = "3" psegname = "PSEG_RAM" >
    183                 <vobj name = "stack"       type = "BUFFER" length = "0x00010000" />
     182            <vseg name = "seg_stack" vbase = "0x00010000" mode = "C_WU" clusterid = "3" psegname = "PSEG_RAM" >
     183                <vobj name = "stack" type       = "BUFFER" length = "0x00010000" />
     184                <vobj name = "heap"  type = "BUFFER" length = "0x00010000" />
    184185            </vseg>
    185186
    186             <task name = "main_display" clusterid = "3" proclocid = "0" stackname = "stack" startid = "0" usetty = "1" usefbdma = "1" />
     187            <task name = "main_display" clusterid = "3" proclocid = "0" stackname = "stack" heapname = "heap" startid = "0" usetty = "1" usefbdma = "1" />
    187188        </vspace>
    188189    </vspaceset>
  • soft/giet_vm/mappings/4c_1p_four.xml

    r218 r232  
    182182            <vseg name = "seg_stack_prod"  vbase = "0x00010000" mode = "C_WU" clusterid = "0" psegname = "PSEG_RAM" >
    183183                <vobj name = "stack_prod"  type = "BUFFER" length = "0x00010000" />
    184             </vseg>
    185             <vseg name = "seg_stack_cons"  vbase = "0x00020000" mode = "C_WU" clusterid = "1" psegname = "PSEG_RAM" >
     184                <vobj name = "heap_prod"   type = "BUFFER" length = "0x00010000" />
     185            </vseg>
     186            <vseg name = "seg_stack_cons"  vbase = "0x00030000" mode = "C_WU" clusterid = "1" psegname = "PSEG_RAM" >
    186187                <vobj name = "stack_cons"  type = "BUFFER" length = "0x00010000" />
    187             </vseg>
    188             <vseg name = "seg_stack_routA" vbase = "0x00030000" mode = "C_WU" clusterid = "2" psegname = "PSEG_RAM" >
     188                <vobj name = "heap_cons"   type = "BUFFER" length = "0x00010000" />
     189            </vseg>
     190            <vseg name = "seg_stack_routA" vbase = "0x00050000" mode = "C_WU" clusterid = "2" psegname = "PSEG_RAM" >
    189191                <vobj name = "stack_routA" type = "BUFFER" length = "0x00010000" />
    190             </vseg>
    191             <vseg name = "seg_stack_routB" vbase = "0x00040000" mode = "C_WU" clusterid = "3" psegname = "PSEG_RAM" >
     192                <vobj name = "heap_routA"  type = "BUFFER" length = "0x00010000" />
     193            </vseg>
     194            <vseg name = "seg_stack_routB" vbase = "0x00070000" mode = "C_WU" clusterid = "3" psegname = "PSEG_RAM" >
    192195                <vobj name = "stack_routB" type = "BUFFER" length = "0x00010000" />
    193             </vseg>
    194             <vseg name = "seg_mwmrs"       vbase = "0x00050000" mode = "__WU" clusterid = "0" psegname = "PSEG_RAM" >
     196                <vobj name = "heap_routB"  type = "BUFFER" length = "0x00010000" />
     197            </vseg>
     198            <vseg name = "seg_mwmrs"       vbase = "0x00090000" mode = "__WU" clusterid = "0" psegname = "PSEG_RAM" >
    195199                <vobj name = "mwmr_in"     type = "MWMR" length = "0x00000020" init = "1" />
    196200                <vobj name = "mwmr_out"    type = "MWMR" length = "0x00000020" init = "1" />
    197201                    </vseg>
    198202
    199             <task name = "producer" clusterid = "0" proclocid = "0" stackname = "stack_prod"  startid = "0" usetty = "1" />
    200             <task name = "consumer" clusterid = "1" proclocid = "0" stackname = "stack_cons"  startid = "1" usetty = "1" />
    201             <task name = "router_A" clusterid = "2" proclocid = "0" stackname = "stack_routA" startid = "2" usetty = "1" />
    202             <task name = "router_B" clusterid = "3" proclocid = "0" stackname = "stack_routB" startid = "2" usetty = "1" />
     203            <task name = "producer" clusterid = "0" proclocid = "0" stackname = "stack_prod"  heapname = "heap_prod"  startid = "0" usetty = "1" />
     204            <task name = "consumer" clusterid = "1" proclocid = "0" stackname = "stack_cons"  heapname = "heap_cons"  startid = "1" usetty = "1" />
     205            <task name = "router_A" clusterid = "2" proclocid = "0" stackname = "stack_routA" heapname = "heap_routA" startid = "2" usetty = "1" />
     206            <task name = "router_B" clusterid = "3" proclocid = "0" stackname = "stack_routB" heapname = "heap_routB" startid = "2" usetty = "1" />
    203207        </vspace>
    204208
     
    215219            <vseg name = "seg_stack"       vbase = "0x00010000" mode = "C_WU" clusterid = "1" psegname = "PSEG_RAM" >
    216220                <vobj name = "stack"       type = "BUFFER" length = "0x00010000" />
    217             </vseg>
    218 
    219             <task name = "main_hello" clusterid = "1" proclocid = "0" stackname = "stack" startid = "0" usetty = "1" />
     221                <vobj name = "heap"        type = "BUFFER" length = "0x00010000" />
     222            </vseg>
     223
     224            <task name = "main_hello" clusterid = "1" proclocid = "0" stackname = "stack" heapname = "heap" startid = "0" usetty = "1" />
    220225        </vspace>
    221226
     
    232237            <vseg name = "seg_stack"       vbase = "0x00010000" mode = "C_WU" clusterid = "2" psegname = "PSEG_RAM" >
    233238                <vobj name = "stack"       type = "BUFFER" length = "0x00010000" />
    234             </vseg>
    235 
    236             <task name = "main_pgcd" clusterid = "2" proclocid = "0" stackname = "stack" startid = "0" usetty = "1" />
     239                <vobj name = "heap"        type = "BUFFER" length = "0x00010000" />
     240            </vseg>
     241
     242            <task name = "main_pgcd" clusterid = "2" proclocid = "0" stackname = "stack" heapname = "heap" startid = "0" usetty = "1" />
    237243        </vspace>
    238244
     
    249255            <vseg name = "seg_stack"       vbase = "0x00010000" mode = "C_WU" clusterid = "3" psegname = "PSEG_RAM" >
    250256                <vobj name = "stack"       type = "BUFFER" length = "0x00010000" />
    251             </vseg>
    252 
    253             <task name = "main_display" clusterid = "3" proclocid = "0" stackname = "stack" startid = "0" usetty = "1" usefbdma = "1" />
     257                <vobj name = "heap"        type = "BUFFER" length = "0x00010000" />
     258            </vseg>
     259
     260            <task name = "main_display" clusterid = "3" proclocid = "0" stackname = "stack" heapname = "heap" startid = "0" usetty = "1" usefbdma = "1" />
    254261        </vspace>
    255262    </vspaceset>
  • soft/giet_vm/mappings/exemple.xml

    r215 r232  
    421421                                                                        type    = "BUFFER"
    422422                                                                            length  = "0x00010000" />
     423                         <vobj   name   = "heap_producer"
     424                                                                        type    = "BUFFER"
     425                                                                            length  = "0x00010000" />
     426
    423427                                                </vseg>
    424428
    425429                        <vseg   name      = "seg_stack_consumer"
    426                                                 vbase     = "0x00020000"
     430                                                vbase     = "0x00030000"
    427431                                mode      = "C_WU"
    428432                                clusterid = "0"
     
    431435                                                                        type    = "BUFFER"
    432436                                                                            length  = "0x00010000" />
     437                         <vobj   name   = "heap_consumer"
     438                                                                        type    = "BUFFER"
     439                                                                            length  = "0x00010000" />
     440
    433441                                                </vseg>
    434442
    435443                        <vseg   name      = "seg_stack_router_A"
    436                                                 vbase     = "0x00030000"
     444                                                vbase     = "0x00050000"
    437445                                mode      = "C_WU"
    438446                                clusterid = "0"
     
    441449                                                                        type    = "BUFFER"
    442450                                                                            length  = "0x00010000" />
     451                         <vobj   name   = "heap_router_A"
     452                                                                        type    = "BUFFER"
     453                                                                            length  = "0x00010000" />
     454
    443455                                                </vseg>
    444456
    445457                        <vseg   name      = "seg_stack_router_B"
    446                                                 vbase     = "0x00040000"
     458                                                vbase     = "0x00070000"
    447459                                mode      = "C_WU"
    448460                                clusterid = "0"
     
    451463                                                                        type    = "BUFFER"
    452464                                                                            length  = "0x00010000" />
     465                                                            <vobj   name        = "heap_router_B"
     466                                                                        type    = "BUFFER"
     467                                                                            length  = "0x00010000" />
     468
    453469                                                </vseg>
    454470
    455471                        <vseg   name      = "seg_mwmr_channels"
    456                                 vbase     = "0x00050000"
     472                                vbase     = "0x00090000"
    457473                                mode      = "__WU"
    458474                                clusterid = "0"
     
    472488                                proclocid = "0"
    473489                                stackname = "stack_producer"
     490                                heapname  = "heap_producer"
    474491                                startid   = "0"
    475492                                usetty    = "1" />
     
    479496                                proclocid = "1"
    480497                                stackname = "stack_consumer"
     498                                heapname  = "heap_consumer"
    481499                                startid   = "1"
    482500                                usetty    = "1" />
     
    486504                                proclocid = "2"
    487505                                stackname = "stack_router_A"
     506                                heapname  = "heap_router_A"
    488507                                startid   = "2"
    489508                                usetty    = "1" />
     
    493512                                proclocid = "3"
    494513                                stackname = "stack_router_B"
     514                                heapname  = "heap_router_B"
    495515                                startid   = "2"
    496516                                usetty    = "1" />
  • soft/giet_vm/sys/common.c

    r231 r232  
    375375
    376376////////////////////////////////////////////////////////////////////////////
    377 //    _get_current_task_id()
     377//    _get_proc_task_id()
    378378// This function returns the index of the currently running task.
    379379////////////////////////////////////////////////////////////////////////////
    380 unsigned int _get_current_task_id() {
     380unsigned int _get_proc_task_id() {
    381381    static_scheduler_t * psched = (static_scheduler_t *) _get_sched();
    382382    return _physical_read_access(&(psched->current));
     
    385385
    386386////////////////////////////////////////////////////////////////////////////
    387 //    _set_current_task_id()
     387//    _set_proc_task_id()
    388388// This function returns the index of the currently running task.
    389389////////////////////////////////////////////////////////////////////////////
    390 void _set_current_task_id(unsigned int value) {
     390void _set_proc_task_id(unsigned int value) {
    391391    static_scheduler_t * psched = (static_scheduler_t *) _get_sched();
    392392    _physical_write_access(&(psched->current), value);
     393}
     394
     395
     396////////////////////////////////////////////////////////////////////////////
     397//    _get_global_task_id()
     398// This function returns the global index of the running task.
     399////////////////////////////////////////////////////////////////////////////
     400unsigned int _get_global_task_id() {
     401  return _get_context_slot(_get_proc_task_id(), CTX_GTID_ID);
    393402}
    394403
  • soft/giet_vm/sys/common.h

    r231 r232  
    6060unsigned int _get_interrupt_vector_entry(unsigned int index);
    6161
    62 unsigned int _get_current_task_id(void);
    63 void _set_current_task_id(unsigned int value);
     62unsigned int _get_proc_task_id(void);
     63void _set_proc_task_id(unsigned int value);
     64
     65unsigned int _get_global_task_id(void);
     66
    6467
    6568unsigned int _get_tasks_number(void);
  • soft/giet_vm/sys/ctx_handler.c

    r231 r232  
    7676
    7777    // get current task index
    78     unsigned int curr_task_id = _get_current_task_id();
     78    unsigned int curr_task_id = _get_proc_task_id();
    7979
    8080    // select the next task using a round-robin policy
     
    103103        unsigned int * next_ctx_paddr = &(psched->context[next_task_id][0]);
    104104
    105         _set_current_task_id(next_task_id);
     105        _set_proc_task_id(next_task_id);
    106106        //_timer_reset_irq_cpt(cluster_id, local_id); // commented until not properly supported in soclib
    107107        // (the function is not yet present in drivers.c)
  • soft/giet_vm/sys/ctx_handler.h

    r231 r232  
    55
    66/////////////////////////////////////////////////////////////////////////////////
    7 //      Definition of the scheduler structure
     7//    Definition of the scheduler structure
    88/////////////////////////////////////////////////////////////////////////////////
    99
    10 typedef struct static_scheduler_s
    11 {
    12     unsigned int        context[15][64];                // at most 15 task contexts
    13     unsigned int        tasks;                                  // actual number of tasks
    14     unsigned int        current;                                // current task index
    15     unsigned int        interrupt_vector[32];   // interrupt vector
     10typedef struct static_scheduler_s {
     11    unsigned int context[15][64];      // at most 15 task contexts
     12    unsigned int tasks;                // actual number of tasks
     13    unsigned int current;              // current task index
     14    unsigned int interrupt_vector[32]; // interrupt vector
    1615} static_scheduler_t;
    1716
     
    2120/////////////////////////////////////////////////////////////////////////////////
    2221
    23 #define IDLE_TASK_INDEX         14
     22#define IDLE_TASK_INDEX        14
    2423
    2524/////////////////////////////////////////////////////////////////////////////////
    26 //      Definition of the task context slots indexes
     25//    Definition of the task context slots indexes
    2726/////////////////////////////////////////////////////////////////////////////////
    2827
    29 #define CTX_SP_ID               29
    30 #define CTX_RA_ID               31
     28#define CTX_SP_ID        29
     29#define CTX_RA_ID        31
    3130
    32 #define CTX_EPC_ID              32
    33 #define CTX_CR_ID               33
    34 #define CTX_SR_ID               34
    35 #define CTX_BVAR_ID             35
     31#define CTX_EPC_ID       32
     32#define CTX_CR_ID        33
     33#define CTX_SR_ID        34
     34#define CTX_BVAR_ID      35
    3635
    37 #define CTX_PTPR_ID             39
     36#define CTX_PTPR_ID      39
    3837
    39 #define CTX_TTY_ID              40  // Integer : global TTY terminal index
    40 #define CTX_DMA_ID          41  // Integer : global DMA channel index
    41 #define CTX_NIC_ID          42  // Integer : global NIC channel index
    42 #define CTX_TIMER_ID    43  // Integer : user level timer index / UNUSED
    43 #define CTX_PTAB_ID             44  // Pointer : page table virtual base adress
    44 #define CTX_LTID_ID             45  // Integer : local task index (in scheduler) / UNUSED
    45 #define CTX_VSID_ID             46  // Integer : vspace index
    46 #define CTX_RUN_ID              47  // Boolean : task runable
     38#define CTX_TTY_ID       40  // Integer : global TTY terminal index
     39#define CTX_DMA_ID       41  // Integer : global DMA channel index
     40#define CTX_NIC_ID       42  // Integer : global NIC channel index
     41#define CTX_TIMER_ID     43  // Integer : user level timer index / UNUSED
     42#define CTX_PTAB_ID      44  // Pointer : page table virtual base adress
     43#define CTX_LTID_ID      45  // Integer : local task index (in scheduler) / UNUSED
     44#define CTX_VSID_ID      46  // Integer : vspace index
     45#define CTX_RUN_ID       47  // Boolean : task runable
     46#define CTX_GTID_ID      48  // Integer : Global task id
    4747
    4848//////////////////////////////////////////////////////////////////////////////////
    49 //      Prototype of the context switch function
     49//     Prototype of the context switch function
    5050//////////////////////////////////////////////////////////////////////////////////
    5151
  • soft/giet_vm/sys/drivers.c

    r228 r232  
    120120#if (NB_TIMERS_MAX > 0)
    121121in_unckdata volatile unsigned char _user_timer_event[NB_CLUSTERS * NB_TIMERS_MAX]
    122 = { [0 ... ((NB_CLUSTERS * NB_TIMERS_MAX) - 1)] = 0 };
     122                            = { [0 ... ((NB_CLUSTERS * NB_TIMERS_MAX) - 1)] = 0 };
    123123#endif
    124124
     
    205205    bloup++; // to avoid a warning
    206206#else
    207     unsigned int * timer_address = (unsigned int *)((char *) &seg_tim_base +
     207    unsigned int * timer_address = (unsigned int *) ((char *) &seg_tim_base +
    208208            (cluster_id * CLUSTER_SIZE));
    209209
     
    213213    return 0;
    214214}
     215
     216
     217////////////////////////////////////////////////
     218// _timer_reset_irq_cpt()
     219////////////////////////////////////////////////
     220//unsigned int _timer_reset_irq_cpt(unsigned int cluster_id, unsigned int local_id) {
     221//    // parameters checking
     222//    if ( cluster_id >= NB_CLUSTERS)    return 1;
     223//    if ( local_id >= NB_TIMERS_MAX ) return 2;
     224//
     225//#if USE_XICU
     226//#error // not implemented
     227//#else
     228//    unsigned int * timer_address = (unsigned int *) ((char *) &seg_tim_base + (cluster_id * CLUSTER_SIZE));
     229//
     230//    timer_address[local_id * TIMER_SPAN + TIMER_RESETIRQ] = 1;
     231//#endif
     232//
     233//    return 0;
     234//}
    215235
    216236
     
    264284unsigned int _tty_write(const char * buffer, unsigned int length) {
    265285    unsigned int nwritten;
    266     unsigned int task_id = _get_current_task_id();
     286    unsigned int task_id = _get_proc_task_id();
    267287    unsigned int tty_id = _get_context_slot(task_id, CTX_TTY_ID);
    268288
     
    300320//////////////////////////////////////////////////////////////////////////////
    301321unsigned int _tty_read(char * buffer, unsigned int length) {
    302     unsigned int task_id = _get_current_task_id();
     322    unsigned int task_id = _get_proc_task_id();
    303323    unsigned int tty_id = _get_context_slot(task_id, CTX_TTY_ID);
    304324
     
    567587
    568588    // get user space page table virtual address
    569     unsigned int task_id = _get_current_task_id();
     589    unsigned int task_id = _get_proc_task_id();
    570590    unsigned int user_pt_vbase = _get_context_slot(task_id, CTX_PTAB_ID);
    571591
     
    877897
    878898    // get DMA channel and compute DMA vbase address
    879     unsigned int task_id    = _get_current_task_id();
     899    unsigned int task_id    = _get_proc_task_id();
    880900    unsigned int dma_id     = _get_context_slot(task_id, CTX_DMA_ID);
    881901    unsigned int cluster_id = dma_id / NB_DMAS_MAX;
     
    10121032unsigned int _dma_completed() {
    10131033#if NB_DMAS_MAX > 0
    1014     unsigned int task_id = _get_current_task_id();
     1034    unsigned int task_id = _get_proc_task_id();
    10151035    unsigned int dma_id  = _get_context_slot(task_id, CTX_DMA_ID);
    10161036    unsigned int dma_ret;
     
    12461266}
    12471267
     1268///////////////////////////////////////////////////////////////////////////////////
     1269// _heap_info()
     1270// This function returns the information associated to a heap (size and vaddr)
     1271// It uses the global task id (CTX_GTID_ID, unique for each giet task) and the
     1272// vspace id (CTX_VSID_ID) defined in the context
     1273///////////////////////////////////////////////////////////////////////////////////
     1274unsigned int _heap_info(unsigned int * vaddr, unsigned int * size) {
     1275    mapping_header_t * header  = (mapping_header_t *) (&seg_mapping_base);
     1276    mapping_task_t * tasks     = _get_task_base(header);
     1277    mapping_vobj_t * vobjs     = _get_vobj_base(header);
     1278    mapping_vspace_t * vspaces = _get_vspace_base(header);
     1279    unsigned int taskid        = _get_context_slot(_get_proc_task_id(), CTX_GTID_ID);
     1280    unsigned int vspaceid      = _get_context_slot(_get_proc_task_id(), CTX_VSID_ID);
     1281    int heap_local_vobjid      = tasks[taskid].heap_vobjid;
     1282    if (heap_local_vobjid != -1) {
     1283        unsigned int vobjheapid = heap_local_vobjid + vspaces[vspaceid].vobj_offset;
     1284        *vaddr                  = vobjs[vobjheapid].vaddr;
     1285        *size                   = vobjs[vobjheapid].length;
     1286        return 0;
     1287    }
     1288    else {
     1289        *vaddr = 0;
     1290        *size = 0;
     1291        return 0;
     1292    }
     1293}
     1294
    12481295// Local Variables:
    12491296// tab-width: 4
  • soft/giet_vm/sys/drivers.h

    r228 r232  
    113113
    114114
     115///////////////////////////////////////////////////////////////////////////////////
     116// Heap related function(s)
     117///////////////////////////////////////////////////////////////////////////////////
     118
     119unsigned int _heap_info(unsigned int * vaddr, unsigned int * size);
     120
     121
    115122#endif
    116123
  • soft/giet_vm/sys/exc_handler.c

    r228 r232  
    7070    _get_lock(&_tty_put_lock);
    7171    _puts("\n[GIET] Exception for task ");
    72     _putd(_get_current_task_id());
     72    _putd(_get_proc_task_id());
    7373    _puts(" on processor ");
    7474    _putd(_procid());
     
    8686
    8787    // goes to sleeping state
    88     unsigned int task_id = _get_current_task_id();
     88    unsigned int task_id = _get_proc_task_id();
    8989    _set_context_slot( task_id, CTX_RUN_ID, 0);
    9090
  • soft/giet_vm/sys/sys_handler.c

    r231 r232  
    3030    &_gcd_write,           /* 0x06 */
    3131    &_gcd_read,            /* 0x07 */
    32     &_sys_ukn,             /* 0x08 */
    33     &_get_current_task_id, /* 0x09 */
    34     &_sys_ukn,             /* 0x0A */
     32    &_heap_info,           /* 0x08 */
     33    &_get_proc_task_id,    /* 0x09 */
     34    &_get_global_task_id,  /* 0x0A */
    3535    &_sys_ukn,             /* 0x0B */
    3636    &_sys_ukn,             /* 0x0C */
     
    7777    unsigned int date = _proctime();
    7878    unsigned int proc_id = _procid();
    79     unsigned int task_id = _get_current_task_id();
     79    unsigned int task_id = _get_proc_task_id();
    8080
    8181    // print death message
  • soft/giet_vm/xml/mapping_info.h

    r228 r232  
    178178    unsigned int clusterid;      // physical cluster index
    179179    unsigned int proclocid;      // processor local index (inside cluster)
    180     unsigned int vobjlocid;      // stack vobj index in vspace
     180    unsigned int stack_vobjid;   // stack vobj index in vspace
     181    unsigned int heap_vobjid;    // heap vobj index in vspace
    181182    unsigned int startid;        // index in start_vector
    182183    unsigned int use_tty;        // TTY terminal required (global)
     
    229230    unsigned int direction;      // TO_COPROC == 0 / FROM_COPROC == 1
    230231    unsigned int vspaceid;       // index of the vspace containing the MWMR channel
    231     unsigned int vobjlocid;      // local index of the vobj containing the MWMR channel
     232    unsigned int mwmr_vobjid;      // local index of the vobj containing the MWMR channel
    232233} mapping_cp_port_t;
    233234
  • soft/giet_vm/xml/xml_driver.c

    r228 r232  
    271271                    port_id < coproc[coproc_id].port_offset + coproc[coproc_id].ports;
    272272                    port_id++) {
    273                 unsigned int vobj_id = cp_port[port_id].vobjlocid + vspace[cp_port[port_id].vspaceid].vobj_offset;
     273                unsigned int vobj_id = cp_port[port_id].mwmr_vobjid + vspace[cp_port[port_id].vspaceid].vobj_offset;
    274274                fprintf(fpout, "             <port direction = \"%s\" ",  port_direction[cp_port[port_id].direction]);
    275275                fprintf(fpout, " vspacename = \"%s\" ", vspace[cp_port[port_id].vspaceid].name);
     
    353353                task_id < (vspace[vspace_id].task_offset + vspace[vspace_id].tasks);
    354354                task_id++) {
    355             unsigned int vobj_id = task[task_id].vobjlocid + vspace[vspace_id].vobj_offset;
     355            unsigned int stack_vobj_id = task[task_id].stack_vobjid + vspace[vspace_id].vobj_offset;
     356            unsigned int heap_vobj_id = task[task_id].heap_vobjid + vspace[vspace_id].vobj_offset;
    356357
    357358            fprintf(fpout, "            <task name = \"%s\" ", task[task_id].name);
    358359            fprintf(fpout, "clusterid = \"%d\" ", task[task_id].clusterid);
    359360            fprintf(fpout, "proclocid = \"%d\" ", task[task_id].proclocid);
    360             fprintf(fpout, "stackname = \"%s\" ", vobj[vobj_id].name);
     361            fprintf(fpout, "stackname = \"%s\" ", vobj[stack_vobj_id].name);
     362            if (heap_vobj_id != -1) {
     363                fprintf(fpout, "heapname = \"%s\" ", vobj[heap_vobj_id].name);
     364            }
    361365            fprintf(fpout, "startid = \"%d\" ", task[task_id].startid);
    362366            fprintf(fpout, "usetty = \"%d\" ", task[task_id].use_tty);
  • soft/giet_vm/xml/xml_parser.c

    r231 r232  
    109109unsigned int cluster_y            = 0;
    110110unsigned int cluster_x            = 0;
    111 unsigned int nb_proc_max          = 0; // max number of processors per cluster
     111unsigned int nb_proc_max          = 0; // max number of processors per cluste
     112
     113unsigned int nb_tasks_max         = 0; // max number of tasks (for all vspaces)
    112114unsigned int nb_timer_channel_max = 0; // max number of user timer
    113115unsigned int nb_dma_channel_max   = 0;
     
    350352            printf("      stackid   = %d\n", index);
    351353#endif
    352             task[task_index]->vobjlocid = index;
     354            task[task_index]->stack_vobjid = index;
    353355        }
    354356        else {
     
    363365        exit(1);
    364366    }
     367
     368    ////////// get heap attribute
     369    str = getStringValue(reader, "heapname", &ok);
     370    if (ok) {
     371        int index = getVobjLocId(vspace_index, str, vobj_loc_index);
     372        if (index >= 0) {
     373#if XML_PARSER_DEBUG
     374            printf("      heapname = %s\n", str);
     375            printf("      heapid   = %d\n", index);
     376#endif
     377            task[task_index]->heap_vobjid = index;
     378        }
     379        else {
     380            printf("[XML ERROR] illegal or missing <heapname> for task (%d,%d)\n", vspace_index, task_loc_index);
     381            exit(1);
     382        }
     383    } 
     384    else {
     385        task[task_index]->heap_vobjid = -1;
     386    }
     387
    365388
    366389    ////////// get startid  attribute
     
    715738    char * str;
    716739    unsigned int ok;
     740    unsigned int nb_task_vspace = 0;
    717741
    718742    vobj_loc_index = 0;
     
    782806        else if (strcmp(tag, "task") == 0) {
    783807            taskNode(reader);
     808            nb_task_vspace++;
    784809        }
    785810        else if (strcmp(tag, "#text")    == 0) { }
     
    818843            }
    819844
     845            nb_tasks_max += nb_task_vspace;
    820846            vspace_index++;
    821847            return;
     
    19341960            printf("      vobj_index   = %d\n", vobj_id);
    19351961#endif
    1936             cp_port[i]->vobjlocid = vobj_id;
     1962            cp_port[i]->mwmr_vobjid = vobj_id;
    19371963
    19381964            assert((vobj[ vspace[vspace_id]->vobj_offset + vobj_id]->type == VOBJ_TYPE_MWMR)
     
    19902016    def_int_write(fdout, "NB_IOCS"      , nb_ioc_channel);
    19912017    def_int_write(fdout, "NB_NICS"      , nb_nic_channel);
     2018    def_int_write(fdout, "NB_TASKS"     , nb_tasks_max);
    19922019
    19932020    file_write(fdout, "\n");
Note: See TracChangeset for help on using the changeset viewer.