apm and smbios stubs, get_char can now wait for printable

This commit is contained in:
Benji Dial 2019-12-27 11:10:56 -05:00
parent 1f309e75b8
commit 3f3f9a806d
5 changed files with 61 additions and 5 deletions

View file

@ -26,7 +26,7 @@ get_key:;uint16_t get_key(void)
xor eax, eax xor eax, eax
;return in ax ;TODO: return in ax
leave leave
ret ret

View file

@ -21,7 +21,13 @@ OF THIS SOFTWARE.
#include "vga.h" #include "vga.h"
uint8_t get_char(bool echo) { 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) if (echo)
put_char(ch); put_char(ch);
return ch; return ch;

View file

@ -123,7 +123,24 @@ struct elf_tag {
struct module_tag { struct module_tag {
uint32_t start; uint32_t start;
uint32_t end; 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__)); } __attribute__ ((__packed__));
struct boot_device_tag boot_device; struct boot_device_tag boot_device;
@ -169,9 +186,9 @@ uint32_t main(void) {
put_32_hex(module->start); put_32_hex(module->start);
put_sz(" - "); put_sz(" - ");
put_32_hex(module->end - 1); put_32_hex(module->end - 1);
if (*module->argument) { if (*(uint8_t *)(module + 1)) {
put_sz("\n Argument: "); put_sz("\n Argument: ");
put_sz(module->argument); put_sz((uint8_t *)(module + 1));
} }
break; break;
@ -355,6 +372,24 @@ uint32_t main(void) {
break; 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: case IMAGE_BASE_ADDR:
put_sz(": image address\n 0x"); put_sz(": image address\n 0x");
put_32_hex(text_base = *(uint32_t *)(tag_pointer + 1)); put_32_hex(text_base = *(uint32_t *)(tag_pointer + 1));

View file

@ -109,6 +109,20 @@ void put_32_dec(uint32_t n) {
put_char('0'); 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) { void put_8_dec(uint8_t n) {
if (n) { if (n) {
bool sig = false; bool sig = false;

View file

@ -29,6 +29,7 @@ void put_32_hex(uint32_t n);
void put_16_hex(uint16_t n); void put_16_hex(uint16_t n);
void put_8_hex(uint8_t n); void put_8_hex(uint8_t n);
void put_32_dec(uint32_t n); void put_32_dec(uint32_t n);
void put_16_dec(uint16_t n);
void put_8_dec(uint8_t n); void put_8_dec(uint8_t n);
void move_cursor(uint8_t col, uint8_t row); void move_cursor(uint8_t col, uint8_t row);
void set_color(uint8_t c); void set_color(uint8_t c);