static int kdb_check_kbd_exists(void) { static int kbd_exists = -1; /* One time init */ if (kbd_exists == -1) { if (KDB_FLAG(NO_I8042) || KDB_FLAG(NO_VT_CONSOLE) || (kbd_read_status() == 0xff && kbd_read_input() == 0xff)) kbd_exists = 0; else kbd_exists = 1; } return kbd_exists; }
/* * Check if the keyboard controller has a keypress for us. * Some parts (Enter Release, LED change) are still blocking polled here, * but hopefully they are all short. */ static int get_kbd_char(void) { int scancode, scanstatus; static int shift_lock; /* CAPS LOCK state (0-off, 1-on) */ static int shift_key; /* Shift next keypress */ static int ctrl_key; u_short keychar; extern u_short plain_map[], shift_map[], ctrl_map[]; if (KDB_FLAG(NO_I8042) || KDB_FLAG(NO_VT_CONSOLE) || (inb(KBD_STATUS_REG) == 0xff && inb(KBD_DATA_REG) == 0xff)) { kbd_exists = 0; return -1; } kbd_exists = 1; if ((inb(KBD_STATUS_REG) & KBD_STAT_OBF) == 0) return -1; /* * Fetch the scancode */ scancode = inb(KBD_DATA_REG); scanstatus = inb(KBD_STATUS_REG); /* * Ignore mouse events. */ if (scanstatus & KBD_STAT_MOUSE_OBF) return -1; /* * Ignore release, trigger on make * (except for shift keys, where we want to * keep the shift state so long as the key is * held down). */ if (((scancode&0x7f) == 0x2a) || ((scancode&0x7f) == 0x36)) { /* * Next key may use shift table */ if ((scancode & 0x80) == 0) { shift_key=1; } else { shift_key=0; } return -1; } if ((scancode&0x7f) == 0x1d) { /* * Left ctrl key */ if ((scancode & 0x80) == 0) { ctrl_key = 1; } else { ctrl_key = 0; } return -1; } if ((scancode & 0x80) != 0) return -1; scancode &= 0x7f; /* * Translate scancode */ if (scancode == 0x3a) { /* * Toggle caps lock */ shift_lock ^= 1; #ifdef KDB_BLINK_LED kdb_toggleled(0x4); #endif return -1; } if (scancode == 0x0e) { /* * Backspace */ return 8; } /* Special Key */ switch (scancode) { case 0xF: /* Tab */ return 9; case 0x53: /* Del */ return 4; case 0x47: /* Home */ return 1; case 0x4F: /* End */ return 5; case 0x4B: /* Left */ return 2; case 0x48: /* Up */ return 16; case 0x50: /* Down */ return 14; case 0x4D: /* Right */ return 6; } if (scancode == 0xe0) { return -1; } /* * For Japanese 86/106 keyboards * See comment in drivers/char/pc_keyb.c. * - Masahiro Adegawa */ if (scancode == 0x73) { scancode = 0x59; } else if (scancode == 0x7d) { scancode = 0x7c; } if (!shift_lock && !shift_key && !ctrl_key) { keychar = plain_map[scancode]; } else if (shift_lock || shift_key) { keychar = shift_map[scancode]; } else if (ctrl_key) { keychar = ctrl_map[scancode]; } else { keychar = 0x0020; kdb_printf("Unknown state/scancode (%d)\n", scancode); } keychar &= 0x0fff; if (keychar == '\t') keychar = ' '; switch (KTYP(keychar)) { case KT_LETTER: case KT_LATIN: if (isprint(keychar)) break; /* printable characters */ /* drop through */ case KT_SPEC: if (keychar == K_ENTER) break; /* drop through */ default: return(-1); /* ignore unprintables */ } if ((scancode & 0x7f) == 0x1c) { /* * enter key. All done. Absorb the release scancode. */ while ((inb(KBD_STATUS_REG) & KBD_STAT_OBF) == 0) ; /* * Fetch the scancode */ scancode = inb(KBD_DATA_REG); scanstatus = inb(KBD_STATUS_REG); while (scanstatus & KBD_STAT_MOUSE_OBF) { scancode = inb(KBD_DATA_REG); scanstatus = inb(KBD_STATUS_REG); } if (scancode != 0x9c) { /* * Wasn't an enter-release, why not? */ kdb_printf("kdb: expected enter got 0x%x status 0x%x\n", scancode, scanstatus); } kdb_printf("\n"); return 13; } return keychar & 0xff; }
asmlinkage void __init start_kernel(void) { char * command_line; extern struct kernel_param __start___param[], __stop___param[]; smp_setup_processor_id(); /* * Need to run as early as possible, to initialize the * lockdep hash: */ unwind_init(); lockdep_init(); local_irq_disable(); early_boot_irqs_off(); early_init_irq_lock_class(); /* * Interrupts are still disabled. Do necessary setups, then * enable them */ lock_kernel(); tick_init(); boot_cpu_init(); page_address_init(); printk(KERN_NOTICE); printk(linux_banner); setup_arch(&command_line); setup_command_line(command_line); unwind_setup(); setup_per_cpu_areas(); smp_prepare_boot_cpu(); /* arch-specific boot-cpu hooks */ /* * Set up the scheduler prior starting any interrupts (such as the * timer interrupt). Full topology setup happens at smp_init() * time - but meanwhile we still have a functioning scheduler. */ sched_init(); /* * Disable preemption - early bootup scheduling is extremely * fragile until we cpu_idle() for the first time. */ preempt_disable(); build_all_zonelists(); page_alloc_init(); printk(KERN_NOTICE "Kernel command line: %s\n", boot_command_line); parse_early_param(); parse_args("Booting kernel", static_command_line, __start___param, __stop___param - __start___param, &unknown_bootoption); if (!irqs_disabled()) { printk(KERN_WARNING "start_kernel(): bug: interrupts were " "enabled *very* early, fixing it\n"); local_irq_disable(); } sort_main_extable(); trap_init(); rcu_init(); init_IRQ(); pidhash_init(); init_timers(); hrtimers_init(); softirq_init(); timekeeping_init(); time_init(); profile_init(); if (!irqs_disabled()) printk("start_kernel(): bug: interrupts were enabled early\n"); early_boot_irqs_on(); local_irq_enable(); /* * HACK ALERT! This is early. We're enabling the console before * we've done PCI setups etc, and console_init() must be aware of * this. But we do want output early, in case something goes wrong. */ console_init(); if (panic_later) panic(panic_later, panic_param); lockdep_info(); /* * Need to run this when irqs are enabled, because it wants * to self-test [hard/soft]-irqs on/off lock inversion bugs * too: */ locking_selftest(); #ifdef CONFIG_BLK_DEV_INITRD if (initrd_start && !initrd_below_start_ok && initrd_start < min_low_pfn << PAGE_SHIFT) { printk(KERN_CRIT "initrd overwritten (0x%08lx < 0x%08lx) - " "disabling it.\n",initrd_start,min_low_pfn << PAGE_SHIFT); initrd_start = 0; } #endif vfs_caches_init_early(); cpuset_init_early(); mem_init(); kmem_cache_init(); setup_per_cpu_pageset(); numa_policy_init(); if (late_time_init) late_time_init(); calibrate_delay(); if(print_me) { printk("HELLO AND WELCOME TO THE WORLD OF TOMORROW!\n"); } pidmap_init(); pgtable_cache_init(); prio_tree_init(); anon_vma_init(); #ifdef CONFIG_KDB kdb_init(); if (KDB_FLAG(EARLYKDB)) { KDB_ENTER(); } #endif /* CONFIG_KDB */ #ifdef CONFIG_X86 if (efi_enabled) efi_enter_virtual_mode(); #endif fork_init(num_physpages); proc_caches_init(); buffer_init(); unnamed_dev_init(); key_init(); security_init(); vfs_caches_init(num_physpages); radix_tree_init(); signals_init(); /* rootfs populating might need page-writeback */ page_writeback_init(); #ifdef CONFIG_PROC_FS proc_root_init(); #endif cpuset_init(); taskstats_init_early(); delayacct_init(); check_bugs(); acpi_early_init(); /* before LAPIC and SMP init */ /* Do the rest non-__init'ed, we're now alive */ rest_init(); }
void smp_kdb_stop(void) { if (!KDB_FLAG(NOIPI)) send_IPI_allbutself(KDB_VECTOR); }