Changeset 237 for trunk/hal


Ignore:
Timestamp:
Jul 19, 2017, 2:57:03 PM (7 years ago)
Author:
max@…
Message:

Attach the secondary CPUs, and for now route the keyboard irq to
cpu1 - test only, but nice.

Location:
trunk/hal/x86_64/core
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/hal/x86_64/core/hal_apic.c

    r236 r237  
    425425 * Only the Spurious and APIC Timer interrupts are enabled.
    426426 */
    427 static void hal_lapic_init()
     427void cpu_lapic_init()
    428428{
    429429        if ((rdmsr(MSR_APICBASE) & APICBASE_PHYSADDR) != lapic_pa) {
     
    524524        hal_pic_init();
    525525
    526         /* Enable the LAPIC */
    527         hal_lapic_init();
    528 
    529526        /* Enable the IOAPIC */
    530527        hal_ioapic_init();
  • trunk/hal/x86_64/core/hal_apic.h

    r236 r237  
    3333
    3434uint32_t hal_lapic_gid();
     35void cpu_lapic_init();
    3536void hal_apic_init();
    3637
  • trunk/hal/x86_64/core/hal_init.c

    r236 r237  
    5050void cpu_tls_init(size_t lid);
    5151void cpu_identify();
    52 void cpu_attach();
     52void cpu_attach(size_t lid);
    5353
    5454size_t mytest __in_kdata = 0;
     
    303303void init_x86_64_cpuN()
    304304{
     305        lid_t lid = hal_lapic_gid();
     306
     307        cpu_attach(lid);
     308        x86_printf("[cpu%z] cpu_attach called\n", (uint64_t)lid);
     309
     310        cpu_tls_init(lid);
     311        x86_printf("[cpu%z] cput_tls_init called\n", (uint64_t)lid);
     312
     313        cpu_lapic_init();
     314        x86_printf("[cpu%z] cpu_lapic_init called\n", (uint64_t)lid);
     315
    305316        cpuN_booted = 1;
    306         x86_printf("-> cpu%z is alive!\n", hal_lapic_gid());
     317
     318        if (lid == 1) {
     319                hal_ioapic_disable_irq(IRQ_KEYBOARD);
     320                hal_ioapic_bind_irq(IRQ_KEYBOARD, IOAPIC_KEYBOARD_VECTOR, 1);
     321                hal_ioapic_enable_irq(IRQ_KEYBOARD);
     322        }
     323
     324        sti();
    307325        while (1);
    308326}
     
    360378
    361379        hal_apic_init();
     380        cpu_lapic_init();
    362381        x86_printf("[+] hal_apic_init called\n");
    363382
  • trunk/hal/x86_64/core/hal_interrupt.c

    r234 r237  
    3838void hal_timer_intr(hal_cpu_context_t *tf)
    3939{
    40         x86_printf("-> got timer: rip=%Z (th=%Z)\n", tf->tf_rip,
    41             hal_get_current_thread());
     40        if (hal_get_gid() != 0) {
     41                /* print the message only for cpu0 */
     42                return;
     43        }
     44        x86_printf("-> got timer: cpu%z rip=%Z (th=%Z)\n", hal_get_gid(),
     45            tf->tf_rip, hal_get_current_thread());
    4246        return;
    4347}
     
    132136        val = in8(PS2_DATA);
    133137
    134         x86_printf("-> got keyboard: rip=%Z key=%c ", tf->tf_rip, scancode_US[val]);
     138        x86_printf("-> got keyboard: cpu%z rip=%Z key=%c ", hal_get_gid(),
     139            tf->tf_rip, scancode_US[val]);
    135140
    136141        if (val & 0x80)
Note: See TracChangeset for help on using the changeset viewer.