Ignore:
Timestamp:
Nov 3, 2014, 11:03:55 AM (10 years ago)
Author:
alain
Message:

Introducing dynamic allocation of peripheral channels (NIC, TTY, CMA, TIM)
Intoducing a kernel function for all system calls: No more direct call
to the peripheral drivers.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/giet_kernel/ctx_handler.h

    r396 r440  
    99// in time multiplexing on a single processor.
    1010// The tasks are statically allocated to a processor in the boot phase, and
    11 // there is one private scheduler per processor. Each sheduler occupies 4K bytes,
     11// there is one private scheduler per processor. Each sheduler occupies 8K bytes,
    1212// and contains up to 14 task contexts (task_id is from 0 to 13).
    1313// The task context [13] is reserved for the "idle" task that does nothing, and
     
    1515/////////////////////////////////////////////////////////////////////////////////////////
    1616// A task context is an array of 64 words = 256 bytes.
    17 // It contains copies of processor registers (when the task is preempted):
    18 // - GPR[i], generally stored in slot (i). $0, $26 & $27 are not saved.
    19 // - HI & LO registers
    20 // - CP0 registers: EPC, SR, CR, BVAR
    21 // - CP2 registers : PTPR
    22 // It contains some general informations associated to the task:
    23 // - TTY    : TTY channel global index
    24 // - NIC    : NIC channel global index
    25 // - CMA    : CMA channel global index
    26 // - HBA    : HBA channel global index
    27 // - DMA    : DMA channel local index
    28 // - TIM    : TIM channel local index
    29 // - PTAB   : page table virtual base address
    30 // - LTID   : Task local index (in scheduler)
    31 // - VSID   : Virtual space index
    32 // - RUN    : Task state (0 => sleeping / 1 => runnable )
    33 // - TRDID  : Thread ID index (in vspace)
    34 //
     17// It contains copies of processor registers (when the task is preempted)
     18// and some general informations associated to a task, such as the peripherals
     19// allocated to the task (private peripheral channel for multi-channels peripherals).
     20/////////////////////////////////////////////////////////////////////////////////////////
    3521// ctx[0] <- ***   |ctx[8] <- $8    |ctx[16]<- $16   |ctx[24]<- $24
    3622// ctx[1] <- $1    |ctx[9] <- $9    |ctx[17]<- $17   |ctx[25]<- $25
     
    4228// ctx[7] <- $7    |ctx[15]<- $15   |ctx[23]<- $23   |ctx[31]<- RA
    4329//
    44 // ctx[32]<- EPC   |ctx[40]<- TTY   |ctx[48]<- TRDID |
    45 // ctx[33]<- CR    |ctx[41]<- DMA
    46 // ctx[34]<- SR    |ctx[42]<- NIC
    47 // ctx[35]<- BVAR  |ctx[43]<- TIM
    48 // ctx[36]<- PTAB  |ctx[44]<- HBA
    49 // ctx[37]<- LTID  |ctx[45]<- CMA
    50 // ctx[38]<- VSID  |ctx[46]<- GTID
    51 // ctx[39]<- PTPR  |ctx[47]<- RUN
     30// ctx[32]<- EPC   |ctx[40]<- TTY   |ctx[48]<- TRDID |ctx[56]<- ***
     31// ctx[33]<- CR    |ctx[41]<- FBCMA |ctx[49]<- GTID  |ctx[57]<- ***
     32// ctx[34]<- SR    |ctx[42]<- TXCMA |ctx[50]<- ***   |ctx[58]<- ***
     33// ctx[35]<- BVAR  |ctx[43]<- RXCMA |ctx[51]<- ***   |ctx[59]<- ***
     34// ctx[36]<- PTAB  |ctx[44]<- NIC   |ctx[52]<- ***   |ctx[60]<- ***
     35// ctx[37]<- LTID  |ctx[45]<- HBA   |ctx[53]<- ***   |ctx[61]<- ***
     36// ctx[38]<- VSID  |ctx[46]<- TIM   |ctx[54]<- ***   |ctx[62]<- ***
     37// ctx[39]<- PTPR  |ctx[47]<- RUN   |ctx[55]<- ***   |ctx[63]<- ***
    5238/////////////////////////////////////////////////////////////////////////////////////////
    5339
     
    5642
    5743#include <giet_config.h>
     44
     45/////////////////////////////////////////////////////////////////////////////////
     46//    Definition of the task context slots indexes
     47/////////////////////////////////////////////////////////////////////////////////
     48
     49#define CTX_SP_ID        29  // Stack Pointer
     50#define CTX_RA_ID        31  // Return Address
     51
     52#define CTX_EPC_ID       32  // Exception Program Counter (CP0)
     53#define CTX_CR_ID        33  // Cause Register (CP0)
     54#define CTX_SR_ID        34  // Status Register (CP0)
     55#define CTX_BVAR_ID      35      // Bad Virtual Address Register (CP0)
     56#define CTX_PTAB_ID      36  // Page Table Virtual address
     57#define CTX_LTID_ID      37  // Local  Task Index (in scheduler)
     58#define CTX_VSID_ID      38  // Vspace Index     
     59#define CTX_PTPR_ID      39  // Page Table Pointer Register (PADDR>>13)
     60
     61#define CTX_TTY_ID       40  // private TTY channel index 
     62#define CTX_FBCMA_ID     41  // private CMA channel index for FBF write
     63#define CTX_TXCMA_ID     42  // private CMA channel index for NIC TX
     64#define CTX_RXCMA_ID     43  // private CMA channel index for NIC RX
     65#define CTX_NIC_ID       44  // private NIC channel index
     66#define CTX_HBA_ID       45  // private HBA channel index
     67#define CTX_TIM_ID       46  // ptivate TIM channel index
     68#define CTX_RUN_ID       47  // Boolean: task runable
     69
     70#define CTX_TRDID_ID     48  // Thread Task Index in vspace
     71#define CTX_GTID_ID      49  // Global Task Index in all system
     72
     73/////////////////////////////////////////////////////////////////////////////////
    5874
    5975/////////////////////////////////////////////////////////////////////////////////
     
    7389} static_scheduler_t;
    7490
     91#define IDLE_TASK_INDEX        13
     92
    7593
    7694/////////////////////////////////////////////////////////////////////////////////
    77 //  "idle" task index and stack size definition
     95//                 Schedulers array
     96/////////////////////////////////////////////////////////////////////////////////
     97extern static_scheduler_t _scheduler[];
     98
     99/////////////////////////////////////////////////////////////////////////////////
     100//               External Functions
    78101/////////////////////////////////////////////////////////////////////////////////
    79102
    80 #define IDLE_TASK_INDEX        13
     103/////////////////////////////////////////////////////////////////////////////////
     104// This function performs a context switch between the running task
     105// and  another task, using a round-robin sheduling policy between all
     106// tasks allocated to a given processor (static allocation).
     107// It selects the next runable task to resume execution.
     108// If the only runable task is the current task, return without context switch.
     109// If there is no runable task, the scheduler switch to the default "idle" task.
     110// The return address contained in $31 is saved in the current task context
     111// (in the ctx[31] slot), and the function actually returns to the address
     112// contained in the ctx[31] slot of the next task context.
     113/////////////////////////////////////////////////////////////////////////////////
     114extern void _ctx_switch();
    81115
    82116/////////////////////////////////////////////////////////////////////////////////
    83 //    Definition of the task context slots indexes
     117// The address of this function is used to initialise the return address
     118// in the "idle" task context.
    84119/////////////////////////////////////////////////////////////////////////////////
     120extern void _ctx_eret();
    85121
    86 #define CTX_SP_ID        29  // Stack Pointer
    87 #define CTX_RA_ID        31  // Return Address
    88 
    89 #define CTX_EPC_ID       32  // Exception Program Counter (CP0)
    90 #define CTX_CR_ID        33  // Cause Register (CP0)
    91 #define CTX_SR_ID        34  // Status Register (CP0)
    92 #define CTX_BVAR_ID      35      // Bad Virtual Address Register (CP0)
    93 #define CTX_PTAB_ID      36  // Page Table Virtual address
    94 #define CTX_LTID_ID      37  // Local  Task Index (in scheduler)
    95 #define CTX_VSID_ID      38  // Vspace Index     
    96 #define CTX_PTPR_ID      39  // Page Table Pointer Register (PADDR>>13)
    97 
    98 #define CTX_TTY_ID       40  // global TTY channel   
    99 #define CTX_DMA_ID       41  // local DMA channel
    100 #define CTX_NIC_ID       42  // global NIC channel
    101 #define CTX_TIM_ID       43  // local TIMER channel
    102 #define CTX_HBA_ID       44  // global HBA channel
    103 #define CTX_CMA_ID       45  // global CMA channel
    104 #define CTX_GTID_ID      46  // Global Task Index
    105 #define CTX_RUN_ID       47  // Boolean: task runable
    106 
    107 #define CTX_TRDID_ID     48  // Thread Index in vspace
    108 
    109 //////////////////////////////////////////////////////////////////////////////////
    110 //    context switch functions
    111 //////////////////////////////////////////////////////////////////////////////////
    112 
    113 extern void _ctx_switch();
    114 extern void _ctx_eret();
     122/////////////////////////////////////////////////////////////////////////////////
     123// This function is executed task when no other task can be executed.
     124/////////////////////////////////////////////////////////////////////////////////
    115125extern void _idle_task();
    116126
    117 extern static_scheduler_t _scheduler[];
    118127
    119128#endif
Note: See TracChangeset for help on using the changeset viewer.