/* init_itron --- ITRON の初期化を行う。 * */ static ER init_itron () { init_interrupt (); simple_init_console (); /* コンソールに文字を出力できるようにする */ pmem_init (); /* 物理メモリ管理機能の初期化 */ banner (); /* 立ち上げメッセージ出力 */ printf ("init_itron: start\n"); init_kalloc (); /* バイト単位のメモリ管理機能の初期化 */ init_semaphore (); /* セマフォの管理機能の初期化 */ init_msgbuf (); /* メッセージ管理機能の初期化 */ init_eventflag (); /* イベントフラグ管理機能の初期化 */ #ifdef notdef init_mpl (); /* メモリプール管理機能の初期化 */ simple_init_console (); /* コンソールに文字を出力できるようにする */ #endif init_task (); /* タスク管理機能の初期化 */ /* 1番目のタスクを初期化する。そしてそのタスクを以後の処 * 理で使用する。 */ init_task1 (); printf ("call init_timer\n"); init_timer (); /* インターバルタイマ機能の初期化 */ start_interval (); /* インターバルタイマの起動 */ init_io (); return (E_OK); }
main(void) { set_eflags(); /* Define the kernel segment registers */ set_seg_regs(__KERNEL_DS, __KERNEL_DS, INITIAL_ESP); printk("Kernel Loaded! "); /* Initialize hardware data */ setGdt(); /* Definicio de la taula de segments de memoria */ setIdt(); /* Definicio del vector de interrupcions */ setTSS(); /* Definicio de la TSS */ /* Initialize Memory */ init_mm(); /* Initialize an address space to be used for the monoprocess version of ZeOS */ /* monoprocess_init_addr_space(); TO BE DELETED WHEN ADDED THE PROCESS MANAGEMENT CODE TO BECOME MULTIPROCESS */ /* Initialize Scheduling */ init_sched(); /* Initialize idle task data */ init_idle(); /* Initialize task 1 data */ init_task1(); /* Initialize keyboard buffer */ init_keyboard_buffer(); /* Move user code/data now (after the page table initialization) */ copy_data((void *) KERNEL_START + *p_sys_size, usr_main, *p_usr_size); /* Adds this call in order to perform test suite provided by lab course */ zeos_init_auxjp(); printk("Entering user mode..."); /* * zeos_ticks must be initialized after memory initialization and just before * enabling interrupts in order to measure the correct elapsed time */ zeos_ticks = 0; enable_int(); /* * We return from a 'theorical' call to a 'call gate' to reduce our privileges * and going to execute 'magically' at 'usr_main'... */ return_gate(__USER_DS, __USER_DS, USER_ESP, __USER_CS, L_USER_START); /* The execution never arrives to this point */ return 0; }
main(void) { set_eflags(); /* Define the kernel segment registers and a stack to execute the 'main' code */ // It is necessary to use a global static array for the stack, because the // compiler will know its final memory location. Otherwise it will try to use the // 'ds' register to access the address... but we are not ready for that yet // (we are still in real mode). set_seg_regs(__KERNEL_DS, __KERNEL_DS, (DWord) &protected_tasks[5]); printk("Kernel Loaded! "); /* Initialize hardware data */ setGdt(); /* Definicio de la taula de segments de memoria */ setIdt(); /* Definicio del vector de interrupcions */ setTSS(); /* Definicio de la TSS */ /* Initialize Memory */ init_mm(); /* Initialize an address space to be used for the monoprocess version of ZeOS */ monoprocess_init_addr_space(); /* TO BE DELETED WHEN ADDED THE PROCESS MANAGEMENT CODE TO BECOME MULTIPROCESS */ /* Initialize Scheduling */ init_sched(); /* Initialize idle task data */ init_idle(); /* Initialize task 1 data */ init_task1(); /* Initialize semaphores */ init_semaphores(); /* Move user code/data now (after the page table initialization) */ copy_data((void *) KERNEL_START + *p_sys_size, usr_main, *p_usr_size); printk("Entering user mode..."); enable_int(); /* * We return from a 'theorical' call to a 'call gate' to reduce our privileges * and going to execute 'magically' at 'usr_main'... */ return_gate(__USER_DS, __USER_DS, USER_ESP, __USER_CS, L_USER_START); /* The execution never arrives to this point */ return 0; }
main(void) { set_eflags(); /* Define the kernel segment registers */ set_seg_regs(__KERNEL_DS, __KERNEL_DS, KERNEL_ESP); printk("Kernel Loaded! "); /* Initialize hardware data */ setGdt(); /* Definicio de la taula de segments de memoria */ setIdt(); /* Definicio del vector de interrupcions */ setTSS(); /* Definicio de la TSS */ /* Initialize Memory */ init_mm(); /* Initialize an address space to be used for the monoprocess version of ZeOS */ // monoprocess_init_addr_space(); /* TO BE DELETED WHEN ADDED THE PROCESS MANAGEMENT CODE TO BECOME MULTIPROCESS */ /* Initialize Scheduling */ init_sched(); /* Initialize idle task data */ init_idle(); /* Initialize task 1 data */ init_task1(); /* Move user code/data now (after the page table initialization) */ copy_data((void *) KERNEL_START + *p_sys_size, usr_main, *p_usr_size); printk("Entering user mode..."); enable_int(); /* * We return from a 'theorical' call to a 'call gate' to reduce our privileges * and going to execute 'magically' at 'usr_main'... */ return_gate(__USER_DS, __USER_DS, USER_ESP, __USER_CS, L_USER_START); /* The execution never arrives to this point */ return 0; }
int main(int argc, char *argv[]) { e_platform_t platform; e_epiphany_t device; w_mapper_t mapper; w_sa_config_t sa_config; w_list_t task1; w_core_id_t first_id, last_id; Mailbox mailbox; memset(&mailbox, 0, sizeof(mailbox)); w_init_list(&task1, 0); printf("=== Initializing system\n"); e_set_host_verbosity(H_D0); e_init(NULL); e_reset_system(); e_get_platform_info(&platform); printf("=== Creating workgroup\n"); e_open(&device, 0, 0, platform.rows, platform.cols); printf("=== Mapping device program\n"); e_reset_group(&device); // Initialize the mapping system: we will use this to automatically map our // application, to assign a device program to each core. mapper = w_create_mapper(platform.rows, platform.cols); // Tell the mapper about our application. It needs to know about allocated // tasks, constraints and faults are optional. By default the mapper assumes // no faults and no constraints. w_set_allocation_matrix(&mapper, allocation_matrix); w_set_constraint_matrix(&mapper, constraint_matrix); w_set_fault_matrix(&mapper, fault_matrix); // Find the ID of all cores allocated for task 1, and create a link between // each core. Links are used to indicate which tasks that communicate with // each other, and to minimize the distance between communicating tasks. w_find_in_matrix(&mapper.allocation_matrix, &task1, 1); connect_task1(&mapper, &task1); // Map the application using simulated annealing. This is will optimize our // poor allocation. sa_config = w_create_sa_config(); if (w_assign_sa(&mapper, &sa_config) != E_OK) { printf("ERROR: Assignment failed.\n"); return 1; } w_print_matrix(&mapper.assignment_matrix, "Assignment"); w_print_matrix(&mapper.mapping_matrix, "Mapping"); // Find the ID of all cores assigned to task 1. w_find_in_matrix(&mapper.assignment_matrix, &task1, 1); first_id = task1.elements[0]; last_id = task1.elements[task1.size - 1]; printf("=== Setting initial conditions\n"); init_task1(&device, &task1); printf("=== Loading device program\n"); // Load the device program onto all cores assigned to task 1. if (w_load(&device, &task1, "e_main.srec") != E_OK) { printf("ERROR: Unable to load device program.\n"); return 1; } printf("=== Starting device\n"); e_start_group(&device); printf("=== Starting counter\n"); mailbox.go = 1; w_write(&device, first_id, _MAILBOX_ADDRESS, &mailbox, sizeof(mailbox)); printf("=== Waiting for last core\n"); do { msleep(100); w_read(&device, last_id, _MAILBOX_ADDRESS, &mailbox, sizeof(mailbox)); } while (mailbox.done == 0); printf("Counted to %i (expected %i)\n", mailbox.counter, task1.size - 1); printf("=== Finalizing\n"); w_free_mapper(&mapper); w_free_list(&task1); e_close(&device); e_finalize(); printf("=== Done\n"); return 0; }