1
0
Fork 0
mirror of https://github.com/tailix/kernel.git synced 2025-04-14 17:33:13 -04:00

Print memory info

This commit is contained in:
Braiden Vasco 2017-11-02 04:21:25 +00:00
parent e0730adae2
commit 029b139343
2 changed files with 67 additions and 7 deletions

View file

@ -15,12 +15,8 @@ void main(struct KernelMQ_Multiboot_Info multiboot_info)
gdt_initialize();
idt_initialize();
asm volatile ("int $0x0");
asm volatile ("int $0x3");
asm volatile ("int $0x4");
asm volatile ("int $0xF");
asm volatile ("int $0x10");
asm volatile ("int $0x1F");
logger_warn("Nothing to do.");
logger_fail("Halt.");

View file

@ -5,9 +5,27 @@
#define MULTIBOOT_1_MAGIC 0x2BADB002
#define MULTIBOOT_2_MAGIC 0x36d76289
#define MULTIBOOT_TAG_TYPE_END 0
#define MULTIBOOT_TAG_TYPE_CMDLINE 1
#define MULTIBOOT_TAG_TYPE_MODULE 3
#define MULTIBOOT_TAG_TYPE_END 0
#define MULTIBOOT_TAG_TYPE_CMDLINE 1
#define MULTIBOOT_TAG_TYPE_MODULE 3
#define MULTIBOOT_TAG_TYPE_BASIC_MEMINFO 4
#define MULTIBOOT_TAG_TYPE_MMAP 6
#define MULTIBOOT_MEMORY_AVAILABLE 1
#define MULTIBOOT_MEMORY_RESERVED 2
#define MULTIBOOT_MEMORY_ACPI_RECLAIMABLE 3
#define MULTIBOOT_MEMORY_NVS 4
struct multiboot_mmap_entry
{
unsigned long long addr;
unsigned long long len;
unsigned int type;
unsigned int zero;
}
__attribute__((packed));
typedef struct multiboot_mmap_entry multiboot_memory_map_t;
struct multiboot_tag
{
@ -31,6 +49,23 @@ struct multiboot_tag_module
char cmdline[0];
};
struct multiboot_tag_basic_meminfo
{
unsigned int type;
unsigned int size;
unsigned int mem_lower;
unsigned int mem_upper;
};
struct multiboot_tag_mmap
{
unsigned int type;
unsigned int size;
unsigned int entry_size;
unsigned int entry_version;
struct multiboot_mmap_entry entries[0];
};
static void itoa(char *buf, int base, int d);
static void printf(const char *format, ...);
@ -73,6 +108,35 @@ void print_multiboot_info(struct KernelMQ_Multiboot_Info info)
((struct multiboot_tag_module *) tag)->cmdline
);
break;
case MULTIBOOT_TAG_TYPE_BASIC_MEMINFO:
printf(
"mem_lower = %uKB, mem_upper = %uKB\n",
((struct multiboot_tag_basic_meminfo *) tag)->mem_lower,
((struct multiboot_tag_basic_meminfo *) tag)->mem_upper
);
break;
case MULTIBOOT_TAG_TYPE_MMAP:
{
printf("mmap\n");
for (
multiboot_memory_map_t *mmap = ((struct multiboot_tag_mmap *) tag)->entries;
(unsigned char *) mmap < (unsigned char *) tag + tag->size;
mmap = (multiboot_memory_map_t *)((unsigned long) mmap + ((struct multiboot_tag_mmap *) tag)->entry_size)
) {
printf(
" base_addr = 0x%x%x, length = 0x%x%x, type = 0x%x\n",
(unsigned) (mmap->addr >> 32),
(unsigned) (mmap->addr & 0xffffffff),
(unsigned) (mmap->len >> 32),
(unsigned) (mmap->len & 0xffffffff),
(unsigned) mmap->type
);
}
}
break;
}
}
}