void ke_init(void) { uint32_t endian = 0x44332211; unsigned char *pendian = (unsigned char *) &endian; /* Endian check */ if (pendian[0] != 0x11 || pendian[3] != 0x44) fatal("cannot run kernel on a big endian machine"); isa_init(); ke = calloc(1, sizeof(struct kernel_t)); ke->current_pid = 1000; /* Initial assigned pid */ /* Initialize mutex for variables controlling calls to 'ke_process_events()' */ pthread_mutex_init(&ke->process_events_mutex, NULL); /* Debug categories */ isa_inst_debug_category = debug_new_category(); isa_call_debug_category = debug_new_category(); elf_debug_category = debug_new_category(); ld_debug_category = debug_new_category(); syscall_debug_category = debug_new_category(); ctx_debug_category = debug_new_category(); /* Initialize GPU kernel */ gk_init(); /* Record start time */ ke_init_time = ke_timer(); }
void __init pcibios_init(void) { pci_controller_probe(); if (pci_controller_root == NULL) return; pci_scan_each_controller_bus(); if (pci_device_reorder) pci_reorder_devs(); isa_init(); ebus_init(); rs_init(); clock_probe(); power_init(); }
u_int initarm(void *arg) { ofw_handle_t ofw_handle = arg; paddr_t pclean; vaddr_t isa_io_virtaddr, isa_mem_virtaddr; paddr_t isadmaphysbufs; extern char shark_fiq[], shark_fiq_end[]; /* Don't want to get hit with interrupts 'til we're ready. */ (void)disable_interrupts(I32_bit | F32_bit); set_cpufuncs(); /* XXX - set these somewhere else? -JJK */ boothowto = 0; /* Init the OFW interface. */ /* MUST do this before invoking any OFW client services! */ ofw_init(ofw_handle); /* Configure ISA stuff: must be done before consinit */ ofw_configisa(&isa_io_physaddr, &isa_mem_physaddr); /* Map-in ISA I/O and memory space. */ /* XXX - this should be done in the isa-bus attach routine! -JJK */ isa_mem_virtaddr = ofw_map(isa_mem_physaddr, L1_S_SIZE, 0); isa_io_virtaddr = ofw_map(isa_io_physaddr, L1_S_SIZE, 0); /* Set-up the ISA system: must be done before consinit */ isa_init(isa_io_virtaddr, isa_mem_virtaddr); /* Initialize the console (which will call into OFW). */ /* This will allow us to see panic messages and other printf output. */ consinit(); /* Get boot info and process it. */ ofw_getbootinfo(&boot_file, &boot_args); process_kernel_args(); ofw_configisadma(&isadmaphysbufs); #if (NISADMA > 0) isa_dma_init(); #endif /* allocate a cache clean space */ if ((pclean = ofw_getcleaninfo()) != -1) { sa1_cache_clean_addr = ofw_map(pclean, 0x4000 * 2, L2_B | L2_C); sa1_cache_clean_size = 0x4000; } /* Configure memory. */ ofw_configmem(); /* * Set-up stacks. * The kernel stack for SVC mode will be updated on return * from this routine. */ set_stackptr(PSR_IRQ32_MODE, irqstack.pv_va + PAGE_SIZE); set_stackptr(PSR_UND32_MODE, undstack.pv_va + PAGE_SIZE); set_stackptr(PSR_ABT32_MODE, abtstack.pv_va + PAGE_SIZE); /* Set-up exception handlers. */ /* * Take control of selected vectors from OFW. * We take: undefined, swi, pre-fetch abort, data abort, addrexc, * irq, fiq * OFW retains: reset */ arm32_vector_init(ARM_VECTORS_LOW, ARM_VEC_ALL & ~ARM_VEC_RESET); data_abort_handler_address = (u_int)data_abort_handler; prefetch_abort_handler_address = (u_int)prefetch_abort_handler; undefined_handler_address = (u_int)undefinedinstruction_bounce; /* why is this needed? -JJK */ /* Initialise the undefined instruction handlers. */ undefined_init(); /* Now for the SHARK-specific part of the FIQ set-up */ shark_fiqhandler.fh_func = shark_fiq; shark_fiqhandler.fh_size = shark_fiq_end - shark_fiq; shark_fiqhandler.fh_flags = 0; shark_fiqhandler.fh_regs = &shark_fiqregs; shark_fiqregs.fr_r8 = isa_io_virtaddr; shark_fiqregs.fr_r9 = 0; /* no routine right now */ shark_fiqregs.fr_r10 = 0; /* no arg right now */ shark_fiqregs.fr_r11 = 0; /* scratch */ shark_fiqregs.fr_r12 = 0; /* scratch */ shark_fiqregs.fr_r13 = 0; /* must set a stack when r9 is set! */ if (fiq_claim(&shark_fiqhandler)) panic("Cannot claim FIQ vector."); #if NKSYMS || defined(DDB) || defined(MODULAR) #ifndef __ELF__ { struct exec *kernexec = (struct exec *)KERNEL_TEXT_BASE; extern int end; extern char *esym; ksyms_addsyms_elf(kernexec->a_syms, &end, esym); } #endif /* __ELF__ */ #endif /* NKSYMS || defined(DDB) || defined(MODULAR) */ #ifdef DDB db_machine_init(); if (boothowto & RB_KDB) Debugger(); #endif /* Return the new stackbase. */ return(kernelstack.pv_va + USPACE_SVC_STACK_TOP); }
void Task1() { uint8_t j, i; uint8_t length,slot; uint8_t *local_rx_buf; uint32_t Score = 0; int8_t rssi; uint8_t cnt=0; //uint8_t tx[3]={2,15,16}; //uint8_t rx[3]={3,18,19}; //uint8_t my_tx_slot[4]; char c = -1; nrk_sig_t uart_rx_signal; uint8_t finished = 0; printf( "Task1 PID=%d\r\n",nrk_get_pid()); nrk_led_set(RED_LED); isa_set_channel_pattern(1); isa_init (ISA_REPEATER, MY_ID, MY_ID);//change isa_set_schedule(ISA_REPEATER, MY_CLK_SRC_ID); isa_set_channel(MY_CHANNEL); isa_start(); isa_rx_pkt_set_buffer(rx_buf, RF_MAX_PAYLOAD_SIZE); while(!isa_ready()) nrk_wait_until_next_period(); /*while(isa_join_ready()!=1) nrk_wait_until_next_period(); for(i=0;i<4;i++){ // set tx slots if(tx_slot_from_join[i]==0) break; else my_tx_slot[i]=tx_slot_from_join[i]; } printf("MAIN_TX:%d\r\n",my_tx_slot[0]);*/ printf("isa start!\n\r"); //i=0; while(1){ //nrk_gpio_toggle(NRK_DEBUG_0); if( isa_rx_pkt_check()!=0 ) { local_rx_buf=isa_rx_pkt_get(&length, &rssi); //printf("length is %d, rssi is %d.\n\r",length,rssi); //local_rx_buf[PKT_DATA_START+length-2]='\0'; //printf("RX[%d]",slot); /*for(i=PKT_DATA_START; i<length-1; i++ ) printf( "%c",local_rx_buf[i]);*/ //printf("\r\n"); //sprintf( &tx_buf[PKT_DATA_START],"Hello Mingzhe!"); //length=strlen(&tx_buf[PKT_DATA_START])+PKT_DATA_START+1; //isa_tx_pkt(tx_buf,length,configDHDR(),MY_TX_SLOT); /* length=strlen(&rx_buf[PKT_DATA_START])+PKT_DATA_START+1; //change isa_tx_pkt(rx_buf,length,configDHDR(),MY_TX_SLOT1);//change forward the message from recipient */ //printf(" Forward message is sent.\n\r"); //printf("pkt length:%d",length); //printf("%d\r\n",cnt++); // printf( "%c",local_rx_buf[PKT_DATA_START]); isa_rx_pkt_release(); // printf("\r\n"); } if(isa_tx_pkt_check(MY_TX_SLOT)!=0){ // printf("Pending TX\r\n"); } else{ /*sprintf( &tx_buf[PKT_DATA_START],local_rx_buf+PKT_DATA_START); length=strlen(&rx_buf[PKT_DATA_START])+PKT_DATA_START+1; //change //isa_tx_pkt(rx_buf,length,configDHDR(),my_tx_slot[0]);//change forward the message from recipient isa_tx_pkt(rx_buf,length,configDHDR(),MY_TX_SLOT); isa_wait_until_rx_or_tx ();*/ sprintf( &tx_buf[PKT_DATA_START],"2"); length=strlen(&tx_buf[PKT_DATA_START])+PKT_DATA_START+1; isa_tx_pkt(tx_buf,length,configDHDR(),MY_TX_SLOT); isa_wait_until_rx_or_tx (); putchar('\n'); putchar('\r'); /*sprintf( &tx_buf2[PKT_DATA_START],"Hello from slot 2!"); length=strlen(&tx_buf2[PKT_DATA_START])+PKT_DATA_START+1; isa_tx_pkt(tx_buf2,length,configDHDR(),2); isa_wait_until_rx_or_tx ();*/ } } }