Advertisement
Guest User

Untitled

a guest
Oct 5th, 2018
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. #include <stdbool.h>
  2. #include <stddef.h>
  3. #include <stdint.h>
  4. extern void serial_outs();
  5. extern void write_serial();
  6. extern void terminal_putchar();
  7. static inline uint8_t inb(uint16_t port)
  8. {
  9. uint8_t ret;
  10. asm volatile ( "inb %1, %0"
  11. : "=a"(ret)
  12. : "Nd"(port) );
  13. return ret;
  14. }
  15. int kbufn = 0;
  16. char kbuff[100];
  17. char key;
  18. unsigned char kbdus[128] =
  19. {
  20. 0,0,'1','2','3','4','5','6','7','8','9','0','-','=','\b','\t','q','w','e','r','t','y','u','i','o','p','[',']','\n',0,'a','s','d','f','g','h','j','k','l',';','\'','`',0,'\\','z','x','c','v','b','n','m',',','.','/',0,'*',
  21. };
  22. void keyboard_handler(struct regs *r)
  23. {
  24. unsigned char scancode;
  25. scancode = inb(0x60);
  26. key = kbdus[scancode];
  27. if (scancode & 0x80)
  28. {
  29.  
  30. }
  31. else
  32. {
  33. kbuff[kbufn] = key;
  34. }
  35. terminal_putchar(key);
  36. write_serial(key);
  37. write_serial(kbuff[kbufn]);
  38. kbufn++;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement