Cleaned up the bios call code somewhat
This commit is contained in:
parent
c1737c30b7
commit
37f53699ff
3 changed files with 24 additions and 27 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,4 +1,5 @@
|
|||
*.o
|
||||
*.swp
|
||||
/boot.bin
|
||||
/boot.elf
|
||||
/serve
|
||||
|
|
|
|||
46
src/bios.S
46
src/bios.S
|
|
@ -31,8 +31,7 @@ bios_write: push %ebp
|
|||
PROT32
|
||||
|
||||
pop %ebx
|
||||
mov %ebp, %esp
|
||||
pop %ebp
|
||||
leave
|
||||
ret
|
||||
|
||||
.global bios_getmap
|
||||
|
|
@ -68,8 +67,7 @@ _gmdone: add $24, %di
|
|||
|
||||
pop %edi
|
||||
pop %ebx
|
||||
mov %ebp, %esp
|
||||
pop %ebp
|
||||
leave
|
||||
ret
|
||||
|
||||
.global bios_func
|
||||
|
|
@ -80,39 +78,38 @@ bios_func: push %ebp
|
|||
push %edi
|
||||
push %esi
|
||||
|
||||
mov 8+0(%ebp), %eax
|
||||
mov 8+4(%ebp), %edi
|
||||
|
||||
// The interrupt number is given as an immediate value to INT.
|
||||
// To support any interrupt number, we use self-modifying code.
|
||||
mov 8+0(%ebp), %eax
|
||||
mov %al, _bf_int+1
|
||||
|
||||
PROT16
|
||||
REAL
|
||||
|
||||
mov 0(%edi), %eax
|
||||
mov 4(%edi), %ecx
|
||||
mov 8(%edi), %edx
|
||||
mov 12(%edi), %ebx
|
||||
mov 16(%edi), %ebp
|
||||
mov 20(%edi), %esi
|
||||
mov 24(%edi), %edi
|
||||
mov 8+4(%ebp), %edi
|
||||
mov 0(%edi), %ax
|
||||
mov 2(%edi), %cx
|
||||
mov 4(%edi), %dx
|
||||
mov 6(%edi), %bx
|
||||
mov 8(%edi), %bp
|
||||
mov 10(%edi), %si
|
||||
mov 12(%edi), %di
|
||||
|
||||
// This instruction will get written at runtime
|
||||
_bf_int: .byte 0xCD, 0 // INT imm8
|
||||
push $0
|
||||
pushf
|
||||
|
||||
push %edi
|
||||
push %di
|
||||
mov 8+4(%ebp), %edi
|
||||
mov %eax, 0(%edi)
|
||||
mov %ecx, 4(%edi)
|
||||
mov %edx, 8(%edi)
|
||||
mov %ebx, 12(%edi)
|
||||
mov %ebp, 16(%edi)
|
||||
mov %esi, 20(%edi)
|
||||
pop %eax
|
||||
mov %eax, 24(%edi)
|
||||
mov %ax, 0(%edi)
|
||||
mov %cx, 2(%edi)
|
||||
mov %dx, 4(%edi)
|
||||
mov %bx, 6(%edi)
|
||||
mov %bp, 8(%edi)
|
||||
mov %si, 10(%edi)
|
||||
pop %ax
|
||||
mov %ax, 12(%edi)
|
||||
|
||||
PROT
|
||||
PROT32
|
||||
|
|
@ -123,6 +120,5 @@ _bf_int: .byte 0xCD, 0 // INT imm8
|
|||
pop %edi
|
||||
pop %ebp
|
||||
pop %ebx
|
||||
mov %ebp, %esp
|
||||
pop %ebp
|
||||
leave
|
||||
ret
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ struct vesa_info {
|
|||
uint8_t reserved[492];
|
||||
};
|
||||
|
||||
extern uint16_t bios_func(uint8_t inum, uint32_t reg[]);
|
||||
extern uint16_t bios_func(uint8_t inum, uint16_t reg[]);
|
||||
|
||||
#define PG_PRESENT 0x001
|
||||
#define PG_WRITE 0x002
|
||||
|
|
@ -123,7 +123,7 @@ main()
|
|||
bios_write(buf);
|
||||
#endif
|
||||
|
||||
uint32_t reg[7];
|
||||
uint16_t reg[7];
|
||||
reg[0] = (0x0E << 8) + 'J';
|
||||
reg[1] = 0;
|
||||
reg[2] = 0;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue