tty.S 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* Copyright (C) 2021 Rain */
  2. /* This file is part of Cunix. */
  3. /*
  4. Cunix is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) and later version.
  8. */
  9. /*
  10. Cunix is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. */
  15. /*
  16. You should have received a copy of the GNU General Public License
  17. along with Cunix. If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. #define ASSEMBLY
  20. #include <modules/tty.h>
  21. .text
  22. .align 8
  23. .globl tty_init
  24. tty_init:
  25. pushq %rsi
  26. pushq %rdi
  27. /* set cursor position */
  28. movw $0x0000, %di
  29. call write_cursor
  30. popq %rdi
  31. popq %rsi
  32. ret
  33. .globl putc
  34. putc:
  35. pushq %rdi
  36. /* character is in EDI */
  37. movl %edi, %eax
  38. /* rdi = *framebuffer */
  39. movq framebuffer(%rip), %rdi
  40. movb $0x0f, %ah
  41. cld
  42. stosw
  43. movq %rdi, framebuffer(%rip)
  44. /* return 0 */
  45. xorq %rax, %rax
  46. popq %rdi
  47. ret
  48. .data
  49. .align 8
  50. .globl framebuffer
  51. framebuffer: .quad 0x00000000000b8000