Rev 15 | Rev 20 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 15 | Rev 16 | ||
---|---|---|---|
Line 37... | Line 37... | ||
37 | #include <panic.h> |
37 | #include <panic.h> |
38 | #include <typedefs.h> |
38 | #include <typedefs.h> |
39 | #include <memstr.h> |
39 | #include <memstr.h> |
40 | #include <list.h> |
40 | #include <list.h> |
41 | 41 | ||
42 | cpu_private_page_t *the = NULL; |
42 | cpu_private_data_t *cpu_private_data; |
43 | - | ||
44 | cpu_t *cpus; |
43 | cpu_t *cpus; |
45 | 44 | ||
46 | void cpu_init(void) { |
45 | void cpu_init(void) { |
47 | int i, j; |
46 | int i, j; |
48 | 47 | ||
49 | #ifdef __SMP__ |
48 | #ifdef __SMP__ |
50 | if (config.cpu_active == 1) { |
49 | if (config.cpu_active == 1) { |
51 | #endif /* __SMP__ */ |
50 | #endif /* __SMP__ */ |
- | 51 | cpu_private_data = (cpu_private_data_t *) malloc(sizeof(cpu_private_data_t) * config.cpu_count); |
|
- | 52 | if (!cpu_private_data) |
|
- | 53 | panic("malloc/cpu_private_data"); |
|
- | 54 | ||
52 | cpus = (cpu_t *) malloc(sizeof(cpu_t) * config.cpu_count); |
55 | cpus = (cpu_t *) malloc(sizeof(cpu_t) * config.cpu_count); |
53 | if (!cpus) |
56 | if (!cpus) |
54 | panic("malloc/cpus"); |
57 | panic("malloc/cpus"); |
55 | 58 | ||
56 | /* initialize everything */ |
59 | /* initialize everything */ |
- | 60 | memsetb((__address) cpu_private_data, sizeof(cpu_private_data_t) * config.cpu_count, 0); |
|
57 | memsetb((__address) cpus, sizeof(cpu_t) * config.cpu_count, 0); |
61 | memsetb((__address) cpus, sizeof(cpu_t) * config.cpu_count, 0); |
58 | 62 | ||
59 | for (i=0; i < config.cpu_count; i++) { |
63 | for (i=0; i < config.cpu_count; i++) { |
60 | cpus[i].stack = (__u8 *) malloc(CPU_STACK_SIZE); |
64 | cpus[i].stack = (__u8 *) malloc(CPU_STACK_SIZE); |
61 | if (!cpus[i].stack) |
65 | if (!cpus[i].stack) |
Line 68... | Line 72... | ||
68 | #endif /* __SMP */ |
72 | #endif /* __SMP */ |
69 | 73 | ||
70 | for (j = 0; j < RQ_COUNT; j++) { |
74 | for (j = 0; j < RQ_COUNT; j++) { |
71 | list_initialize(&cpus[i].rq[j].rq_head); |
75 | list_initialize(&cpus[i].rq[j].rq_head); |
72 | } |
76 | } |
- | 77 | ||
- | 78 | cpu_private_data[i].cpu = &cpus[i]; |
|
73 | } |
79 | } |
74 | 80 | ||
75 | the = (cpu_private_page_t *) frame_alloc(FRAME_KA | FRAME_PANIC); |
- | |
76 | memsetb((__address) the, PAGE_SIZE, 0); |
- | |
77 | #ifdef __SMP__ |
81 | #ifdef __SMP__ |
78 | } |
82 | } |
79 | else { |
- | |
80 | __address frame; |
- | |
81 | - | ||
82 | frame = frame_alloc(FRAME_KA | FRAME_PANIC); |
- | |
83 | memsetb(frame, PAGE_SIZE, 0); |
- | |
84 | map_page_to_frame((__address) the, frame, PAGE_CACHEABLE, 1); |
- | |
85 | } |
- | |
86 | #endif /* __SMP__ */ |
83 | #endif /* __SMP__ */ |
87 | 84 | ||
88 | CPU = &cpus[config.cpu_active-1]; |
- | |
89 | cpu_identify(); |
85 | cpu_identify(); |
90 | cpu_arch_init(); |
86 | cpu_arch_init(); |
91 | } |
87 | } |