Changes in kernel/generic/src/cpu/cpu.c [9dae191e:e3ee9b9] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/cpu/cpu.c
r9dae191e re3ee9b9 33 33 /** 34 34 * @file 35 * @brief 35 * @brief CPU subsystem initialization and listing. 36 36 */ 37 37 38 38 #include <cpu.h> 39 39 #include <arch.h> … … 49 49 #include <print.h> 50 50 #include <sysinfo/sysinfo.h> 51 #include <arch/cycle.h> 51 52 52 53 cpu_t *cpus; … … 58 59 */ 59 60 void cpu_init(void) { 60 unsigned int i, j;61 62 61 #ifdef CONFIG_SMP 63 62 if (config.cpu_active == 1) { 64 63 #endif /* CONFIG_SMP */ 64 65 65 cpus = (cpu_t *) malloc(sizeof(cpu_t) * config.cpu_count, 66 66 FRAME_ATOMIC); 67 67 if (!cpus) 68 68 panic("Cannot allocate CPU structures."); 69 70 /* initialize everything */69 70 /* Initialize everything */ 71 71 memsetb(cpus, sizeof(cpu_t) * config.cpu_count, 0); 72 72 73 size_t i; 73 74 for (i = 0; i < config.cpu_count; i++) { 74 cpus[i].stack = (uint8_t *) frame_alloc(STACK_FRAMES, FRAME_KA | FRAME_ATOMIC);75 75 cpus[i].stack = (uint8_t *) frame_alloc(STACK_FRAMES, 76 FRAME_KA | FRAME_ATOMIC); 76 77 cpus[i].id = i; 77 78 78 spinlock_initialize(&cpus[i].lock, "cpu_t.lock"); 79 79 irq_spinlock_initialize(&cpus[i].lock, "cpus[].lock"); 80 81 unsigned int j; 80 82 for (j = 0; j < RQ_COUNT; j++) { 81 spinlock_initialize(&cpus[i].rq[j].lock, "rq_t.lock");83 irq_spinlock_initialize(&cpus[i].rq[j].lock, "cpus[].rq[].lock"); 82 84 list_initialize(&cpus[i].rq[j].rq_head); 83 85 } … … 87 89 } 88 90 #endif /* CONFIG_SMP */ 89 91 90 92 CPU = &cpus[config.cpu_active - 1]; 91 93 92 CPU->active = 1; 93 CPU->tlb_active = 1; 94 CPU->active = true; 95 CPU->tlb_active = true; 96 97 CPU->idle = false; 98 CPU->last_cycle = get_cycle(); 99 CPU->idle_cycles = 0; 100 CPU->busy_cycles = 0; 94 101 95 102 cpu_identify(); … … 100 107 void cpu_list(void) 101 108 { 102 unsigned int i;103 109 size_t i; 110 104 111 for (i = 0; i < config.cpu_count; i++) { 105 112 if (cpus[i].active) … … 112 119 /** @} 113 120 */ 114
Note:
See TracChangeset
for help on using the changeset viewer.