aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile3
-rw-r--r--src/boot/multiboot2.cc9
-rw-r--r--src/boot/multiboot2.hpp10
-rw-r--r--src/boucane.cc18
-rw-r--r--src/boucane.hpp2
-rw-r--r--src/core/idt.cc1
-rw-r--r--src/core/int.S3
-rw-r--r--src/core/paging.cc23
-rw-r--r--src/drivers/bmp.cc39
-rw-r--r--src/drivers/bmp.hpp18
-rw-r--r--src/res/logo.bmpbin0 -> 364954 bytes
11 files changed, 114 insertions, 12 deletions
diff --git a/src/Makefile b/src/Makefile
index e4b2a82..486b8f2 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -25,6 +25,9 @@ $(EXEC): boot/boot.o $(BOOT_OBJ) $(DRIVERS_OBJ) $(LIBS_OBJ) $(CORE_OBJ) $(RES_OB
%.o: %.psf
objcopy -I binary -O elf64-x86-64 --prefix-symbol res $^ $@
+%.o: %.bmp
+ objcopy -I binary -O elf64-x86-64 --prefix-symbol res $^ $@
+
clean:
rm -f $(EXEC)
find ./ -name "*.o" -delete
diff --git a/src/boot/multiboot2.cc b/src/boot/multiboot2.cc
index da247ad..0cc8a25 100644
--- a/src/boot/multiboot2.cc
+++ b/src/boot/multiboot2.cc
@@ -69,4 +69,13 @@ char mb2_find_framebuffer(u32* mb2_info_addr, FRAMEBUFFER *fb){
return 1;
}
return 0;
+}
+
+char mb2_find_mem(u32* mb2_info_addr, MEM_INFO *mem){
+ u32* addr=mb2_find_tag(mb2_info_addr,4);
+ if(addr){
+ memcpy(addr, mem, sizeof(MEM_INFO));
+ return 1;
+ }
+ return 0;
} \ No newline at end of file
diff --git a/src/boot/multiboot2.hpp b/src/boot/multiboot2.hpp
index f340269..f86c894 100644
--- a/src/boot/multiboot2.hpp
+++ b/src/boot/multiboot2.hpp
@@ -19,8 +19,16 @@ typedef struct FRAMEBUFFER {
u8 reserved;
} __attribute__((packed)) FRAMEBUFFER;
+typedef struct {
+ TAG_HEADER header;
+ u32 mem_lower;
+ u32 mem_upper;
+} __attribute__((packed)) MEM_INFO;
+
+
u32* mb2_find_tag(u32 *mb2_info_addr, char type);
char mb2_find_bootloader_name(u32* mb2_info_addr, char *return_name);
char mb2_find_new_rsdp(u32* mb2_info_addr, u64 *return_addr, u32 *return_size);
char mb2_find_old_rsdp(u32* mb2_info_addr, u64 *return_addr, u32 *return_size);
-char mb2_find_framebuffer(u32* mb2_info_addr, FRAMEBUFFER *fb); \ No newline at end of file
+char mb2_find_framebuffer(u32* mb2_info_addr, FRAMEBUFFER *fb);
+char mb2_find_mem(u32* mb2_info_addr, MEM_INFO *mem); \ No newline at end of file
diff --git a/src/boucane.cc b/src/boucane.cc
index 5f8c851..060f9cd 100644
--- a/src/boucane.cc
+++ b/src/boucane.cc
@@ -8,6 +8,7 @@
#include "drivers/vgatext.hpp"
#include "libs/stdio.hpp"
#include "libs/string.hpp"
+#include "drivers/bmp.hpp"
u64 kvar_kernel_vma;
u64 kvar_stack_pma;
@@ -16,6 +17,8 @@ u64 kvar_bss_start;
u64 kvar_bss_end;
u64 kvar_terminus_psf_start;
u64 kvar_terminus_psf_end;
+u64 kvar_logo_bmp_start;
+u64 kvar_logo_bmp_end;
void (*printk)(char *str,...)=printf;
@@ -28,6 +31,8 @@ extern "C" void boucane(u64 mb_info){
asm volatile ("movq $__bss_end, %0":"=m"(kvar_bss_end));
asm volatile ("movq $res_binary_res_terminus_psf_start, %0":"=m"(kvar_terminus_psf_start));
asm volatile ("movq $res_binary_res_terminus_psf_end, %0":"=m"(kvar_terminus_psf_end));
+ asm volatile ("movq $res_binary_res_logo_bmp_start, %0":"=m"(kvar_logo_bmp_start));
+ asm volatile ("movq $res_binary_res_logo_bmp_end, %0":"=m"(kvar_logo_bmp_end));
// Init data structures
asm volatile ("call load_gdt");
@@ -54,9 +59,20 @@ extern "C" void boucane(u64 mb_info){
__putchar=vgatext_putchar;
}
}
-
+
// Booting!
printk("Booting Boucane v%d.%d.%d\n",VERSION_MAJOR,VERSION_MINOR, VERSION_PATH);
+ char bootloader[20];
+ if(mb2_find_bootloader_name((u32*)mb_info,bootloader)){
+ printk("System informations -- BOOT:%s ", bootloader);
+ }
+
+ MEM_INFO mem_infos;
+ if(mb2_find_mem((u32*)mb_info,&mem_infos)){
+ u64 mem=mem_infos.mem_upper-mem_infos.mem_lower;
+ mem/=1024;
+ printk("RAM:%dMB\n", mem);
+ }
while(1);
} \ No newline at end of file
diff --git a/src/boucane.hpp b/src/boucane.hpp
index 20145c5..125b192 100644
--- a/src/boucane.hpp
+++ b/src/boucane.hpp
@@ -20,6 +20,8 @@ extern u64 kvar_bss_end;
/// @brief Binary references
extern u64 kvar_terminus_psf_start;
extern u64 kvar_terminus_psf_end;
+extern u64 kvar_logo_bmp_start;
+extern u64 kvar_logo_bmp_end;
// ---- Debug
#define DUMP(var) asm volatile("push $0xABC; push %0; push $0xABC; _%=:; jmp _%="::"r"(var))
diff --git a/src/core/idt.cc b/src/core/idt.cc
index 25264b6..d2b7ccc 100644
--- a/src/core/idt.cc
+++ b/src/core/idt.cc
@@ -1,4 +1,5 @@
#include "idt.hpp"
+#include "boucane.hpp"
#include "core/paging.hpp"
#include "libs/string.hpp"
diff --git a/src/core/int.S b/src/core/int.S
index daf0224..861d5cc 100644
--- a/src/core/int.S
+++ b/src/core/int.S
@@ -6,7 +6,8 @@
.macro call_printk msg
mov \msg, %rdi
mov $0, %eax # Required for variadic functions
- call printk
+ mov $printk,%rcx
+ call *(%rcx)
.endm
.globl INT_DEFAULT
diff --git a/src/core/paging.cc b/src/core/paging.cc
index b21e660..b12fb4c 100644
--- a/src/core/paging.cc
+++ b/src/core/paging.cc
@@ -36,7 +36,10 @@ void paging_enable() {
// Setting up new kernel address space
for(u64 i=0;i<=0x10000000;i+=4096){
+ // Higher half mapping
PAGE_MAP(i);
+ // Allow access to RAM:
+ paging_allocate_addr(kpages[0], i, i, PAGING_OPT_P|PAGING_OPT_RW, 1);
}
// 4096 bytes stack
@@ -145,32 +148,35 @@ void paging_allocate_addr(u64* pml4_table, u64 virt, u64 phy, u16 options, char
// Solve pdp
if(pml4_table[pml4] == 0){
- pml4_table[pml4]=(u64)(useKernelTables ? paging_allocate_table() : VIRT(PAGE_ALLOCATE()));
+ pml4_table[pml4]=(u64)(useKernelTables ? paging_allocate_table() : PAGE_ALLOCATE());
pml4_table[pml4]|=options;
paging_allocate_addr(pml4_table,virt,phy,options,useKernelTables);
return;
}
// Solve pd
- u64* pdp_table=(u64*)(VIRT(PAGE(pml4_table[pml4])));
+ u64* pdp_table=(u64*)(PAGE(pml4_table[pml4]));
+ pdp_table=useKernelTables ? VIRT(pdp_table) : pdp_table;
if(pdp_table[pdp] == 0){
- pdp_table[pdp]=(u64)(useKernelTables ? paging_allocate_table() : VIRT(PAGE_ALLOCATE()));
+ pdp_table[pdp]=(u64)(useKernelTables ? paging_allocate_table() : PAGE_ALLOCATE());
pdp_table[pdp]|=options;
paging_allocate_addr(pml4_table,virt,phy,options,useKernelTables);
return;
}
// Solve pt
- u64* pd_table=(u64*)(VIRT(PAGE(pdp_table[pdp])));
+ u64* pd_table=(u64*)(PAGE(pdp_table[pdp]));
+ pd_table=useKernelTables ? VIRT(pd_table) : pd_table;
if(pd_table[pd] == 0){
- pd_table[pd]=(u64)(useKernelTables ? paging_allocate_table() : VIRT(PAGE_ALLOCATE()));
+ pd_table[pd]=(u64)(useKernelTables ? paging_allocate_table() : PAGE_ALLOCATE());
pd_table[pd]|=options;
paging_allocate_addr(pml4_table,virt,phy,options,useKernelTables);
return;
}
// Solve address
- u64* pt_table=(u64*)(VIRT(PAGE(pd_table[pd])));
+ u64* pt_table=(u64*)(PAGE(pd_table[pd]));
+ pt_table=useKernelTables ? VIRT(pt_table) : pt_table;
if(pt_table[pt] == 0){
pt_table[pt]=PAGE(phy);
pt_table[pt]|=options;
@@ -180,8 +186,7 @@ void paging_allocate_addr(u64* pml4_table, u64 virt, u64 phy, u16 options, char
}
u64* paging_create_task(int npages){
- u64 *pml4=VIRT(PAGE_ALLOCATE());
- u64 sum=(u64)pml4+kvar_kernel_vma;
- paging_allocate_addr(pml4, 0, (u64)PAGE_ALLOCATE(), PAGING_OPT_P|PAGING_OPT_RW, 0);
+ u64 *pml4=PAGE_ALLOCATE();
+ // paging_allocate_addr(pml4, 0, (u64)PAGE_ALLOCATE(), PAGING_OPT_P|PAGING_OPT_RW, 0);
return pml4;
} \ No newline at end of file
diff --git a/src/drivers/bmp.cc b/src/drivers/bmp.cc
new file mode 100644
index 0000000..6f9dad6
--- /dev/null
+++ b/src/drivers/bmp.cc
@@ -0,0 +1,39 @@
+#include "bmp.hpp"
+#include "libs/string.hpp"
+
+#include "drivers/framebuffer.hpp"
+
+void bmp_draw(u8* bmp_data, int posx, int posy){
+ BMP_HEADER header;
+ memcpy(bmp_data, &header, sizeof(BMP_HEADER));
+ if(header.signature!=0x4d42){
+ printk("Invalid BMP data\n");
+ return;
+ }
+
+ // Do not forget, each row is 32bits aligned
+ u32 Bpp=header.bpp/8;
+ u32 lineW=header.width*Bpp;
+ while((lineW&0x3)!=0){
+ lineW++;
+ }
+
+ for(u32 y=0;y<header.height;y++){
+ for(u32 x=0;x<header.width;x++){
+ u32 pos=x*Bpp+y*lineW;
+ u8 *pixel=((u8*)bmp_data)+header.data_offset+pos;
+ FB_PIXEL p;
+ p.x=posx+x;
+ p.y=posy+(header.height-y);
+ p.r=pixel[0];
+ p.g=pixel[1];
+ p.b=pixel[2];
+ //printk("R%d G%d B%d\n",p.r,p.g,p.b);
+ p.a=0;
+ framebuffer_draw(p);
+
+ }
+
+ }
+
+} \ No newline at end of file
diff --git a/src/drivers/bmp.hpp b/src/drivers/bmp.hpp
new file mode 100644
index 0000000..e31d4b3
--- /dev/null
+++ b/src/drivers/bmp.hpp
@@ -0,0 +1,18 @@
+#pragma once
+
+#include "boucane.hpp"
+
+typedef struct {
+ u16 signature;
+ u32 filesize;
+ u32 reserved;
+ u32 data_offset;
+ u32 info_header_size;
+ u32 width;
+ u32 height;
+ u16 planes;
+ u16 bpp;
+ u32 compression;
+} __attribute__((packed)) BMP_HEADER;
+
+void bmp_draw(u8* bmp_data, int x, int y); \ No newline at end of file
diff --git a/src/res/logo.bmp b/src/res/logo.bmp
new file mode 100644
index 0000000..894f020
--- /dev/null
+++ b/src/res/logo.bmp
Binary files differ