summaryrefslogtreecommitdiff
path: root/kernel/source/serial.asm
blob: 071e5254d2aa5e98c4a4503ce5adac04ba62e19e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
bits 64

global serial_init
global serial_putchar

section .text

serial_init:

  xor al, al
  mov dx, 0x03f9
  out dx, al

  mov al, 0x80
  mov dx, 0x03fb
  out dx, al

  mov al, 0x03
  mov dx, 0x03f8
  out dx, al

  xor al, al
  mov dx, 0x03f9
  out dx, al

  mov al, 0x03
  mov dx, 0x03fb
  out dx, al

  mov al, 0xc7
  mov dx, 0x03fa
  out dx, al

  ret

serial_putchar:

  cmp dil, 0x0a
  je .do_cr
.cr_ret:

  mov dx, 0x03fd

.loop:
  in al, dx
  test al, 0x20
  jz .loop

  mov al, dil
  mov dx, 0x03f8
  out dx, al
  ret

.do_cr:
  mov dil, 0x0d
  call serial_putchar
  mov dil, 0x0a
  jmp .cr_ret