⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 keyboard.s

📁 带中文注释的 linux 0.11 源代码0.11,很好的
💻 S
📖 第 1 页 / 共 2 页
字号:
alt_map:.byte 0,0.ascii "\0@\0$\0\0{[]}\\\0".byte 0,0.byte 0,0,0,0,0,0,0,0,0,0,0.byte '~,13,0.byte 0,0,0,0,0,0,0,0,0,0,0.byte 0,0.byte 0,0,0,0,0,0,0,0,0,0,0.byte 0,0,0,0 /* 36-39 */.fill 16,1,0 /* 3A-49 */.byte 0,0,0,0,0 /* 4A-4E */.byte 0,0,0,0,0,0,0 /* 4F-55 */.byte '|.fill 10,1,0#elif defined(KBD_US)// 以下是美式键盘的扫描码映射表。key_map:.byte 0,27.ascii "1234567890-=".byte 127,9.ascii "qwertyuiop[]".byte 13,0.ascii "asdfghjkl;'".byte '`,0.ascii "\\zxcvbnm,./".byte 0,'*,0,32 /* 36-39 */.fill 16,1,0 /* 3A-49 */.byte '-,0,0,0,'+ /* 4A-4E */.byte 0,0,0,0,0,0,0 /* 4F-55 */.byte '<.fill 10,1,0shift_map:.byte 0,27.ascii "!@#$%^&*()_+".byte 127,9.ascii "QWERTYUIOP{}".byte 13,0.ascii "ASDFGHJKL:\"".byte '~,0.ascii "|ZXCVBNM<>?".byte 0,'*,0,32 /* 36-39 */.fill 16,1,0 /* 3A-49 */.byte '-,0,0,0,'+ /* 4A-4E */.byte 0,0,0,0,0,0,0 /* 4F-55 */.byte '>.fill 10,1,0alt_map:.byte 0,0.ascii "\0@\0$\0\0{[]}\\\0".byte 0,0.byte 0,0,0,0,0,0,0,0,0,0,0.byte '~,13,0.byte 0,0,0,0,0,0,0,0,0,0,0.byte 0,0.byte 0,0,0,0,0,0,0,0,0,0,0.byte 0,0,0,0 /* 36-39 */.fill 16,1,0 /* 3A-49 */.byte 0,0,0,0,0 /* 4A-4E */.byte 0,0,0,0,0,0,0 /* 4F-55 */.byte '|.fill 10,1,0#elif defined(KBD_GR)// 以下是德语键盘的扫描码映射表。key_map:.byte 0,27.ascii "1234567890\\'".byte 127,9.ascii "qwertzuiop@+".byte 13,0.ascii "asdfghjkl[]^".byte 0,'#.ascii "yxcvbnm,.-".byte 0,'*,0,32 /* 36-39 */.fill 16,1,0 /* 3A-49 */.byte '-,0,0,0,'+ /* 4A-4E */.byte 0,0,0,0,0,0,0 /* 4F-55 */.byte '<.fill 10,1,0shift_map:.byte 0,27.ascii "!\"#$%&/()=?`".byte 127,9.ascii "QWERTZUIOP\\*".byte 13,0.ascii "ASDFGHJKL{}~".byte 0,''.ascii "YXCVBNM;:_".byte 0,'*,0,32 /* 36-39 */.fill 16,1,0 /* 3A-49 */.byte '-,0,0,0,'+ /* 4A-4E */.byte 0,0,0,0,0,0,0 /* 4F-55 */.byte '>.fill 10,1,0alt_map:.byte 0,0.ascii "\0@\0$\0\0{[]}\\\0".byte 0,0.byte '@,0,0,0,0,0,0,0,0,0,0.byte '~,13,0.byte 0,0,0,0,0,0,0,0,0,0,0.byte 0,0.byte 0,0,0,0,0,0,0,0,0,0,0.byte 0,0,0,0 /* 36-39 */.fill 16,1,0 /* 3A-49 */.byte 0,0,0,0,0 /* 4A-4E */.byte 0,0,0,0,0,0,0 /* 4F-55 */.byte '|.fill 10,1,0#elif defined(KBD_FR)// 以下是法语键盘的扫描码映射表。key_map:.byte 0,27.ascii "&{\"'(-}_/@)=".byte 127,9.ascii "azertyuiop^$".byte 13,0.ascii "qsdfghjklm|".byte '`,0,42 /* coin sup gauche, don't know, [*|mu] */.ascii "wxcvbn,;:!".byte 0,'*,0,32 /* 36-39 */.fill 16,1,0 /* 3A-49 */.byte '-,0,0,0,'+ /* 4A-4E */.byte 0,0,0,0,0,0,0 /* 4F-55 */.byte '<.fill 10,1,0shift_map:.byte 0,27.ascii "1234567890]+".byte 127,9.ascii "AZERTYUIOP<>".byte 13,0.ascii "QSDFGHJKLM%".byte '~,0,'#.ascii "WXCVBN?./\\".byte 0,'*,0,32 /* 36-39 */.fill 16,1,0 /* 3A-49 */.byte '-,0,0,0,'+ /* 4A-4E */.byte 0,0,0,0,0,0,0 /* 4F-55 */.byte '>.fill 10,1,0alt_map:.byte 0,0.ascii "\0~#{[|`\\^@]}".byte 0,0.byte '@,0,0,0,0,0,0,0,0,0,0.byte '~,13,0.byte 0,0,0,0,0,0,0,0,0,0,0.byte 0,0.byte 0,0,0,0,0,0,0,0,0,0,0.byte 0,0,0,0 /* 36-39 */.fill 16,1,0 /* 3A-49 */.byte 0,0,0,0,0 /* 4A-4E */.byte 0,0,0,0,0,0,0 /* 4F-55 */.byte '|.fill 10,1,0#else#error "KBD-type not defined"#endif/** do_self handles "normal" keys, ie keys that don't change meaning* and which have just one character returns.*//** do_self 用于处理“普通”键,也即含义没有变化并且只有一个字符返回的键。*/do_self:// 454-460 行用于根据模式标志mode 选择alt_map、shift_map 或key_map 映射表之一。lea alt_map,%ebx // alt 键同时按下时的映射表基址alt_map??ebx。testb $0x20,mode /* alt-gr */ /* 右alt 键同时按下了? */jne 1f // 是,则向前跳转到标号1 处。lea shift_map,%ebx // shift 键同时按下时的映射表基址shift_map??ebx。testb $0x03,mode // 有shift 键同时按下了吗?jne 1f // 有,则向前跳转到标号1 处。lea key_map,%ebx // 否则使用普通映射表key_map。// 取映射表中对应扫描码的ASCII 字符,若没有对应字符,则返回(转none)。1: movb (%ebx,%eax),%al // 将扫描码作为索引值,取对应的ASCII 码??al。orb %al,%al // 检测看是否有对应的ASCII 码。je none // 若没有(对应的ASCII 码=0),则返回。// 若ctrl 键已按下或caps 键锁定,并且字符在'a'-'}'(0x61-0x7D)范围内,则将其转成大写字符// (0x41-0x5D)。testb $0x4c,mode /* ctrl or caps */ /* 控制键已按下或caps 亮?*/je 2f // 没有,则向前跳转标号2 处。cmpb $'a,%al // 将al 中的字符与'a'比较。jb 2f // 若al 值<'a',则转标号2 处。cmpb $'},%al // 将al 中的字符与'}'比较。ja 2f // 若al 值>'}',则转标号2 处。subb $32,%al // 将al 转换为大写字符(减0x20)。// 若ctrl 键已按下,并且字符在'`'--'_'(0x40-0x5F)之间(是大写字符),则将其转换为控制字符// (0x00-0x1F)。2: testb $0x0c,mode /* ctrl */ /* ctrl 键同时按下了吗?*/je 3f // 若没有则转标号3。cmpb $64,%al // 将al 与'@'(64)字符比较(即判断字符所属范围)。jb 3f // 若值<'@',则转标号3。cmpb $64+32,%al // 将al 与'`'(96)字符比较(即判断字符所属范围)。jae 3f // 若值>='`',则转标号3。subb $64,%al // 否则al 值减0x40,// 即将字符转换为0x00-0x1f 之间的控制字符。// 若左alt 键同时按下,则将字符的位7 置位。3: testb $0x10,mode /* left alt */ /* 左alt 键同时按下?*/je 4f // 没有,则转标号4。orb $0x80,%al // 字符的位7 置位。// 将al 中的字符放入读缓冲队列中。4: andl $0xff,%eax // 清eax 的高字和ah。xorl %ebx,%ebx // 清ebx。call put_queue // 将字符放入缓冲队列中。none: ret/** minus has a routine of it's own, as a 'E0h' before* the scan code for minus means that the numeric keypad* slash was pushed.*//** 减号有它自己的处理子程序,因为在减号扫描码之前的0xe0* 意味着按下了数字小键盘上的斜杠键。*/minus: cmpb $1,e0 // e0 标志置位了吗?jne do_self // 没有,则调用do_self 对减号符进行普通处理。movl $'/,%eax // 否则用'/'替换减号'-'??al。xorl %ebx,%ebxjmp put_queue // 并将字符放入缓冲队列中。/** This table decides which routine to call when a scan-code has been* gotten. Most routines just call do_self, or none, depending if* they are make or break.*//* 下面是一张子程序地址跳转表。当取得扫描码后就根据此表调用相应的扫描码处理子程序。* 大多数调用的子程序是do_self,或者是none,这起决于是按键(make)还是释放键(break)。*/key_table:.long none,do_self,do_self,do_self /* 00-03 s0 esc 1 2 */.long do_self,do_self,do_self,do_self /* 04-07 3 4 5 6 */.long do_self,do_self,do_self,do_self /* 08-0B 7 8 9 0 */.long do_self,do_self,do_self,do_self /* 0C-0F + ' bs tab */.long do_self,do_self,do_self,do_self /* 10-13 q w e r */.long do_self,do_self,do_self,do_self /* 14-17 t y u i */.long do_self,do_self,do_self,do_self /* 18-1B o p } ^ */.long do_self,ctrl,do_self,do_self /* 1C-1F enter ctrl a s */.long do_self,do_self,do_self,do_self /* 20-23 d f g h */.long do_self,do_self,do_self,do_self /* 24-27 j k l | */.long do_self,do_self,lshift,do_self /* 28-2B { para lshift , */.long do_self,do_self,do_self,do_self /* 2C-2F z x c v */.long do_self,do_self,do_self,do_self /* 30-33 b n m , */.long do_self,minus,rshift,do_self /* 34-37 . - rshift * */.long alt,do_self,caps,func /* 38-3B alt sp caps f1 */.long func,func,func,func /* 3C-3F f2 f3 f4 f5 */.long func,func,func,func /* 40-43 f6 f7 f8 f9 */.long func,num,scroll,cursor /* 44-47 f10 num scr home */.long cursor,cursor,do_self,cursor /* 48-4B up pgup - left */.long cursor,cursor,do_self,cursor /* 4C-4F n5 right + end */.long cursor,cursor,cursor,cursor /* 50-53 dn pgdn ins del */.long none,none,do_self,func /* 54-57 sysreq ? < f11 */.long func,none,none,none /* 58-5B f12 ? ? ? */.long none,none,none,none /* 5C-5F ? ? ? ? */.long none,none,none,none /* 60-63 ? ? ? ? */.long none,none,none,none /* 64-67 ? ? ? ? */.long none,none,none,none /* 68-6B ? ? ? ? */.long none,none,none,none /* 6C-6F ? ? ? ? */.long none,none,none,none /* 70-73 ? ? ? ? */.long none,none,none,none /* 74-77 ? ? ? ? */.long none,none,none,none /* 78-7B ? ? ? ? */.long none,none,none,none /* 7C-7F ? ? ? ? */.long none,none,none,none /* 80-83 ? br br br */.long none,none,none,none /* 84-87 br br br br */.long none,none,none,none /* 88-8B br br br br */.long none,none,none,none /* 8C-8F br br br br */.long none,none,none,none /* 90-93 br br br br */.long none,none,none,none /* 94-97 br br br br */.long none,none,none,none /* 98-9B br br br br */.long none,unctrl,none,none /* 9C-9F br unctrl br br */.long none,none,none,none /* A0-A3 br br br br */.long none,none,none,none /* A4-A7 br br br br */.long none,none,unlshift,none /* A8-AB br br unlshift br */.long none,none,none,none /* AC-AF br br br br */.long none,none,none,none /* B0-B3 br br br br */.long none,none,unrshift,none /* B4-B7 br br unrshift br */.long unalt,none,uncaps,none /* B8-BB unalt br uncaps br */.long none,none,none,none /* BC-BF br br br br */.long none,none,none,none /* C0-C3 br br br br */.long none,none,none,none /* C4-C7 br br br br */.long none,none,none,none /* C8-CB br br br br */.long none,none,none,none /* CC-CF br br br br */.long none,none,none,none /* D0-D3 br br br br */.long none,none,none,none /* D4-D7 br br br br */.long none,none,none,none /* D8-DB br ? ? ? */.long none,none,none,none /* DC-DF ? ? ? ? */.long none,none,none,none /* E0-E3 e0 e1 ? ? */.long none,none,none,none /* E4-E7 ? ? ? ? */.long none,none,none,none /* E8-EB ? ? ? ? */.long none,none,none,none /* EC-EF ? ? ? ? */.long none,none,none,none /* F0-F3 ? ? ? ? */.long none,none,none,none /* F4-F7 ? ? ? ? */.long none,none,none,none /* F8-FB ? ? ? ? */.long none,none,none,none /* FC-FF ? ? ? ? *//** kb_wait waits for the keyboard controller buffer to empty.* there is no timeout - if the buffer doesn't empty, we hang.*//** 子程序kb_wait 用于等待键盘控制器缓冲空。不存在超时处理 - 如果* 缓冲永远不空的话,程序就会永远等待(死掉)。*/kb_wait:pushl %eax1: inb $0x64,%al // 读键盘控制器状态。testb $0x02,%al // 测试输入缓冲器是否为空(等于0)。jne 1b // 若不空,则跳转循环等待。popl %eaxret/** This routine reboots the machine by asking the keyboard* controller to pulse the reset-line low.*//** 该子程序通过设置键盘控制器,向复位线输出负脉冲,使系统复位重启(reboot)。*/reboot:call kb_wait // 首先等待键盘控制器输入缓冲器空。movw $0x1234,0x472 /* don't do memory check */movb $0xfc,%al /* pulse reset and A20 low */outb %al,$0x64 // 向系统复位和A20 线输出负脉冲。die: jmp die // 死机。

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -