summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenji Dial <Benji3.141@gmail.com>2019-12-26 20:50:57 -0500
committerBenji Dial <Benji3.141@gmail.com>2019-12-26 20:50:57 -0500
commit1f309e75b808f7f9576a3f60dbbe925d1e43a714 (patch)
treea7f0abf9e2db77783a406b35f1637d4d10676b8f
parent3353bdaf2bc2f0eb7c37b57728c5b3ce2017e7f5 (diff)
downloadportland-os-1f309e75b808f7f9576a3f60dbbe925d1e43a714.tar.gz
a few more tags, just printing
-rw-r--r--src/kernel/main.c79
1 files changed, 70 insertions, 9 deletions
diff --git a/src/kernel/main.c b/src/kernel/main.c
index 6993233..10f0446 100644
--- a/src/kernel/main.c
+++ b/src/kernel/main.c
@@ -26,7 +26,7 @@ OF THIS SOFTWARE.
enum tag_type {
BOOT_COMMAND = 0x00000001,
LOADER_NAME = 0x00000002,
- BOOT_MODULES = 0x00000003,
+ BOOT_MODULE = 0x00000003,
MEMORY_INFO = 0x00000004,
BOOT_DEVICE = 0x00000005,
MEMORY_MAP = 0x00000006,
@@ -113,9 +113,24 @@ struct fbuf_rgb_info {
uint8_t blue_mask;
} __attribute__ ((__packed__));
+struct elf_tag {
+ uint16_t count;
+ uint16_t size;
+ uint16_t shndx;
+ uint16_t padding;
+} __attribute__ ((__packed__));
+
+struct module_tag {
+ uint32_t start;
+ uint32_t end;
+ uint8_t argument[1];
+} __attribute__ ((__packed__));
+
struct boot_device_tag boot_device;
bool have_boot_device = false;
bool have_mmap = false;
+uint32_t text_base;
+bool have_text_base;
enum error_codes {
NO_BOOT_DEVICE = 0x00000000,
@@ -137,11 +152,29 @@ uint32_t main(void) {
put_32_hex(tag_pointer->size);
switch (tag_pointer->type) {
+ case BOOT_COMMAND:
+ put_sz(": boot arguments\n ");
+ put_sz(*(uint8_t *)(tag_pointer + 1) ?
+ (uint8_t *)(tag_pointer + 1) : "No arguments");
+ break;
+
case LOADER_NAME:
put_sz(": bootloader name\n ");
put_sz((uint8_t *)(tag_pointer + 1));
break;
+ case BOOT_MODULE:
+ put_sz(": boot module\n Loaded at: 0x");
+ struct module_tag *module = (struct module_tag *)(tag_pointer + 1);
+ put_32_hex(module->start);
+ put_sz(" - ");
+ put_32_hex(module->end - 1);
+ if (*module->argument) {
+ put_sz("\n Argument: ");
+ put_sz(module->argument);
+ }
+ break;
+
case MEMORY_INFO:
put_sz(": memory size\n Lower memory: 0x");
put_32_hex((tag_pointer + 1)->type);
@@ -273,7 +306,7 @@ uint32_t main(void) {
struct fbuf_tag *fbuf_info = (struct fbuf_tag *)(tag_pointer + 1);
put_sz(": framebuffer information\n Address: 0x");
put_32_hex(fbuf_info->address_high);
- put_char(':');
+ put_char('.');
put_32_hex(fbuf_info->address_low);
put_sz("\n Pitch: ");
put_32_dec(fbuf_info->pitch);
@@ -309,9 +342,23 @@ uint32_t main(void) {
break;
}
+ case ELF_SYMBOLS: {
+ struct elf_tag *tag = (struct elf_tag *)(tag_pointer + 1);
+ struct elf_shdr *p = (struct elf_shdr *)(tag + 1);
+ put_sz(": ELF shdr table\n shndx: 0x");
+ put_16_hex(tag->shndx);
+ if (tag->count)
+ for (uint32_t i = 0; i < tag->count; ++i) {
+ ;//TODO
+ p = (struct elf_shdr *)((uint32_t)p + tag->size);
+ }
+ break;
+ }
+
case IMAGE_BASE_ADDR:
put_sz(": image address\n 0x");
- put_32_hex(*(uint32_t *)(tag_pointer + 1));
+ put_32_hex(text_base = *(uint32_t *)(tag_pointer + 1));
+ have_text_base = true;
break;
default:
@@ -326,12 +373,26 @@ uint32_t main(void) {
if (!have_mmap)
return NO_MMAP;
- put_sz("\n\nReady!\n Memory map size: 0x");
- put_32_hex(sizeof(struct mmap_entry) * MMAP_SIZE);
- put_sz("\n Process table size: 0x");
- put_32_hex(sizeof(struct proc_info) * 65536);
- put_sz("\n File table size: 0x");
- put_32_hex(sizeof(struct file_info) * 65536);
+ put_sz("\n\nImportant locations:");
+ if (have_text_base) {
+ put_sz("\n Text section: 0x");
+ put_32_hex(text_base);
+ }
+ put_sz("\n Memory map: 0x");
+ put_32_hex((uint32_t)mmap_bss);
+ put_sz(" - 0x");
+ put_32_hex((uint32_t)mmap_bss - 1 +
+ sizeof(struct mmap_entry) * MMAP_SIZE);
+ put_sz("\n Process table: 0x");
+ put_32_hex((uint32_t)proc_table);
+ put_sz(" - 0x");
+ put_32_hex((uint32_t)proc_table - 1 +
+ sizeof(struct proc_info) * 65536);
+ put_sz("\n File table: 0x");
+ put_32_hex((uint32_t)file_table);
+ put_sz(" - 0x");
+ put_32_hex((uint32_t)file_table - 1 +
+ sizeof(struct file_info) * 65536);
put_sz("\n\n");
put_sz("No file support yet. Halting.");