More BIOS text display functionality
This commit is contained in:
parent
37f53699ff
commit
87ab2b0295
5 changed files with 81 additions and 48 deletions
2
run-dnsmasq.sh
Executable file
2
run-dnsmasq.sh
Executable file
|
|
@ -0,0 +1,2 @@
|
|||
#!/bin/sh
|
||||
dnsmasq -u "$USER" --conf-file=dnsmasq.conf "$@"
|
||||
35
src/bios.S
35
src/bios.S
|
|
@ -86,30 +86,31 @@ bios_func: push %ebp
|
|||
PROT16
|
||||
REAL
|
||||
|
||||
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
|
||||
mov %ds:8+4(%ebp), %edi
|
||||
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
|
||||
|
||||
// This instruction will get written at runtime
|
||||
_bf_int: .byte 0xCD, 0 // INT imm8
|
||||
push $0
|
||||
pushf
|
||||
|
||||
push %di
|
||||
// FIXME broken BP
|
||||
push %edi
|
||||
mov 8+4(%ebp), %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)
|
||||
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)
|
||||
|
||||
PROT
|
||||
PROT32
|
||||
|
|
|
|||
82
src/main.c
82
src/main.c
|
|
@ -49,7 +49,49 @@ struct vesa_info {
|
|||
uint8_t reserved[492];
|
||||
};
|
||||
|
||||
extern uint16_t bios_func(uint8_t inum, uint16_t reg[]);
|
||||
extern uint16_t bios_func(uint8_t inum, uint32_t reg[]);
|
||||
|
||||
void
|
||||
blank_screen(uint16_t attr)
|
||||
{
|
||||
uint32_t reg[7];
|
||||
reg[0] = (0x06 << 8);
|
||||
reg[1] = 0;
|
||||
reg[2] = 0xFFFF;
|
||||
reg[3] = attr << 8;
|
||||
reg[4] = 0;
|
||||
reg[5] = 0;
|
||||
reg[6] = 0;
|
||||
bios_func(0x10, reg);
|
||||
}
|
||||
|
||||
void
|
||||
move_cursor(uint8_t row, uint8_t col)
|
||||
{
|
||||
uint32_t reg[7];
|
||||
reg[0] = (0x02 << 8);
|
||||
reg[1] = 0;
|
||||
reg[2] = (row << 8) | col;
|
||||
reg[3] = 0;
|
||||
reg[4] = 0;
|
||||
reg[5] = 0;
|
||||
reg[6] = 0;
|
||||
bios_func(0x10, reg);
|
||||
}
|
||||
|
||||
void
|
||||
display_string(uint16_t attr, const char *str)
|
||||
{
|
||||
uint32_t reg[7];
|
||||
reg[0] = (0x13 << 8) | 0x01;
|
||||
reg[1] = strlen(str);
|
||||
reg[2] = 0xFFFF;
|
||||
reg[3] = attr;
|
||||
reg[4] = (uint32_t)str;
|
||||
reg[5] = 0;
|
||||
reg[6] = 0;
|
||||
bios_func(0x10, reg);
|
||||
}
|
||||
|
||||
#define PG_PRESENT 0x001
|
||||
#define PG_WRITE 0x002
|
||||
|
|
@ -76,16 +118,19 @@ pg_setup()
|
|||
void
|
||||
main()
|
||||
{
|
||||
bios_write("Netboot via fernlader v2 ...\r\n");
|
||||
//blank_screen(0x10);
|
||||
//move_cursor(0, 0);
|
||||
display_string(0x14, "Netboot via fernlader v2 ...\r\n");
|
||||
bios_write("Going well ...\r\n");
|
||||
|
||||
memcpy(bootboot.magic, BOOTBOOT_MAGIC, sizeof bootboot.magic);
|
||||
bootboot.size = 128;
|
||||
bootboot.protocol = PROTOCOL_MINIMAL | LOADER_BIOS;
|
||||
bootboot.numcores = 1;
|
||||
|
||||
bios_write("init\r\n");
|
||||
display_string(0x0E, "init\r\n");
|
||||
struct e820_entry *end = bios_getmap(memmap);
|
||||
bios_write("karlos\r\n");
|
||||
display_string(0x0E, "karlos\r\n");
|
||||
for (int i = 0; ; i++) {
|
||||
if (&memmap[i] >= end) break;
|
||||
char buf[2];
|
||||
|
|
@ -97,33 +142,7 @@ main()
|
|||
pg_setup();
|
||||
|
||||
#if 0
|
||||
char foo[24];
|
||||
|
||||
bios_write("bios_func():\r\n");
|
||||
uint32_t reg[6];
|
||||
reg[0] = 0xE820;
|
||||
reg[1] = 24;
|
||||
reg[2] = 0x534D4150;
|
||||
reg[3] = 0;
|
||||
reg[4] = (uint32_t)&foo;
|
||||
reg[5] = 0;
|
||||
uint16_t flags = bios_func(0x15, reg);
|
||||
|
||||
const char *hex_digits = "0123456789ABCDEF";
|
||||
char buf[100];
|
||||
buf[0] = hex_digits[(flags >> 12) & 0xF];
|
||||
buf[1] = hex_digits[(flags >> 8) & 0xF];
|
||||
buf[2] = hex_digits[(flags >> 4) & 0xF];
|
||||
buf[3] = hex_digits[(flags >> 0) & 0xF];
|
||||
buf[4] = ' ';
|
||||
buf[5] = hex_digits[(foo[16] >> 0) & 0xF];
|
||||
buf[6] = ' ';
|
||||
buf[7] = 0;
|
||||
|
||||
bios_write(buf);
|
||||
#endif
|
||||
|
||||
uint16_t reg[7];
|
||||
uint32_t reg[7];
|
||||
reg[0] = (0x0E << 8) + 'J';
|
||||
reg[1] = 0;
|
||||
reg[2] = 0;
|
||||
|
|
@ -134,6 +153,7 @@ main()
|
|||
bios_func(0x10, reg);
|
||||
|
||||
bios_write("what?\r\n");
|
||||
#endif
|
||||
|
||||
for (;;) {
|
||||
__asm__ ("hlt");
|
||||
|
|
|
|||
|
|
@ -10,3 +10,11 @@ memcpy(void *dst, const void *src, size_t n)
|
|||
: "memory");
|
||||
return dst;
|
||||
}
|
||||
|
||||
size_t
|
||||
strlen(const char *s)
|
||||
{
|
||||
size_t l = 0;
|
||||
while (s[l]) l++;
|
||||
return l;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,4 +38,6 @@ void *memmove(void *dst, const void *src, size_t n);
|
|||
void *memset (void *dst, int c, size_t n);
|
||||
int memcmp (const void *src1, const void *src2, size_t n);
|
||||
|
||||
size_t strlen(const char *s);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue