/** * keyboard_read() will invoke this routine after having recognized a key press. * * @param tty The key press is for whom. * @param key The integer key with metadata. *****************************************************************************/ PUBLIC void in_process(TTY* tty, u32 key) { if (!(key & FLAG_EXT)) { put_key(tty, key); } else { int raw_code = key & MASK_RAW; switch(raw_code) { case ENTER: put_key(tty, '\n'); break; case BACKSPACE: put_key(tty, '\b'); break; case UP: if ((key & FLAG_SHIFT_L) || (key & FLAG_SHIFT_R)) { /* Shift + Up */ scroll_screen(tty->console, SCR_DN); } break; case DOWN: if ((key & FLAG_SHIFT_L) || (key & FLAG_SHIFT_R)) { /* Shift + Down */ scroll_screen(tty->console, SCR_UP); } break; case RIGHT: if ((key & FLAG_SHIFT_L) || (key & FLAG_SHIFT_R)) { /* Shift + Right */ select_console(current_console+1); } break; case LEFT: if ((key & FLAG_SHIFT_L) || (key & FLAG_SHIFT_R)) { /* Shift + Left */ select_console(current_console-1); } break; case F1: case F2: case F3: case F4: case F5: case F6: case F7: case F8: case F9: case F10: case F11: case F12: if ((key & FLAG_ALT_L) || (key & FLAG_ALT_R)) { /* Alt + F1~F12 */ select_console(raw_code - F1); } break; default: break; } } }
/*======================================================================* in_process *======================================================================*/ PUBLIC void in_process(TTY* p_tty, t_32 key) { if (!(key & FLAG_EXT)) { put_key(p_tty, key); } else { int raw_code = key & MASK_RAW; switch(raw_code) { case ENTER: put_key(p_tty, '\n'); break; case BACKSPACE: put_key(p_tty, '\b'); break; case UP: if ((key & FLAG_SHIFT_L) || (key & FLAG_SHIFT_R)) { /* Shift + Up */ scroll_screen(p_tty->p_console, SCROLL_SCREEN_UP); } break; case DOWN: if ((key & FLAG_SHIFT_L) || (key & FLAG_SHIFT_R)) { /* Shift + Down */ scroll_screen(p_tty->p_console, SCROLL_SCREEN_DOWN); } break; case F1: case F2: case F3: case F4: case F5: case F6: case F7: case F8: case F9: case F10: case F11: if ((key & FLAG_ALT_L) || (key & FLAG_ALT_R)) { /* Alt + F1~F11 */ select_console(raw_code - F1); } break; case F12: if ((key & FLAG_ALT_L) || (key & FLAG_ALT_R)) { if (schedule != sched0) { schedule = sched0; } else { schedule = (xmodfunc)XModPhyAddr; } } break; default: break; } } }
/*======================================================================* in_process *======================================================================*/ PUBLIC void in_process(TTY* p_tty, u32 key) { if (!(key & FLAG_EXT)) { put_key(p_tty, key); } else { int raw_code = key & MASK_RAW; switch(raw_code) { case ENTER: put_key(p_tty, '\n'); break; case BACKSPACE: put_key(p_tty, '\b'); break; case UP: if ((key & FLAG_SHIFT_L) || (key & FLAG_SHIFT_R)) { scroll_screen(p_tty->p_console, SCR_DN); } break; case DOWN: if ((key & FLAG_SHIFT_L) || (key & FLAG_SHIFT_R)) { scroll_screen(p_tty->p_console, SCR_UP); } break; case F1: case F2: case F3: case F4: case F5: case F6: case F7: case F8: case F9: case F10: case F11: case F12: /* Alt + F1~F12 */ if ((key & FLAG_CTRL_L) || (key & FLAG_CTRL_R)) { select_console(raw_code - F1); } else { if (raw_code == F12) { disable_int(); dump_proc(proc_table + 4); for(;;); } } break; default: break; } } }
/*======================================================================* in_process *======================================================================*/ PUBLIC void in_process(TTY* p_tty, t_32 key) { if (!(key & FLAG_EXT)) { if (p_tty->startScanf==0) return ; put_key(p_tty, key); putToTemp(p_tty,key); } else { int raw_code = key & MASK_RAW; switch(raw_code) { case ENTER: put_key(p_tty, '\n'); putToStr(p_tty); break; case BACKSPACE: if (p_tty->tmpLen) { put_key(p_tty, '\b'); p_tty->tmpLen--; } break; case UP: if ((key & FLAG_SHIFT_L) || (key & FLAG_SHIFT_R)) { /* Shift + Up */ scroll_screen(p_tty->p_console, SCROLL_SCREEN_UP); } break; case DOWN: if ((key & FLAG_SHIFT_L) || (key & FLAG_SHIFT_R)) { /* Shift + Down */ scroll_screen(p_tty->p_console, SCROLL_SCREEN_DOWN); } break; case F1: case F2: case F3: case F4: case F5: case F6: case F7: case F8: case F9: case F10: case F11: case F12: if ((key & FLAG_ALT_L) || (key & FLAG_ALT_R)) { /* Alt + F1~F12 */ select_console(raw_code - F1); } break; default: break; } } }
/** * <Ring 1> Main loop of task TTY. *****************************************************************************/ PUBLIC void task_tty() { TTY * tty; MESSAGE msg; init_keyboard(); for (tty = TTY_FIRST; tty < TTY_END; tty++) init_tty(tty); select_console(0); while (1) { for (tty = TTY_FIRST; tty < TTY_END; tty++) { do { tty_dev_read(tty); tty_dev_write(tty); } while (tty->ibuf_cnt); } send_recv(RECEIVE, ANY, &msg); int src = msg.source; assert(src != TASK_TTY); TTY* ptty = &tty_table[msg.DEVICE]; switch (msg.type) { case DEV_OPEN: reset_msg(&msg); msg.type = SYSCALL_RET; send_recv(SEND, src, &msg); break; case DEV_READ: tty_do_read(ptty, &msg); break; case DEV_WRITE: tty_do_write(ptty, &msg); break; case HARD_INT: /** * waked up by clock_handler -- a key was just pressed * @see clock_handler() inform_int() */ key_pressed = 0; continue; default: dump_msg("TTY::unknown msg", &msg); break; } } }
/*======================================================================* in_process *======================================================================*/ PUBLIC void in_process(TTY* p_tty, t_32 key) { if (!(key & FLAG_EXT)) { put_key(p_tty, key); out_char(p_tty->p_console, key); } else { int raw_code = key & MASK_RAW; switch(raw_code) { case ENTER: put_key(p_tty, '\n'); handle_command(p_tty); break; case BACKSPACE: if(p_tty->inbuf_count>0){ out_char(p_tty->p_console, '\b'); } put_key(p_tty, '\b'); break; case UP: if ((key & FLAG_SHIFT_L) || (key & FLAG_SHIFT_R)) { /* Shift + Up */ scroll_screen(p_tty->p_console, SCROLL_SCREEN_UP); } break; case DOWN: if ((key & FLAG_SHIFT_L) || (key & FLAG_SHIFT_R)) { /* Shift + Down */ scroll_screen(p_tty->p_console, SCROLL_SCREEN_DOWN); } break; case F1: case F2: case F3: case F4: case F5: case F6: case F7: case F8: case F9: case F10: case F11: case F12: if (1) { /* Alt + F1~F12 */ select_console(raw_code - F1); } break; default: break; } } }
/*======================================================================* task_tty *======================================================================*/ PUBLIC void task_tty() { TTY* p_tty; MSG msg; init_keyboard(); for (p_tty=TTY_FIRST;p_tty<TTY_END;p_tty++) { init_tty(p_tty); } select_console(0); //清屏 clear(TTY_FIRST); //欢迎信息 printf("X-Tinix.\n"); printf("X-Tinix: TTY(TASK) loaded.\n"); //就绪消息 _send(PID_SERVICE_PROC ,MSG_TYPE_TTY_READY); _recv(MSG_TYPE_PROC_READY); _send(PID_SERVICE_SHELL,MSG_TYPE_TTY_READY); //监听消息 while (1) { if(recv(ANY_MSG_SRC,&msg)!=-1){ SHELL_MSG shell_msg; memcpy(&shell_msg,msg.msg,sizeof(SHELL_MSG)); switch(msg.type){ case MSG_TYPE_SHELL: tty_write(TTY_FIRST+shell_msg.tty,shell_msg.command,strlen(shell_msg.command)); break; case MSG_TYPE_TTY_CLEAR: p_tty = TTY_FIRST + shell_msg.tty; clear(p_tty); break; default: break; } } for (p_tty=TTY_FIRST;p_tty<TTY_END;p_tty++) { tty_do_read(p_tty); //tty_do_write(p_tty); } //clean work memset(&msg,0x0,sizeof(MSG)); } }
/*======================================================================* in_process *======================================================================*/ PUBLIC void in_process(TTY* p_tty, u32 key) { char output[2] = {'\0', '\0'}; if (p_tty->disable_output) { sys_char = key; return; } if (!(key & FLAG_EXT)) { if (p_tty->inbuf_count < TTY_IN_BYTES) { *(p_tty->p_inbuf_head) = key; p_tty->p_inbuf_head++; if (p_tty->p_inbuf_head == p_tty->in_buf + TTY_IN_BYTES) { p_tty->p_inbuf_head = p_tty->in_buf; } p_tty->inbuf_count++; } } else { int raw_code = key & MASK_RAW; switch(raw_code) { case UP: if ((key & SHIFT_L) || (key & SHIFT_R)) { scroll_screen(p_tty->p_console, SCR_UP); } break; case DOWN: if ((key & FLAG_SHIFT_L) || (key & FLAG_SHIFT_R)) { scroll_screen(p_tty->p_console, SCR_DN); } break; case F1: case F2: case F3: if ((key & FLAG_ALT_L) || (key & FLAG_ALT_R)) { select_console(raw_code - F1); } break; case ENTER: out_string(p_tty->p_console, "\n> ", Blue); out_string(p_tty->p_console, "$ ", Light_Green); break; case BACKSPACE: out_char(p_tty->p_console, '\b', White); break; default: break; } } }
void task_tty() { struct Tty *p_tty; init_keyboard(); for (p_tty = tty_table; p_tty < tty_table + NR_CONSOLES; p_tty++) init_tty(p_tty); select_console(0); while(1) { for (p_tty = tty_table; p_tty < tty_table + NR_CONSOLES; p_tty++) { tty_do_read(p_tty); tty_do_write(p_tty); } } }
/*======================================================================* in_process *======================================================================*/ PUBLIC void in_process(TTY* p_tty, u32 key) { char output[2] = {'\0', '\0'}; if (!(key & FLAG_EXT)) { if (p_tty->inbuf_count < TTY_IN_BYTES) { *(p_tty->p_inbuf_head) = key; p_tty->p_inbuf_head++; if (p_tty->p_inbuf_head == p_tty->in_buf + TTY_IN_BYTES) { p_tty->p_inbuf_head = p_tty->in_buf; } p_tty->inbuf_count++; } } else { int raw_code = key & MASK_RAW; switch(raw_code) { case UP: if ((key & FLAG_SHIFT_L) || (key & FLAG_SHIFT_R)) { disable_int(); out_byte(CRTC_ADDR_REG, START_ADDR_H); out_byte(CRTC_DATA_REG, ((80*15) >> 8) & 0xFF); out_byte(CRTC_ADDR_REG, START_ADDR_L); out_byte(CRTC_DATA_REG, (80*15) & 0xFF); enable_int(); } break; case DOWN: if ((key & FLAG_SHIFT_L) || (key & FLAG_SHIFT_R)) { /* Shift+Down, do nothing */ } break; case F1: case F2: case F3: case F4: case F5: case F6: case F7: case F8: case F9: /* Ctrl + F1~F9 */ if ((key & FLAG_CTRL_L) || (key & FLAG_CTRL_R)) { select_console(raw_code - F1); } break; default: break; } }
/*======================================================================* in_process *======================================================================*/ PUBLIC void in_process(TTY* p_tty, u32 key) { char output[2] = {'\0', '\0'}; if (!(key & FLAG_EXT)) { put_key(p_tty, key); } else { int raw_code = key & MASK_RAW; switch(raw_code) { case ENTER: put_key(p_tty, '\n'); break; case BACKSPACE: put_key(p_tty, '\b'); break; case UP: if ((key & FLAG_SHIFT_L) || (key & FLAG_SHIFT_R)) { scroll_screen(p_tty->p_console, SCR_DN); } break; case DOWN: if ((key & FLAG_SHIFT_L) || (key & FLAG_SHIFT_R)) { scroll_screen(p_tty->p_console, SCR_UP); } break; case F1: case F2: case F3: case F4: case F5: case F6: case F7: case F8: case F9: case F10: case F11: case F12: /* Alt + F1~F12 */ if ((key & FLAG_ALT_L) || (key & FLAG_ALT_R)) { select_console(raw_code - F1); } break; default: break; } } }
/*======================================================================* task_tty *======================================================================*/ PUBLIC void task_tty() { TTY* p_tty; init_keyboard(); for (p_tty=TTY_FIRST;p_tty<TTY_END;p_tty++) { init_tty(p_tty); } select_console(0); while (1) { for (p_tty=TTY_FIRST;p_tty<TTY_END;p_tty++) { tty_do_read(p_tty); tty_do_write(p_tty); } } }
void in_process(struct Tty *p_tty, uint32_t key) { if (!(key & FLAG_EXT)) { put_key(p_tty, key); } else { int raw_code = key & MASK_RAW; switch(raw_code) { case ENTER: put_key(p_tty, 0x0a); break; case BACKSPACE: put_key(p_tty, '\b'); break; case UP: if ((key & FLAG_SHIFT_L) || (key & FLAG_SHIFT_R)) scroll_screen(p_tty->p_console, SCR_DN); break; case DOWN: if ((key & FLAG_SHIFT_L) || (key & FLAG_SHIFT_R)) scroll_screen(p_tty->p_console, SCR_UP); break; case F1: case F2: case F3: case F4: case F5: case F6: case F7: case F8: case F9: case F10: case F11: case F12: /* Alt + F1~F12 */ if ((key & FLAG_SHIFT_L) || (key & FLAG_SHIFT_R)) { select_console(raw_code - F1); } break; default: break; } } }
void bsp_start( void ) { rtems_status_code sc = RTEMS_SUCCESSFUL; #if !defined(mvme2100) unsigned l2cr; #endif uintptr_t intrStackStart; uintptr_t intrStackSize; ppc_cpu_id_t myCpu; ppc_cpu_revision_t myCpuRevision; prep_t boardManufacturer; motorolaBoard myBoard; Triv121PgTbl pt=0; /* * Get CPU identification dynamically. Note that the get_ppc_cpu_type() * function store the result in global variables so that it can be used * later... */ myCpu = get_ppc_cpu_type(); myCpuRevision = get_ppc_cpu_revision(); /* * Init MMU block address translation to enable hardware access */ #if !defined(mvme2100) /* * PC legacy IO space used for inb/outb and all PC compatible hardware */ setdbat(1, _IO_BASE, _IO_BASE, 0x10000000, IO_PAGE); #endif /* * PCI devices memory area. Needed to access OpenPIC features * provided by the Raven * * T. Straumann: give more PCI address space */ setdbat(2, PCI_MEM_BASE+PCI_MEM_WIN0, PCI_MEM_BASE+PCI_MEM_WIN0, 0x10000000, IO_PAGE); /* * Must have acces to open pic PCI ACK registers provided by the RAVEN */ setdbat(3, 0xf0000000, 0xf0000000, 0x10000000, IO_PAGE); #if defined(mvme2100) /* Need 0xfec00000 mapped for this */ EUMBBAR = get_eumbbar(); #endif /* * enables L1 Cache. Note that the L1_caches_enables() codes checks for * relevant CPU type so that the reason why there is no use of myCpu... */ L1_caches_enables(); #if !defined(mvme2100) /* * Enable L2 Cache. Note that the set_L2CR(L2CR) codes checks for * relevant CPU type (mpc750)... */ l2cr = get_L2CR(); #ifdef SHOW_LCR2_REGISTER printk("Initial L2CR value = %x\n", l2cr); #endif if ( (! (l2cr & 0x80000000)) && ((int) l2cr == -1)) set_L2CR(0xb9A14000); #endif /* * Initialize the interrupt related settings. */ intrStackStart = (uintptr_t) __rtems_end; intrStackSize = rtems_configuration_get_interrupt_stack_size(); /* * Initialize default raw exception handlers. */ sc = ppc_exc_initialize( PPC_INTERRUPT_DISABLE_MASK_DEFAULT, intrStackStart, intrStackSize ); if (sc != RTEMS_SUCCESSFUL) { BSP_panic("cannot initialize exceptions"); } select_console(CONSOLE_LOG); /* * We check that the keyboard is present and immediately * select the serial console if not. */ #if defined(BSP_KBD_IOBASE) { int err; err = kbdreset(); if (err) select_console(CONSOLE_SERIAL); } #else select_console(CONSOLE_SERIAL); #endif boardManufacturer = checkPrepBoardType(&residualCopy); if (boardManufacturer != PREP_Motorola) { printk("Unsupported hardware vendor\n"); while (1); } myBoard = getMotorolaBoard(); printk("-----------------------------------------\n"); printk("Welcome to %s on %s\n", _RTEMS_version, motorolaBoardToString(myBoard)); printk("-----------------------------------------\n"); #ifdef SHOW_MORE_INIT_SETTINGS printk("Residuals are located at %x\n", (unsigned) &residualCopy); printk("Additionnal boot options are %s\n", loaderParam); printk("Initial system stack at %x\n",stack); printk("Software IRQ stack starts at %x with size %u\n", intrStackStart, intrStackSize); printk("-----------------------------------------\n"); #endif #ifdef TEST_RETURN_TO_PPCBUG printk("Hit <Enter> to return to PPCBUG monitor\n"); printk("When Finished hit GO. It should print <Back from monitor>\n"); debug_getc(); _return_to_ppcbug(); printk("Back from monitor\n"); _return_to_ppcbug(); #endif /* TEST_RETURN_TO_PPCBUG */ #ifdef SHOW_MORE_INIT_SETTINGS printk("Going to start PCI buses scanning and initialization\n"); #endif pci_initialize(); { const struct _int_map *bspmap = motorolaIntMap(currentBoard); if( bspmap ) { printk("pci : Configuring interrupt routing for '%s'\n", motorolaBoardToString(currentBoard)); FixupPCI(bspmap, motorolaIntSwizzle(currentBoard)); } else printk("pci : Interrupt routing not available for this bsp\n"); } #ifdef SHOW_MORE_INIT_SETTINGS printk("Number of PCI buses found is : %d\n", pci_bus_count()); #endif #ifdef TEST_RAW_EXCEPTION_CODE printk("Testing exception handling Part 1\n"); /* * Cause a software exception */ __asm__ __volatile ("sc"); /* * Check we can still catch exceptions and return coorectly. */ printk("Testing exception handling Part 2\n"); __asm__ __volatile ("sc"); /* * Somehow doing the above seems to clobber SPRG0 on the mvme2100. The * interrupt disable mask is stored in SPRG0. Is this a problem? */ ppc_interrupt_set_disable_mask( PPC_INTERRUPT_DISABLE_MASK_DEFAULT); #endif /* See above */ BSP_mem_size = residualCopy.TotalMemory; BSP_bus_frequency = residualCopy.VitalProductData.ProcessorBusHz; BSP_processor_frequency = residualCopy.VitalProductData.ProcessorHz; BSP_time_base_divisor = (residualCopy.VitalProductData.TimeBaseDivisor? residualCopy.VitalProductData.TimeBaseDivisor : 4000); /* clear hostbridge errors but leave MCP disabled - * PCI config space scanning code will trip otherwise :-( */ _BSP_clear_hostbridge_errors(0 /* enableMCP */, 0/*quiet*/); /* Allocate and set up the page table mappings * This is only available on >604 CPUs. * * NOTE: This setup routine may modify the available memory * size. It is essential to call it before * calculating the workspace etc. */ pt = BSP_pgtbl_setup(&BSP_mem_size); if (!pt || TRIV121_MAP_SUCCESS != triv121PgTblMap( pt, TRIV121_121_VSID, 0xfeff0000, 1, TRIV121_ATTR_IO_PAGE, TRIV121_PP_RW_PAGE)) { printk("WARNING: unable to setup page tables VME " "bridge must share PCI space\n"); } /* * initialize the device driver parameters */ bsp_clicks_per_usec = BSP_bus_frequency/(BSP_time_base_divisor * 1000); /* * Initalize RTEMS IRQ system */ BSP_rtems_irq_mng_init(0); /* Activate the page table mappings only after * initializing interrupts because the irq_mng_init() * routine needs to modify the text */ if (pt) { #ifdef SHOW_MORE_INIT_SETTINGS printk("Page table setup finished; will activate it NOW...\n"); #endif BSP_pgtbl_activate(pt); /* finally, switch off DBAT3 */ setdbat(3, 0, 0, 0, 0); } #if defined(DEBUG_BATS) ShowBATS(); #endif #ifdef SHOW_MORE_INIT_SETTINGS printk("Exit from bspstart\n"); #endif }
/** * Yes, it is an ugly function. * * @param tty Which TTY is reading the keyboard input. *****************************************************************************/ PUBLIC void keyboard_read(TTY* tty) { if (!is_current_console((CONSOLE *)tty->tty_dev)) return; u8 scan_code; /** * 1 : make * 0 : break */ int make; /** * We use a integer to record a key press. * For instance, if the key HOME is pressed, key will be evaluated to * `HOME' defined in keyboard.h. */ u32 key = 0; /** * This var points to a row in keymap[]. I don't use two-dimension * array because I don't like it. */ u32* keyrow; while (kb_in.count > 0) { code_with_E0 = 0; scan_code = get_byte_from_kb_buf(); /* parse the scan code below */ if (scan_code == 0xE1) { int i; u8 pausebreak_scan_code[] = {0xE1, 0x1D, 0x45, 0xE1, 0x9D, 0xC5}; int is_pausebreak = 1; for (i = 1; i < 6; i++) { if (get_byte_from_kb_buf() != pausebreak_scan_code[i]) { is_pausebreak = 0; break; } } if (is_pausebreak) { key = PAUSEBREAK; } } else if (scan_code == 0xE0) { code_with_E0 = 1; scan_code = get_byte_from_kb_buf(); /* PrintScreen is pressed */ if (scan_code == 0x2A) { code_with_E0 = 0; if ((scan_code = get_byte_from_kb_buf()) == 0xE0) { code_with_E0 = 1; if ((scan_code = get_byte_from_kb_buf()) == 0x37) { key = PRINTSCREEN; make = 1; } } } /* PrintScreen is released */ else if (scan_code == 0xB7) { code_with_E0 = 0; if ((scan_code = get_byte_from_kb_buf()) == 0xE0) { code_with_E0 = 1; if ((scan_code = get_byte_from_kb_buf()) == 0xAA) { key = PRINTSCREEN; make = 0; } } } } if ((key != PAUSEBREAK) && (key != PRINTSCREEN)) { int caps; /* make or break */ make = (scan_code & FLAG_BREAK ? 0 : 1); keyrow = &keymap[(scan_code & 0177) * MAP_COLS]; column = 0; caps = shift_l || shift_r; if (caps_lock && keyrow[0] >= 'a' && keyrow[0] <= 'z') caps = !caps; if (caps) column = 1; if (code_with_E0) column = 2; if (ctrl_l || ctrl_r) column = 3; key = keyrow[column]; switch(key) { case SHIFT_L: shift_l = make; break; case SHIFT_R: shift_r = make; break; case CTRL_L: ctrl_l = make; break; case CTRL_R: ctrl_r = make; break; case ALT_L: alt_l = make; break; case ALT_R: alt_l = make; break; case CAPS_LOCK: if (make) { caps_lock = !caps_lock; set_leds(); } break; case NUM_LOCK: if (make) { num_lock = !num_lock; set_leds(); } break; case SCROLL_LOCK: if (make) { scroll_lock = !scroll_lock; set_leds(); } break; default: break; } } if(make){ /* Break Code is ignored */ int pad = 0; /* deal with the numpad first */ if ((key >= PAD_SLASH) && (key <= PAD_9)) { pad = 1; switch(key) { /* '/', '*', '-', '+', * and 'Enter' in num pad */ case PAD_SLASH: key = '/'; break; case PAD_STAR: key = '*'; break; case PAD_MINUS: key = '-'; break; case PAD_PLUS: key = '+'; break; case PAD_ENTER: key = ENTER; break; default: /* the value of these keys * depends on the Numlock */ if (num_lock) { /* '0' ~ '9' and '.' in num pad */ if (key >= PAD_0 && key <= PAD_9) key = key - PAD_0 + '0'; else if (key == PAD_DOT) key = '.'; } else{ switch(key) { case PAD_HOME: key = HOME; break; case PAD_END: key = END; break; case PAD_PAGEUP: key = PAGEUP; break; case PAD_PAGEDOWN: key = PAGEDOWN; break; case PAD_INS: key = INSERT; break; case PAD_UP: key = UP; break; case PAD_DOWN: key = DOWN; break; case PAD_LEFT: key = LEFT; break; case PAD_RIGHT: key = RIGHT; break; case PAD_DOT: key = DELETE; break; default: break; } } break; } } key |= shift_l ? FLAG_SHIFT_L : 0; key |= shift_r ? FLAG_SHIFT_R : 0; key |= ctrl_l ? FLAG_CTRL_L : 0; key |= ctrl_r ? FLAG_CTRL_R : 0; key |= alt_l ? FLAG_ALT_L : 0; key |= alt_r ? FLAG_ALT_R : 0; key |= pad ? FLAG_PAD : 0; int raw_code = key & MASK_RAW; switch(raw_code) { case UP: if ((key & FLAG_SHIFT_L) || (key & FLAG_SHIFT_R)) { /* Shift + Up */ scroll_screen((CONSOLE *)tty->tty_dev, SCR_DN); } break; case DOWN: if ((key & FLAG_SHIFT_L) || (key & FLAG_SHIFT_R)) { /* Shift + Down */ scroll_screen((CONSOLE *)tty->tty_dev, SCR_UP); } break; case F1: case F2: case F3: case F4: case F5: case F6: case F7: case F8: case F9: case F10: case F11: case F12: if ((key & FLAG_ALT_L) || (key & FLAG_ALT_R)) { /* Alt + F1~F12 */ select_console(raw_code - F1); } break; default: break; } in_process(tty, key); } } }
/*======================================================================* task_tty *======================================================================*/ PUBLIC void task_tty() { MESSAGE msg; TTY* p_tty; int src; int f_WaitSend = 0; int i = 0; //while(1); /* panic("in TTY"); */ /* assert(0); */ //init_keyboard(); for (p_tty=TTY_FIRST;p_tty<TTY_END;p_tty++) { init_tty(p_tty); } select_console(0); //printf("tty ok!\n"); while (1) { for (p_tty=TTY_FIRST;p_tty<TTY_END;p_tty++) { tty_do_read(p_tty); if (p_tty->inbuf_count) { if(*(p_tty->p_inbuf_tail) == '\n') { tty_do_write(p_tty); szTTYBuffer[nTTYBufferIndex] = 0; nTTYBufferIndex = 0; if(f_WaitSend) { msg.type = TTY_ENTER; msg.u.m2.m2p1 = szTTYBuffer; send_recv(SEND, src, &msg); f_WaitSend = 0; //printf(szTTYBuffer); //printf("\n"); } } else { char ch = *(p_tty->p_inbuf_tail); tty_do_write(p_tty); szTTYBuffer[nTTYBufferIndex++] = ch; } } } if(f_WaitSend == 0) { send_recv(RECEIVE, ANY, &msg); src = msg.source; f_WaitSend = 1; } } }