summaryrefslogtreecommitdiff
path: root/kernel/rs.s
blob: 69d31ae7690f7bf6632f3d6359af421791b71946 (plain)
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
global rs_isr
extern rsint_rx
extern rsint_tx
extern rsputs

%define RSBASE 0x3F8

%define RSDATA    RSBASE
%define RSINTEN   (RSBASE + 1)
%define RSFIFOC   (RSBASE + 2)
%define RSINTID   (RSBASE + 2)
%define RSLINEC   (RSBASE + 3)
%define RSMODEMC  (RSBASE + 4)
%define RSLINES   (RSBASE + 5)
%define RSMODEMS  (RSBASE + 6)
%define RSSCRATCH (RSBASE + 7)

rs_isr:
  pusha
  mov ax, ds
  push ax
  mov ax, 0x10
  mov ds, ax
  mov es, ax
  mov fs, ax
  mov gs, ax

  mov dx, RSINTID
  in al, dx
  test al, 1
  jnz .skip
  and al, 0x0E
  cmp al, 0x04
  je .rx
  cmp al, 0x0C
  je .rx
  cmp al, 0x02
  je .tx
  jmp .skip
.tx:
  call rsint_tx
  jmp .skip
.rx:
  call rsint_rx
.skip:
  mov al, 0x20
  out 0x20, al

  pop ax
  mov ds, ax
  mov es, ax
  mov fs, ax
  mov gs, ax
  popa
  iret