Changeset a83a802 in mainline
- Timestamp:
- 2005-11-23T13:28:17Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8418c7d
- Parents:
- 607c5f9
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
arch/amd64/src/amd64.c
r607c5f9 ra83a802 70 70 if (config.cpu_active == 1) { 71 71 bios_init(); 72 i8042_init(); /* a20 bit */73 72 i8259_init(); /* PIC */ 74 73 i8254_init(); /* hard clock */ … … 103 102 void arch_post_smp_init(void) 104 103 { 105 trap_virtual_enable_irqs(1<<IRQ_KBD); 104 i8042_init(); /* keyboard controller */ 106 105 } 107 106 -
arch/ia32/include/smp/apic.h
r607c5f9 ra83a802 115 115 #define IOREDTBL 0x10 116 116 117 /** Delivery modes. */ 118 #define DELMOD_FIXED 0x0 119 #define DELMOD_LOWPRI 0x1 120 #define DELMOD_SMI 0x2 121 /* 0x3 reserved */ 122 #define DELMOD_NMI 0x4 123 #define DELMOD_INIT 0x5 124 /* 0x6 reserved */ 125 #define DELMOD_EXTINT 0x7 126 127 /** Destination modes. */ 128 #define DESTMOD_PHYS 0x0 129 #define DESTMOD_LOGIC 0x1 130 131 /** Trigger Modes. */ 132 #define TRIGMOD_EDGE 0x0 133 #define TRIGMOD_LEVEL 0x1 134 135 /** Interrupt Input Pin Polarities. */ 136 #define POLARITY_HIGH 0x0 137 #define POLARITY_LOW 0x1 138 139 /** I/O Redirection Register. */ 140 struct io_redirection_reg { 141 union { 142 __u32 lo; 143 struct { 144 unsigned intvec : 8; /**< Interrupt Vector. */ 145 unsigned delmod : 3; /**< Delivery Mode. */ 146 unsigned destmod : 1; /**< Destination mode. */ 147 unsigned delivs : 1; /**< Delivery status (RO). */ 148 unsigned intpol : 1; /**< Interrupt Input Pin Polarity. */ 149 unsigned irr : 1; /**< Remote IRR (RO). */ 150 unsigned trigger_mode : 1; /**< Trigger Mode. */ 151 unsigned masked : 1; /**< Interrupt Mask. */ 152 unsigned : 15; /**< Reserved. */ 153 }; 154 }; 155 union { 156 __u32 hi; 157 struct { 158 unsigned : 24; /**< Reserved. */ 159 unsigned dest : 8; /**< Destination Field. */ 160 }; 161 }; 162 163 } __attribute__ ((packed)); 164 165 typedef struct io_redirection_reg io_redirection_reg_t; 117 166 118 167 extern volatile __u32 *l_apic; -
arch/ia32/include/smp/mps.h
r607c5f9 ra83a802 121 121 extern struct smp_config_operations mps_config_operations; 122 122 123 extern int mps_irq_to_pin(int irq);124 125 123 extern void mps_init(void); 126 124 extern void kmp(void *arg); -
arch/ia32/include/smp/smp.h
r607c5f9 ra83a802 33 33 #include <typedefs.h> 34 34 35 /** SMP config opertaions interface. */ 35 36 struct smp_config_operations { 36 count_t (* cpu_count)(void); 37 bool (* cpu_enabled)(index_t i); 38 bool (*cpu_bootstrap)(index_t i); 39 __u8 (*cpu_apic_id)(index_t i); 37 count_t (* cpu_count)(void); /**< Return number of detected processors. */ 38 bool (* cpu_enabled)(index_t i); /**< Check whether the processor of index i is enabled. */ 39 bool (*cpu_bootstrap)(index_t i); /**< Check whether the processor of index i is BSP. */ 40 __u8 (*cpu_apic_id)(index_t i); /**< Return APIC ID of the processor of index i. */ 41 int (*irq_to_pin)(int irq); /**< Return mapping between irq and APIC pin. */ 40 42 }; 41 43 44 extern int smp_irq_to_pin(int irq); 45 42 46 #endif -
arch/ia32/src/drivers/i8042.c
r607c5f9 ra83a802 43 43 * It takes care of low-level keyboard functions. 44 44 */ 45 46 #define i8042_DATA 0x60 47 #define i8042_STATUS 0x64 48 49 /** Keyboard commands. */ 50 #define KBD_ENABLE 0xf4 51 #define KBD_DISABLE 0xf5 52 #define KBD_ACK 0xfa 45 53 46 54 #define SPECIAL '?' … … 231 239 { 232 240 trap_register(VECTOR_KBD, i8042_interrupt); 241 trap_virtual_enable_irqs(1<<IRQ_KBD); 233 242 spinlock_initialize(&keylock); 234 243 chardev_initialize(&kbrd, &ops); … … 246 255 247 256 trap_virtual_eoi(); 248 x = inb( 0x60);257 x = inb(i8042_DATA); 249 258 if (x & KEY_RELEASE) 250 259 key_released(x ^ KEY_RELEASE); -
arch/ia32/src/ia32.c
r607c5f9 ra83a802 57 57 if (config.cpu_active == 1) { 58 58 bios_init(); 59 i8042_init(); /* keyboard controller */60 59 i8259_init(); /* PIC */ 61 60 i8254_init(); /* hard clock */ … … 90 89 void arch_post_smp_init(void) 91 90 { 92 trap_virtual_enable_irqs(1<<IRQ_KBD);91 i8042_init(); /* keyboard controller */ 93 92 } 94 93 -
arch/ia32/src/smp/apic.c
r607c5f9 ra83a802 41 41 42 42 /* 43 * This is functional, far-from-general-enough interface to the APIC. 44 * Advanced Programmable Interrupt Controller for MP systems. 43 * Advanced Programmable Interrupt Controller for SMP systems. 45 44 * Tested on: 46 45 * Bochs 2.0.2 - Bochs 2.2 with 2-8 CPUs … … 83 82 io_apic_disable_irqs(0xffff); 84 83 trap_register(VECTOR_CLK, l_apic_timer_interrupt); 85 for (i= 1; i<16; i++) {84 for (i=0; i<16; i++) { 86 85 int pin; 87 86 88 if ((pin = mps_irq_to_pin(i)) != -1) 89 io_apic_change_ioredtbl(pin,0xf,IVT_IRQBASE+i,LOPRI); 87 if ((pin = smp_irq_to_pin(i)) != -1) { 88 io_apic_change_ioredtbl(pin,0xff,IVT_IRQBASE+i,LOPRI); 89 } 90 90 } 91 91 … … 353 353 void io_apic_change_ioredtbl(int signal, int dest, __u8 v, int flags) 354 354 { 355 __u32 reglo, reghi;355 io_redirection_reg_t reg; 356 356 int dlvr = 0; 357 357 358 358 if (flags & LOPRI) 359 dlvr = 1; 360 361 reglo = io_apic_read(IOREDTBL + signal*2); 362 reghi = io_apic_read(IOREDTBL + signal*2 + 1); 363 364 reghi &= ~0x0f000000; 365 reghi |= (dest<<24); 366 367 reglo &= (~0x1ffff) | (1<<16); /* don't touch the mask */ 368 reglo |= (0<<15) | (0<<13) | (0<<11) | (dlvr<<8) | v; 369 370 io_apic_write(IOREDTBL + signal*2, reglo); 371 io_apic_write(IOREDTBL + signal*2 + 1, reghi); 359 dlvr = DELMOD_LOWPRI; 360 361 362 reg.lo = io_apic_read(IOREDTBL + signal*2); 363 reg.hi = io_apic_read(IOREDTBL + signal*2 + 1); 364 365 reg.dest = dest; 366 reg.destmod = DESTMOD_LOGIC; 367 reg.trigger_mode = TRIGMOD_EDGE; 368 reg.intpol = POLARITY_HIGH; 369 reg.delmod = dlvr; 370 reg.intvec = v; 371 372 io_apic_write(IOREDTBL + signal*2, reg.lo); 373 io_apic_write(IOREDTBL + signal*2 + 1, reg.hi); 372 374 } 373 375 374 376 void io_apic_disable_irqs(__u16 irqmask) 375 377 { 376 i nt i,pin;377 __u32 reglo;378 io_redirection_reg_t reg; 379 int i, pin; 378 380 379 381 for (i=0;i<16;i++) { … … 383 385 * mapping for the respective IRQ number. 384 386 */ 385 pin = mps_irq_to_pin(i);387 pin = smp_irq_to_pin(i); 386 388 if (pin != -1) { 387 reg lo = io_apic_read(IOREDTBL + pin*2);388 reg lo |= (1<<16);389 io_apic_write(IOREDTBL + pin*2, reglo);389 reg.lo = io_apic_read(IOREDTBL + pin*2); 390 reg.masked = true; 391 io_apic_write(IOREDTBL + pin*2, reg.lo); 390 392 } 391 393 … … 396 398 void io_apic_enable_irqs(__u16 irqmask) 397 399 { 398 int i, pin;399 __u32 reglo;400 int i, pin; 401 io_redirection_reg_t reg; 400 402 401 403 for (i=0;i<16;i++) { … … 405 407 * mapping for the respective IRQ number. 406 408 */ 407 pin = mps_irq_to_pin(i);409 pin = smp_irq_to_pin(i); 408 410 if (pin != -1) { 409 reg lo = io_apic_read(IOREDTBL + pin*2);410 reg lo &= ~(1<<16);411 io_apic_write(IOREDTBL + pin*2, reglo);411 reg.lo = io_apic_read(IOREDTBL + pin*2); 412 reg.masked = false; 413 io_apic_write(IOREDTBL + pin*2, reg.lo); 412 414 } 413 415 -
arch/ia32/src/smp/mps.c
r607c5f9 ra83a802 90 90 static bool is_bsp(index_t i); 91 91 static __u8 get_cpu_apic_id(index_t i); 92 static int mps_irq_to_pin(int irq); 92 93 93 94 struct smp_config_operations mps_config_operations = { … … 95 96 .cpu_enabled = is_cpu_enabled, 96 97 .cpu_bootstrap = is_bsp, 97 .cpu_apic_id = get_cpu_apic_id 98 .cpu_apic_id = get_cpu_apic_id, 99 .irq_to_pin = mps_irq_to_pin 98 100 }; 99 101 -
arch/ia32/src/smp/smp.c
r607c5f9 ra83a802 166 166 } 167 167 168 int smp_irq_to_pin(int irq) 169 { 170 ASSERT(ops != NULL); 171 return ops->irq_to_pin(irq); 172 } 173 168 174 #endif /* CONFIG_SMP */ -
genarch/src/acpi/matd.c
r607c5f9 ra83a802 45 45 #ifdef CONFIG_SMP 46 46 47 /** Standard ISA IRQ map; can be overriden by Interrupt Source Override entries of MADT. */ 48 int isa_irq_map[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; 49 47 50 static void madt_l_apic_entry(struct madt_l_apic *la, __u32 index); 48 51 static void madt_io_apic_entry(struct madt_io_apic *ioa, __u32 index); 52 static void madt_intr_src_ovrd_entry(struct madt_intr_src_ovrd *override, __u32 index); 49 53 static int madt_cmp(void * a, void * b); 50 54 … … 80 84 static bool madt_cpu_bootstrap(index_t i); 81 85 static __u8 madt_cpu_apic_id(index_t i); 86 static int madt_irq_to_pin(int irq); 82 87 83 88 struct smp_config_operations madt_config_operations = { … … 85 90 .cpu_enabled = madt_cpu_enabled, 86 91 .cpu_bootstrap = madt_cpu_bootstrap, 87 .cpu_apic_id = madt_cpu_apic_id 92 .cpu_apic_id = madt_cpu_apic_id, 93 .irq_to_pin = madt_irq_to_pin 88 94 }; 89 95 90 staticcount_t madt_cpu_count(void)96 count_t madt_cpu_count(void) 91 97 { 92 98 return madt_l_apic_entry_cnt; 93 99 } 94 100 95 staticbool madt_cpu_enabled(index_t i)101 bool madt_cpu_enabled(index_t i) 96 102 { 97 103 ASSERT(i < madt_l_apic_entry_cnt); … … 100 106 } 101 107 102 staticbool madt_cpu_bootstrap(index_t i)108 bool madt_cpu_bootstrap(index_t i) 103 109 { 104 110 ASSERT(i < madt_l_apic_entry_cnt); … … 106 112 } 107 113 108 static__u8 madt_cpu_apic_id(index_t i)114 __u8 madt_cpu_apic_id(index_t i) 109 115 { 110 116 ASSERT(i < madt_l_apic_entry_cnt); 111 117 return ((struct madt_l_apic *) madt_entries_index[madt_l_apic_entry_index + i])->apic_id; 118 } 119 120 int madt_irq_to_pin(int irq) 121 { 122 ASSERT(irq < sizeof(isa_irq_map)/sizeof(int)); 123 return isa_irq_map[irq]; 112 124 } 113 125 … … 155 167 break; 156 168 case MADT_INTR_SRC_OVRD: 169 madt_intr_src_ovrd_entry((struct madt_intr_src_ovrd *) h, index); 170 break; 157 171 case MADT_NMI_SRC: 158 172 case MADT_L_APIC_NMI: … … 210 224 } 211 225 226 void madt_intr_src_ovrd_entry(struct madt_intr_src_ovrd *override, __u32 index) 227 { 228 ASSERT(override->source < sizeof(isa_irq_map)/sizeof(int)); 229 printf("Remapping irq%d to IO APIC pin%d\n", override->source, override->global_intr); 230 isa_irq_map[override->source] = override->global_intr; 231 232 } 212 233 213 234 #endif /* CONFIG_SMP */ -
generic/src/main/kconsole.c
r607c5f9 ra83a802 50 50 printf("%s> ", __FUNCTION__); 51 51 gets(stdin, buf, sizeof(buf)); 52 printf("?\n"); 52 53 } 53 54 } -
generic/src/main/kinit.c
r607c5f9 ra83a802 118 118 119 119 /* 120 * At this point SMP, if present, is configured. 121 */ 122 arch_post_smp_init(); 123 124 /* 120 125 * Create kernel console. 121 126 */ … … 165 170 166 171 while (1) { 167 thread_sleep( 60);172 thread_sleep(1); 168 173 printf("kinit... "); 169 174 } -
generic/src/main/main.c
r607c5f9 ra83a802 171 171 arch_pre_smp_init(); 172 172 smp_init(); 173 arch_post_smp_init();174 173 printf("config.memory_size=%dM\n", config.memory_size/(1024*1024)); 175 174 printf("config.cpu_count=%d\n", config.cpu_count);
Note:
See TracChangeset
for help on using the changeset viewer.