Push missing write/read ports w/ diff operand sizes.

This commit is contained in:
secXsQuared 2016-06-13 23:57:38 -07:00
parent b2254e207d
commit 0188fe66a5
3 changed files with 63 additions and 8 deletions

View File

@ -102,23 +102,70 @@ pop rbp
ret
;====================
global hal_write_port
hal_write_port:
global hal_write_port_32
hal_write_port_32:
mov rdx,rdi
mov rax,rsi
out dx,eax
nop
nop
nop
ret
;====================
global hal_read_port
hal_read_port:
global hal_write_port_16
hal_write_port_16:
mov rdx,rdi
mov rax,rsi
out dx,ax
nop
nop
nop
ret
;====================
global hal_write_port_8
hal_write_port_8:
mov rdx,rdi
mov rax,rsi
out dx,al
nop
nop
nop
ret
;====================
global hal_read_port_8
hal_read_port_8:
mov rdx,rdi
xor rax,rax
in al,dx
nop
nop
nop
ret
;====================
global hal_read_port_16
hal_read_port_16:
mov rdx,rdi
xor rax,rax
in ax,dx
nop
nop
nop
ret
;====================
global hal_read_port_32
hal_read_port_32:
mov rdx,rdi
xor rax,rax
in eax,dx
nop
nop
nop
ret
;====================

View File

@ -151,8 +151,8 @@ int32_t KAPI hal_interrupt_init(void)
hal_flush_idt(&g_idt_ptr);
// disable PIC
hal_write_port(0xa1, 0xff);
hal_write_port(0x21, 0xff);
hal_write_port_8(0xa1, 0xff);
hal_write_port_8(0x21, 0xff);
uint64_t apic_base_reg = 0;
uint64_t apic_base = 0;

View File

@ -30,9 +30,17 @@ extern void KAPI hal_disable_interrupt();
extern void KAPI hal_halt_cpu();
extern void KAPI hal_write_port(uint64_t port, int64_t data);
extern int8_t KAPI hal_read_port_8(uint16_t port);
extern int64_t KAPI hal_read_port(uint64_t port);
extern int16_t KAPI hal_read_port_16(uint16_t port);
extern int32_t KAPI hal_read_port_32(uint16_t port);
extern void KAPI hal_write_port_8(uint16_t port, uint8_t data);
extern void KAPI hal_write_port_16(uint16_t port, uint16_t data);
extern void KAPI hal_write_port_32(uint16_t port, uint32_t data);
extern void KAPI hal_write_mem_32(void* target, uint32_t data);