Debug interrupts, allow to show bmp images
This commit is contained in:
parent
717556178c
commit
66f2ca6246
12 changed files with 209 additions and 12 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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);
|
||||
char mb2_find_framebuffer(u32* mb2_info_addr, FRAMEBUFFER *fb);
|
||||
char mb2_find_mem(u32* mb2_info_addr, MEM_INFO *mem);
|
|
@ -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);
|
||||
}
|
|
@ -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))
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "idt.hpp"
|
||||
#include "boucane.hpp"
|
||||
#include "core/paging.hpp"
|
||||
#include "libs/string.hpp"
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
39
src/drivers/bmp.cc
Normal file
39
src/drivers/bmp.cc
Normal file
|
@ -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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
18
src/drivers/bmp.hpp
Normal file
18
src/drivers/bmp.hpp
Normal file
|
@ -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);
|
BIN
src/res/logo.bmp
Normal file
BIN
src/res/logo.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 356 KiB |
95
tools/logo.svg
Normal file
95
tools/logo.svg
Normal file
|
@ -0,0 +1,95 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="80mm"
|
||||
height="80mm"
|
||||
viewBox="0 0 80 80"
|
||||
version="1.1"
|
||||
id="svg8"
|
||||
inkscape:version="1.0.2 (e86c870879, 2021-01-15, custom)"
|
||||
sodipodi:docname="logo.svg"
|
||||
inkscape:export-filename="/home/loic/Documents/Git/boucane/src/res/logo.png"
|
||||
inkscape:export-xdpi="96"
|
||||
inkscape:export-ydpi="96">
|
||||
<defs
|
||||
id="defs2">
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
id="linearGradient843">
|
||||
<stop
|
||||
style="stop-color:#b3b3b3;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop839" />
|
||||
<stop
|
||||
style="stop-color:#b3b3b3;stop-opacity:0;"
|
||||
offset="1"
|
||||
id="stop841" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient843"
|
||||
id="linearGradient845"
|
||||
x1="0"
|
||||
y1="40"
|
||||
x2="80"
|
||||
y2="40"
|
||||
gradientUnits="userSpaceOnUse" />
|
||||
</defs>
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="1.2512358"
|
||||
inkscape:cx="148.75224"
|
||||
inkscape:cy="239.43042"
|
||||
inkscape:document-units="mm"
|
||||
inkscape:current-layer="layer1"
|
||||
inkscape:document-rotation="0"
|
||||
showgrid="false"
|
||||
inkscape:window-width="1892"
|
||||
inkscape:window-height="1014"
|
||||
inkscape:window-x="10"
|
||||
inkscape:window-y="48"
|
||||
inkscape:window-maximized="0" />
|
||||
<metadata
|
||||
id="metadata5">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1">
|
||||
<rect
|
||||
style="fill:url(#linearGradient845);stroke:none;stroke-width:2;stop-color:#000000;fill-opacity:1"
|
||||
id="rect835"
|
||||
width="80"
|
||||
height="80"
|
||||
x="7.1054274e-15"
|
||||
y="7.2164497e-15" />
|
||||
<ellipse
|
||||
style="fill:#ffaaaa;stroke:#808080;stroke-width:2;stop-color:#000000"
|
||||
id="path833"
|
||||
cx="40"
|
||||
cy="40"
|
||||
rx="15.068277"
|
||||
ry="14.545761" />
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 2.7 KiB |
Loading…
Add table
Reference in a new issue