diff options
author | Benji Dial <Benji3.141@gmail.com> | 2019-12-27 11:10:56 -0500 |
---|---|---|
committer | Benji Dial <Benji3.141@gmail.com> | 2019-12-27 11:10:56 -0500 |
commit | 3f3f9a806dc63ad827fe28724dabe694f6e67f1e (patch) | |
tree | 441ff1f1617086e200af097575889735dc08b0ad | |
parent | 1f309e75b808f7f9576a3f60dbbe925d1e43a714 (diff) | |
download | portland-os-3f3f9a806dc63ad827fe28724dabe694f6e67f1e.tar.gz |
apm and smbios stubs, get_char can now wait for printable
-rw-r--r-- | src/kernel/keyb.asm | 2 | ||||
-rw-r--r-- | src/kernel/keyb.c | 8 | ||||
-rw-r--r-- | src/kernel/main.c | 41 | ||||
-rw-r--r-- | src/kernel/vga.c | 14 | ||||
-rw-r--r-- | src/kernel/vga.h | 1 |
5 files changed, 61 insertions, 5 deletions
diff --git a/src/kernel/keyb.asm b/src/kernel/keyb.asm index e3078cc..ba9fc87 100644 --- a/src/kernel/keyb.asm +++ b/src/kernel/keyb.asm @@ -26,7 +26,7 @@ get_key:;uint16_t get_key(void) xor eax, eax - ;return in ax + ;TODO: return in ax leave ret
\ No newline at end of file diff --git a/src/kernel/keyb.c b/src/kernel/keyb.c index bae462a..2c87422 100644 --- a/src/kernel/keyb.c +++ b/src/kernel/keyb.c @@ -21,7 +21,13 @@ OF THIS SOFTWARE. #include "vga.h" uint8_t get_char(bool echo) { - uint8_t ch = poll_port(COM2) ? read_byte(COM2) : 0;//TODO: from get_key + uint8_t ch = 0; + do + if (poll_port(COM2)) + ch = read_byte(COM2); + else + ;//TODO: get from get_key + while (!ch); if (echo) put_char(ch); return ch; diff --git a/src/kernel/main.c b/src/kernel/main.c index 10f0446..36257e9 100644 --- a/src/kernel/main.c +++ b/src/kernel/main.c @@ -123,7 +123,24 @@ struct elf_tag { struct module_tag { uint32_t start; uint32_t end; - uint8_t argument[1]; +} __attribute__ ((__packed__)); + +struct smbios_tag { + uint8_t major_version; + uint8_t minor_version; + uint16_t padding[3]; +} __attribute__ ((__packed__)); + +struct apm_table { + uint16_t version; + uint16_t cs_32; + uint32_t ip_32; + uint16_t cs_16; + uint16_t ds_16; + uint16_t flags; + uint16_t cs_32_length; + uint16_t cs_16_length; + uint16_t ds_16_lenth; } __attribute__ ((__packed__)); struct boot_device_tag boot_device; @@ -169,9 +186,9 @@ uint32_t main(void) { put_32_hex(module->start); put_sz(" - "); put_32_hex(module->end - 1); - if (*module->argument) { + if (*(uint8_t *)(module + 1)) { put_sz("\n Argument: "); - put_sz(module->argument); + put_sz((uint8_t *)(module + 1)); } break; @@ -355,6 +372,24 @@ uint32_t main(void) { break; } + case APM_TABLE: { + struct apm_table *table = (struct apm_table *)(tag_pointer + 1); + put_sz(": APM table\n v"); + put_16_dec(table->version); + //TODO + break; + } + + case SMBIOS_TABLE: { + struct smbios_tag *tag = (struct smbios_tag *)(tag_pointer + 1); + put_sz(": SMBIOS\n v"); + put_8_dec(tag->major_version); + put_char('.'); + put_8_dec(tag->minor_version); + //TODO + break; + } + case IMAGE_BASE_ADDR: put_sz(": image address\n 0x"); put_32_hex(text_base = *(uint32_t *)(tag_pointer + 1)); diff --git a/src/kernel/vga.c b/src/kernel/vga.c index cf95bc2..f83a2cf 100644 --- a/src/kernel/vga.c +++ b/src/kernel/vga.c @@ -109,6 +109,20 @@ void put_32_dec(uint32_t n) { put_char('0'); } +void put_16_dec(uint16_t n) { + if (n) { + bool sig = false; + for (uint16_t m = 10000; m; m /= 10) { + if (((n / m) % 10) || sig) { + sig = true; + put_char((uint8_t)'0' + (n / m) % 10); + } + } + } + else + put_char('0'); +} + void put_8_dec(uint8_t n) { if (n) { bool sig = false; diff --git a/src/kernel/vga.h b/src/kernel/vga.h index cb2c2e3..85eb887 100644 --- a/src/kernel/vga.h +++ b/src/kernel/vga.h @@ -29,6 +29,7 @@ void put_32_hex(uint32_t n); void put_16_hex(uint16_t n); void put_8_hex(uint8_t n); void put_32_dec(uint32_t n); +void put_16_dec(uint16_t n); void put_8_dec(uint8_t n); void move_cursor(uint8_t col, uint8_t row); void set_color(uint8_t c); |