Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void hilevel_handler_rst( ctx_t* ctx ) {
- /* Initialise PCBs representing processes stemming from execution of
- * the two user programs. Note in each case that
- *
- * - the CPSR value of 0x50 means the processor is switched into USR
- * mode, with IRQ interrupts enabled, and
- * - the PC and SP values matche the entry point and top of stack.
- */
- TIMER0->Timer1Load = 0x00100000; // select period = 2^20 ticks ~= 1 sec
- TIMER0->Timer1Ctrl = 0x00000002; // select 32-bit timer
- TIMER0->Timer1Ctrl |= 0x00000040; // select periodic timer
- TIMER0->Timer1Ctrl |= 0x00000020; // enable timer interrupt
- TIMER0->Timer1Ctrl |= 0x00000080; // enable timer
- GICC0->PMR = 0x000000F0; // unmask all interrupts
- GICD0->ISENABLER1 |= 0x00000010; // enable timer interrupt
- GICC0->CTLR = 0x00000001; // enable GIC interface
- GICD0->CTLR = 0x00000001; // enable GIC distributor
- int_enable_irq();
- memset( &pcb[ 0 ], 0, sizeof( pcb_t ) );
- pcb[ 0 ].pid = 1;
- pcb[ 0 ].ctx.cpsr = 0x50;
- pcb[ 0 ].ctx.pc = ( uint32_t )( &main_P1 );
- pcb[ 0 ].ctx.sp = ( uint32_t )( &tos_P1 );
- memset( &pcb[ 1 ], 0, sizeof( pcb_t ) );
- pcb[ 1 ].pid = 2;
- pcb[ 1 ].ctx.cpsr = 0x50;
- pcb[ 1 ].ctx.pc = ( uint32_t )( &main_P2 );
- pcb[ 1 ].ctx.sp = ( uint32_t )( &tos_P2 );
- /* Once the PCBs are initialised, we (arbitrarily) select one to be
- * restored (i.e., executed) when the function then returns.
- */
- current = &pcb[ 0 ]; memcpy( ctx, ¤t->ctx, sizeof( ctx_t ) );
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement