mirror of
https://github.com/Tom-on64/kern.git
synced 2026-11-03 18:22:22 +00:00
Added bigError()
This commit is contained in:
@@ -36,6 +36,7 @@ uint8_t loadFile(inode_t* inode, void* dest) {
|
|||||||
|
|
||||||
if (totalBlocks > 0) {
|
if (totalBlocks > 0) {
|
||||||
// TODO: Indirect extents
|
// TODO: Indirect extents
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ void drawLine(int32_t x1, int32_t y1, int32_t x2, int32_t y2, uint32_t color) {
|
|||||||
int8_t sx = (x1 < x2) ? 1 : -1;
|
int8_t sx = (x1 < x2) ? 1 : -1;
|
||||||
int8_t sy = (y1 < y2) ? 1 : -1;
|
int8_t sy = (y1 < y2) ? 1 : -1;
|
||||||
int16_t err = dx + dy;
|
int16_t err = dx + dy;
|
||||||
|
|
||||||
|
|
||||||
// TODO: Sometimes the condition isn't met for some reason and it breaks everything
|
// TODO: Sometimes the condition isn't met for some reason and it breaks everything
|
||||||
while (!(x1 == x2 && y1 == y2)) {
|
while (!(x1 == x2 && y1 == y2)) {
|
||||||
|
|||||||
+1
-1
@@ -368,7 +368,7 @@ CODE_SEG equ GDT.codeDescriptor - GDT.start
|
|||||||
DATA_SEG equ GDT.dataDescriptor - GDT.start
|
DATA_SEG equ GDT.dataDescriptor - GDT.start
|
||||||
|
|
||||||
;; VBE Stuff
|
;; VBE Stuff
|
||||||
;; !! IF YOU WANT TO SELECT ANY VALUE IN THE SETUP, SET THESE TO ZERO !!
|
;; XXX IF YOU WANT TO SELECT ANY VALUE IN THE SETUP, SET THESE TO ZERO XXX
|
||||||
width: dw 1920
|
width: dw 1920
|
||||||
height: dw 1080
|
height: dw 1080
|
||||||
bpp: db 32
|
bpp: db 32
|
||||||
|
|||||||
+76
-8
@@ -6,6 +6,8 @@
|
|||||||
#include <fs/fs.h>
|
#include <fs/fs.h>
|
||||||
#include <screen/gfxmode.h>
|
#include <screen/gfxmode.h>
|
||||||
|
|
||||||
|
void bigError();
|
||||||
|
|
||||||
__attribute__ ((section("entry")))
|
__attribute__ ((section("entry")))
|
||||||
void main() {
|
void main() {
|
||||||
// Physical memory manager setup
|
// Physical memory manager setup
|
||||||
@@ -27,22 +29,29 @@ void main() {
|
|||||||
deinitMemoryRegion(MEMMAP_AREA, maxBlocks / BLOCKS_PER_BYTE);
|
deinitMemoryRegion(MEMMAP_AREA, maxBlocks / BLOCKS_PER_BYTE);
|
||||||
|
|
||||||
// Load root dir, find kernel INode and parse it
|
// Load root dir, find kernel INode and parse it
|
||||||
superblock_t* superblock = (superblock_t*)SUPERBLOCK_LOC;
|
superblock_t* sb = (superblock_t*)SUPERBLOCK_LOC;
|
||||||
superblock->rootInodePtr = BOOT_FIRST_INODE_LOC + sizeof(inode_t);
|
sb->rootInodePtr = BOOT_FIRST_INODE_LOC + sizeof(inode_t);
|
||||||
diskRead(superblock->dataStart * 8, 8, (void*)SCRATCH_BLOCK_LOC);
|
inode_t* root = (inode_t*)sb->rootInodePtr;
|
||||||
|
diskRead(root->extent[0].block * 8, root->extent[0].length * 8, (void*)SCRATCH_BLOCK_LOC);
|
||||||
|
|
||||||
inode_t* inode;
|
inode_t* inode;
|
||||||
if ((inode = getInode("kernel.bin")) == NULL) {
|
if ((inode = getInode("kernel.bin")) == NULL) {
|
||||||
__asm__ volatile ("cli; hlt" : : "a"(0xDeadBeef));
|
// kernel.bin doesn't exist??? very bad -> error
|
||||||
|
bigError(0xDEAD);
|
||||||
} else { loadFile(inode, (void*)KERNEL_LOC); }
|
} else { loadFile(inode, (void*)KERNEL_LOC); }
|
||||||
|
|
||||||
if ((inode = getInode("term16n.fnt")) == NULL) {
|
if ((inode = getInode("term16n.fnt")) != NULL) {
|
||||||
__asm__ volatile ("cli; hlt" : : "a"(0xDeadBeef));
|
loadFile(inode, (void*)FONT_LOC);
|
||||||
} else { loadFile(inode, (void*)FONT_LOC); }
|
} else if ((inode = getInode("testfont.fnt")) != NULL) {
|
||||||
|
loadFile(inode, (void*)FONT_LOC);
|
||||||
|
} else {
|
||||||
|
// No font found, bad.
|
||||||
|
bigError(0xBeef);
|
||||||
|
}
|
||||||
|
|
||||||
// Virtual memory manager setup
|
// Virtual memory manager setup
|
||||||
if (setupVirtualMemoryManager() != 0) {
|
if (setupVirtualMemoryManager() != 0) {
|
||||||
while (1);
|
bigError(0xCafe);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Identity map VBE framebuffer
|
// Identity map VBE framebuffer
|
||||||
@@ -67,5 +76,64 @@ void main() {
|
|||||||
|
|
||||||
// Call/jump to kernel
|
// Call/jump to kernel
|
||||||
((void(*)(void))0xC0000000)();
|
((void(*)(void))0xC0000000)();
|
||||||
|
bigError(0xffffffff);
|
||||||
|
}
|
||||||
|
|
||||||
|
void rect(uint32_t c, uint16_t x, uint16_t y, uint16_t w, uint16_t h) {
|
||||||
|
uint8_t* vidmem = (uint8_t*)gfxMode->physicalBasePtr;
|
||||||
|
uint8_t bytesPerPx = gfxMode->bpp / 8;
|
||||||
|
uint32_t convColor = convertColor(c);
|
||||||
|
|
||||||
|
for (uint32_t dx = 0; dx < w; dx++) {
|
||||||
|
for (uint32_t dy = 0; dy < h; dy++) {
|
||||||
|
uint32_t offset = (((y + dy) * gfxMode->xRes) + (x + dx)) * bytesPerPx;
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < gfxMode->bpp; i++) {
|
||||||
|
vidmem[offset + i] = (uint8_t)(convColor >> (i*8));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Something went VERY wrong.
|
||||||
|
* Eg. kernel.bin is missing, no filesystem, Virtual Memory failed, etc.
|
||||||
|
*/
|
||||||
|
void bigError(uint32_t err) {
|
||||||
|
// Red BG
|
||||||
|
rect(0x00ff0000, 0, 0, gfxMode->xRes, gfxMode->yRes);
|
||||||
|
// E
|
||||||
|
rect(0x00ffffff, 20, 10, 10, 50);
|
||||||
|
rect(0x00ffffff, 30, 10, 30, 10);
|
||||||
|
rect(0x00ffffff, 30, 30, 30, 10);
|
||||||
|
rect(0x00ffffff, 30, 50, 30, 10);
|
||||||
|
// R
|
||||||
|
rect(0x00ffffff, 70, 10, 10, 50);
|
||||||
|
rect(0x00ffffff, 70, 10, 30, 10);
|
||||||
|
rect(0x00ffffff, 70, 30, 30, 10);
|
||||||
|
rect(0x00ffffff, 90, 10, 10, 30);
|
||||||
|
rect(0x00ffffff, 80, 40, 10, 10);
|
||||||
|
rect(0x00ffffff, 90, 50, 10, 10);
|
||||||
|
// R
|
||||||
|
rect(0x00ffffff, 110, 10, 10, 50);
|
||||||
|
rect(0x00ffffff, 110, 10, 30, 10);
|
||||||
|
rect(0x00ffffff, 110, 30, 30, 10);
|
||||||
|
rect(0x00ffffff, 130, 10, 10, 30);
|
||||||
|
rect(0x00ffffff, 120, 40, 10, 10);
|
||||||
|
rect(0x00ffffff, 130, 50, 10, 10);
|
||||||
|
// O
|
||||||
|
rect(0x00ffffff, 150, 10, 10, 50);
|
||||||
|
rect(0x00ffffff, 170, 10, 10, 50);
|
||||||
|
rect(0x00ffffff, 150, 10, 30, 10);
|
||||||
|
rect(0x00ffffff, 150, 50, 30, 10);
|
||||||
|
// R
|
||||||
|
rect(0x00ffffff, 190, 10, 10, 50);
|
||||||
|
rect(0x00ffffff, 190, 10, 30, 10);
|
||||||
|
rect(0x00ffffff, 190, 30, 30, 10);
|
||||||
|
rect(0x00ffffff, 210, 10, 10, 30);
|
||||||
|
rect(0x00ffffff, 200, 40, 10, 10);
|
||||||
|
rect(0x00ffffff, 210, 50, 10, 10);
|
||||||
|
|
||||||
|
__asm__ volatile ("cli; hlt" :: "a"(err));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user