Debug this beautiful panicked kernel !
* Stuff I don't remember * stuff * merge * merge * Step 0 : InitTerms() is the bug * Debug stuff * Step 1 : StartPanic is the real problem * Step 1 : StartPanic is the real problem * Step 1 : StartPanic is the real problem * Step 1 : In StartPanic is the real problem * Step 1 : In StartPanic is the real problem * Step 1 : In StartPanic is the real problem * Step 1 : In StartPanic is the real problem * Step 1 : In StartPanic is the real problem * Step 1.5 : \n was a problem * Step 2 : Well... It was a 'sleepy' problem * Step 2 : Well... It was a 'sleepy' problem * Step 2.1 : GetPanicStr is an array * Step 2.2 : Now panic accept 8 chars * Ok then !
This commit is contained in:
parent
d92266ae34
commit
7d5fc6da75
23
Makefile
23
Makefile
|
@ -28,7 +28,7 @@
|
|||
ASM=nasm
|
||||
LD=ld
|
||||
ASMFLAGS=-f elf64
|
||||
LDFLAGS= -melf_x86_64
|
||||
LDFLAGS=-melf_x86_64
|
||||
|
||||
#Folders
|
||||
MBRDIR=boot/grub
|
||||
|
@ -37,7 +37,24 @@ OBJDIR=build/obj
|
|||
BINDIR=build/bin
|
||||
|
||||
# Object to link (temp)
|
||||
l_objects=./build/obj/kaleid/crtlib/memory.o ./build/obj/kaleid/crtlib/rand.o ./build/obj/kaleid/crtlib/string.o ./build/obj/kaleid/crtlib/ultoa.o ./build/obj/kaleid/crtlib/strtol.o ./build/obj/kaleid/crtlib/utoa.o ./build/obj/kaleid/crtlib/status.o ./build/obj/kaleid/crtlib/atoul.o ./build/obj/kaleid/crtlib/atol.o ./build/obj/kaleid/crtlib/itoa.o ./build/obj/kaleid/crtlib/ltoa.o ./build/obj/kaleid/crtlib/atou.o ./build/obj/kaleid/crtlib/arith.o ./build/obj/kaleid/crtlib/atoi.o ./build/obj/kaleid/extras/prog.o ./build/obj/kaleid/extras/argv.o ./build/obj/kaleid/kernel/init/table.o ./build/obj/kaleid/kernel/init/init.o ./build/obj/kaleid/kernel/io/vga.o ./build/obj/kaleid/kernel/io/cursor.o ./build/obj/kaleid/kernel/io/term.o ./build/obj/kaleid/kernel/ke/panic.o ./build/obj/boot/loader.o
|
||||
l_objects=./build/obj/kaleid/crtlib/memory.o \
|
||||
./build/obj/kaleid/crtlib/rand.o \
|
||||
./build/obj/kaleid/crtlib/string.o \
|
||||
./build/obj/kaleid/crtlib/ultoa.o \
|
||||
./build/obj/kaleid/crtlib/utoa.o \
|
||||
./build/obj/kaleid/crtlib/ctype.o \
|
||||
./build/obj/kaleid/crtlib/itoa.o \
|
||||
./build/obj/kaleid/crtlib/ltoa.o \
|
||||
./build/obj/kaleid/crtlib/sprintf.o \
|
||||
./build/obj/kaleid/extras/prog.o \
|
||||
./build/obj/kaleid/extras/argv.o \
|
||||
./build/obj/kaleid/kernel/init/table.o \
|
||||
./build/obj/kaleid/kernel/init/init.o \
|
||||
./build/obj/kaleid/kernel/io/vga.o \
|
||||
./build/obj/kaleid/kernel/io/cursor.o \
|
||||
./build/obj/kaleid/kernel/io/term.o \
|
||||
./build/obj/kaleid/kernel/ke/panic.o \
|
||||
./build/obj/boot/loader.o
|
||||
|
||||
#Color codes
|
||||
CL='\033[0;32m'
|
||||
|
@ -91,6 +108,7 @@ make_disk:
|
|||
@$(MBRDIR)/create_disk.sh $(BINDIR)/disk.img
|
||||
@echo ${CL2}[make_disk]${CL} OK${CL3}
|
||||
|
||||
|
||||
kaleid: kernel loader
|
||||
|
||||
test: kaleid
|
||||
|
@ -98,7 +116,6 @@ test: kaleid
|
|||
@ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 64 > loader_disasm64.asm
|
||||
@ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 32 > loader_disasm32.asm
|
||||
|
||||
|
||||
test32: kaleid
|
||||
@qemu-system-i386 -hda build/bin/disk.img -d cpu_reset,guest_errors,pcall,int -enable-kvm 2> qemu.log &
|
||||
@ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 64 > loader_disasm64.asm
|
||||
|
|
59
Makefile.in
59
Makefile.in
|
@ -27,7 +27,7 @@
|
|||
// The madman's Makefile
|
||||
#include "build/preproc.h"
|
||||
|
||||
CCNAME="/opt/cross-cc/bin/x86_64-elf-gcc"
|
||||
CCNAME=x86_64-elf-gcc
|
||||
CC2NAME=gcc
|
||||
COPTIM=-O2
|
||||
CWARNS=-Wall -Wextra // -Werror=implicit-function-declaration
|
||||
|
@ -35,7 +35,7 @@ CINCLUDES=-Ikaleid/include
|
|||
|
||||
CFLAGS1=-nostdlib -ffreestanding -mcmodel=large // -std=gnu11
|
||||
CFLAGS2=_ASMTYPE -mno-red-zone -mno-mmx -mno-sse -mno-sse2
|
||||
CFLAGS=$(CFLAGS1) $(CFLAGS2)
|
||||
CFLAGS=$(CFLAGS1) $(CFLAGS2) -DNDEBUG
|
||||
|
||||
CC=$(CCNAME) $(COPTIM) $(CWARNS) $(CFLAGS) $(CINCLUDES)
|
||||
|
||||
|
@ -48,16 +48,7 @@ KERNDIR=kaleid/kernel
|
|||
SYSTDIR=kaleid/system
|
||||
LINXDIR=kaleid/test
|
||||
|
||||
//----------------------------------------------------------------------------#
|
||||
// TESTING MAKEFILE
|
||||
|
||||
pseudo_kern:
|
||||
$(ASM) $(BOOTFLAGS) $(BOOTDIR)/pseudo_kernel.s -o $(OBJDIR)/boot/pkernel.bin
|
||||
|
||||
testing: bootloader pseudo_kern
|
||||
cat $(BINDIR)/bootloader.bin $(OBJDIR)/boot/pkernel.bin > $(BINDIR)/boot.bin
|
||||
|
||||
//----------------------------------------------------------------------------#
|
||||
// COMMON MAKEFILE
|
||||
|
||||
COBJDIR=$(OBJDIR)/$(COMMDIR)
|
||||
|
@ -69,25 +60,25 @@ TCC=$(CC2NAME) $(COPTIM) $(CWARNS) $(CINCLUDES)
|
|||
KCC=$(CC) -D_OSK_SOURCE -D_KALEID_KERNEL
|
||||
|
||||
comm-convert:
|
||||
COMPILE_CONVRT1(itoa) -D_NEED_ITOA
|
||||
COMPILE_CONVRT1(ltoa) -D_NEED_LTOA
|
||||
COMPILE_CONVRT1(utoa) -D_NEED_UTOA
|
||||
COMPILE_CONVRT1(ultoa) -D_NEED_ULTOA
|
||||
COMPILE_CONVRT2(atoi) -D_NEED_ATOI
|
||||
COMPILE_CONVRT2(atol) -D_NEED_ATOL
|
||||
COMPILE_CONVRT2(atou) -D_NEED_ATOU
|
||||
COMPILE_CONVRT2(atoul) -D_NEED_ATOUL
|
||||
@COMPILE_CONVRT1(itoa) -D_NEED_ITOA
|
||||
@COMPILE_CONVRT1(ltoa) -D_NEED_LTOA
|
||||
@COMPILE_CONVRT1(utoa) -D_NEED_UTOA
|
||||
@COMPILE_CONVRT1(ultoa) -D_NEED_ULTOA
|
||||
@COMPILE_CONVRT2(atoi) -D_NEED_ATOI
|
||||
@COMPILE_CONVRT2(atol) -D_NEED_ATOL
|
||||
@COMPILE_CONVRT2(atou) -D_NEED_ATOU
|
||||
@COMPILE_CONVRT2(atoul) -D_NEED_ATOUL
|
||||
|
||||
common: comm-convert
|
||||
COMPILE_COMMON(rand)
|
||||
COMPILE_COMMON(ctype)
|
||||
COMPILE_COMMON(string)
|
||||
COMPILE_COMMON(status)
|
||||
COMPILE_COMMON(memory) -fno-strict-aliasing
|
||||
COMPILE_COMMON(strtol)
|
||||
COMPILE_COMMON(sprintf)
|
||||
COMPILE_COMMON(../extras/prog)
|
||||
COMPILE_COMMON(../extras/argv)
|
||||
@COMPILE_COMMON(rand)
|
||||
@COMPILE_COMMON(ctype)
|
||||
@COMPILE_COMMON(string)
|
||||
@COMPILE_COMMON(status)
|
||||
@COMPILE_COMMON(memory) -fno-strict-aliasing
|
||||
@COMPILE_COMMON(strtol)
|
||||
@COMPILE_COMMON(sprintf)
|
||||
@COMPILE_COMMON(../extras/prog)
|
||||
@COMPILE_COMMON(../extras/argv)
|
||||
|
||||
tests: common
|
||||
$(TCC) -c $(LINXDIR)/test-common.c -o $(LOBJDIR)/test-common.o
|
||||
|
@ -101,12 +92,12 @@ KOBJDIR=$(OBJDIR)/$(KERNDIR)
|
|||
KERNOBJS=KOBJ6(init/init, init/table, ke/panic, io/term, io/cursor, io/vga)
|
||||
|
||||
kernel: common
|
||||
COMPILE_KERNEL(init/init)
|
||||
COMPILE_KERNEL(init/table)
|
||||
COMPILE_KERNEL(ke/panic)
|
||||
COMPILE_KERNEL(io/cursor)
|
||||
COMPILE_KERNEL(io/term)
|
||||
COMPILE_KERNEL(io/vga)
|
||||
@COMPILE_KERNEL(init/init)
|
||||
@COMPILE_KERNEL(init/table)
|
||||
@COMPILE_KERNEL(ke/panic)
|
||||
@COMPILE_KERNEL(io/cursor)
|
||||
@COMPILE_KERNEL(io/term)
|
||||
@COMPILE_KERNEL(io/vga)
|
||||
//LINK_KERNEL(kaleid-kernel.elf)
|
||||
|
||||
//----------------------------------------------------------------------------#
|
||||
|
|
|
@ -38,6 +38,10 @@ sudo losetup /dev/loop1 $1 -o 1048576 > /dev/null #mounting the logical partitio
|
|||
|
||||
echo ${CL2}[grub-install.sh]${NC} Mounting volume... \(mount\)${CL3}
|
||||
## Mount
|
||||
if [ -e $2/boot ]
|
||||
then
|
||||
sudo umount $2 > /dev/null
|
||||
fi
|
||||
sudo mount /dev/loop1 $2 > /dev/null
|
||||
|
||||
echo ${CL2}[grub-install.sh]${NC} Installing grub... \(grub-install\)${CL3}
|
||||
|
|
|
@ -29,8 +29,8 @@ CL3='\033[0m'
|
|||
NC='\033[1;37m'
|
||||
|
||||
set -e #exit if error
|
||||
#sleep 3
|
||||
sync
|
||||
sleep 1
|
||||
echo ${CL2}[umount.sh]${NC} Unmounting volume... \(umount\)${CL3}
|
||||
sudo umount $1
|
||||
echo ${CL2}[umount.sh]${NC} Unmounting image... \(losetup\)${CL3}
|
||||
|
|
|
@ -23,6 +23,10 @@
|
|||
; along with OS/K. If not, see <https://www.gnu.org/licenses/>. ;
|
||||
;=----------------------------------------------------------------------------=;
|
||||
|
||||
[global temporize]
|
||||
[global bitemporize]
|
||||
[global tritemporize]
|
||||
|
||||
[BITS 64]
|
||||
|
||||
temporize:
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
; You should have received a copy of the GNU General Public License ;
|
||||
; along with OS/K. If not, see <https://www.gnu.org/licenses/>. ;
|
||||
;=----------------------------------------------------------------------------=;
|
||||
|
||||
[global testf]
|
||||
|
||||
;;VIDEO
|
||||
%define TRAM 0xB8000 ; [T]ext[RAM]
|
||||
|
@ -41,6 +41,17 @@ VGA_X dq 0
|
|||
|
||||
[BITS 64]
|
||||
|
||||
testf:
|
||||
push rsi
|
||||
push rbx
|
||||
mov esi, teststr
|
||||
mov bl, 0xF
|
||||
call write
|
||||
pop rsi
|
||||
pop rbx
|
||||
ret
|
||||
teststr: db "Salut",0
|
||||
|
||||
|
||||
;-----------------------------------------------------------------------;
|
||||
; x64/LM Clear Text Screen Function ;
|
||||
|
|
|
@ -62,16 +62,16 @@ MB_start:
|
|||
; Prints 'ERR:XX' where 'XX' is the str in AX ;
|
||||
; ---------------------------------------------------------------------------- ;
|
||||
Error:
|
||||
mov word [CODE], ax
|
||||
mov word [.code], ax
|
||||
push esi
|
||||
mov bl, 0x0c
|
||||
mov esi, ERGO
|
||||
mov esi, .ergo
|
||||
call write32
|
||||
pop esi
|
||||
jmp Die
|
||||
ERGO : db "A", 219, 219, " Error "
|
||||
CODE : db "00"
|
||||
db 0x0
|
||||
.ergo : db 219, 219, 219, " Error "
|
||||
.code : db "00"
|
||||
db 0x0
|
||||
; ---------------------------------------------------------------------------- ;
|
||||
; Kills the mind of your computer to get it prostrated ;
|
||||
; ---------------------------------------------------------------------------- ;
|
||||
|
@ -101,11 +101,11 @@ lbegin:
|
|||
call clear ; Clear the screen
|
||||
|
||||
;; BEGIN OF CHECKLIST
|
||||
call MB_check ; Check Multiboot State
|
||||
call MB_check ; Check Multiboot State, ERR 01
|
||||
|
||||
call Check_cpuid ; Check if cpuid supported
|
||||
call Is64Bits ; Check if long mode available
|
||||
call CheckA20 ; Check if A20 is correctly enable
|
||||
call Check_cpuid ; Check if cpuid supported, ERR 02
|
||||
call Is64Bits ; Check if long mode available, ERR 03
|
||||
call CheckA20 ; Check if A20 is correctly enable, ERR 04
|
||||
|
||||
;; BEGIN OF WORK
|
||||
call Setup_paging ; Enable paging
|
||||
|
@ -126,6 +126,7 @@ lbegin:
|
|||
|
||||
x64_K db "Now in x64 long mode", 0x0A, 0x0D, 0x0
|
||||
GoKernel db "Launching Kernel...", 0
|
||||
nokernel db 219, 219, 219, " Error 05 : Kernel returns",0
|
||||
|
||||
_loader64:
|
||||
;; Some cleanup
|
||||
|
@ -152,7 +153,12 @@ _loader64:
|
|||
call tritemporize ; Let time to see
|
||||
|
||||
extern StartKern
|
||||
jmp StartKern
|
||||
call StartKern
|
||||
|
||||
;; We must never reach this point ------------------------------------------- ;;
|
||||
call tritemporize ; Let time to see
|
||||
call clear
|
||||
mov bl, 0x0c
|
||||
mov esi, nokernel ; Error 05
|
||||
call write
|
||||
jmp Die
|
||||
|
|
|
@ -230,6 +230,7 @@ size_t vsnprintf(char *str, size_t n, const char *fmt, va_list ap)
|
|||
|
||||
// Unknown/unsupported modifier :|
|
||||
*str++ = mod;
|
||||
ret++;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,6 +61,7 @@ typedef enum KernelState_t KernelState_t;
|
|||
|
||||
// Get Process_t structure of current CPU
|
||||
#define GetCurCPU() (cpuTable[_GetCurCPU()])
|
||||
#define PANICSTR_SIZE 1024
|
||||
|
||||
//------------------------------------------//
|
||||
|
||||
|
@ -73,7 +74,7 @@ struct Processor_t
|
|||
int index;
|
||||
|
||||
// Panic string
|
||||
char panicStr[1024];
|
||||
char panicStr[PANICSTR_SIZE];
|
||||
|
||||
// Number of ticks since boot time
|
||||
ulong ticks;
|
||||
|
|
|
@ -96,6 +96,9 @@ extern Terminal_t *stdOut;
|
|||
#define GetStdOut() (stdOut)
|
||||
#define SetStdOut(x) (stdOut = (x))
|
||||
|
||||
// Debug purposes
|
||||
volatile ushort *vga;
|
||||
|
||||
//------------------------------------------//
|
||||
|
||||
#ifndef _NO_DEBUG
|
||||
|
|
|
@ -25,11 +25,17 @@
|
|||
#include <kernel/term.h>
|
||||
#include <kernel/panic.h>
|
||||
|
||||
|
||||
extern void testf(void);
|
||||
|
||||
//
|
||||
// Entry point of the Kaleid kernel
|
||||
//
|
||||
noreturn void StartKern(void* mbt, unsigned int mb_magic)
|
||||
noreturn void StartKern(void *mbInfo, int mbMagic)
|
||||
{
|
||||
(void)mbInfo;
|
||||
(void)mbMagic;
|
||||
|
||||
// We're not ready to deal with interrupts
|
||||
DisableIRQs();
|
||||
|
||||
|
|
|
@ -27,5 +27,7 @@
|
|||
int cpuCount = 1;
|
||||
Processor_t cpuTable[NCPUS] = {0};
|
||||
|
||||
Terminal_t *stdOut, *stdDbg;
|
||||
Terminal_t *stdOut = 0, *stdDbg = 0;
|
||||
|
||||
volatile ushort *vga = (volatile ushort *)0xB8000;
|
||||
|
||||
|
|
|
@ -32,12 +32,10 @@ extern Terminal_t VGA_Terminal;
|
|||
//
|
||||
void InitTerms(void)
|
||||
{
|
||||
KalAssert(!GetStdOut() && !GetStdDbg());
|
||||
//KalAssert(!GetStdOut() && !GetStdDbg());
|
||||
|
||||
VGA_Init();
|
||||
|
||||
// vgaTerm.initDone = INITOK;
|
||||
|
||||
SetStdDbg(&VGA_Terminal);
|
||||
SetStdOut(&VGA_Terminal);
|
||||
|
||||
|
|
|
@ -37,12 +37,12 @@
|
|||
#define VGA_ComputeEntry(ch, cl) (((ushort)(ch)) | (ushort)(cl) << 8)
|
||||
|
||||
//
|
||||
// Fill terminal with '\0'
|
||||
// Clear terminal
|
||||
//
|
||||
error_t VGA_ClearTermUnlocked(Terminal_t *term)
|
||||
{
|
||||
const uchar color = VGA_ComputeColorCode(term->fgColor, term->bgColor);
|
||||
const ushort filler = VGA_ComputeEntry('\0', color);
|
||||
const ushort filler = VGA_ComputeEntry(' ', color);
|
||||
const size_t bufsize = term->width * term->height;
|
||||
|
||||
// Fill the buffer
|
||||
|
@ -70,15 +70,15 @@ error_t VGA_PutOnTermUnlocked(Terminal_t *term, char ch)
|
|||
// Line feed first takes us to the very end of the line
|
||||
// Later in this function we actually do the line feed
|
||||
else if (ch == '\n') {
|
||||
term->currentY = term->width - 1;
|
||||
term->currentX = term->width - 1;
|
||||
}
|
||||
|
||||
// Tabulations account for "term->tabSize" spaces
|
||||
else if (ch == '\t') {
|
||||
prevY = term->currentY;
|
||||
prevY = term->currentX;
|
||||
for (i = 0; i < term->tabSize; i++) {
|
||||
// Make sure tabulations can't spread over two lines
|
||||
if (term->currentY == prevY) {
|
||||
if (term->currentX == prevY) {
|
||||
VGA_PutOnTermUnlocked(term, ' ');
|
||||
}
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ error_t VGA_PutOnTermUnlocked(Terminal_t *term, char ch)
|
|||
|
||||
else {
|
||||
ushort *buffer = (ushort *)term->data;
|
||||
const size_t offset = VGA_ComputeOffset(term, term->currentY, term->currentY);
|
||||
const size_t offset = VGA_ComputeOffset(term, term->currentX, term->currentY);
|
||||
buffer[offset] = VGA_ComputeEntry(ch, VGA_ComputeColorCode(term->fgColor, term->bgColor));
|
||||
}
|
||||
|
||||
|
|
|
@ -60,16 +60,16 @@ noreturn void StartPanic(const char *fmt, ...)
|
|||
fmt = "(no message given)";
|
||||
}
|
||||
|
||||
if (GetPanicStr()) {
|
||||
GetStdOut()->PrintOnTermUnlocked(GetStdOut(), "\ndouble panic!");
|
||||
if (*GetPanicStr()) {
|
||||
GetStdOut()->PrintOnTermUnlocked(GetStdOut(), "\nDouble panic!");
|
||||
HaltCPU();
|
||||
}
|
||||
|
||||
va_start(ap, fmt);
|
||||
vsnprintf(GetPanicStr(), sizeof GetPanicStr(), fmt, ap);
|
||||
vsnprintf(GetPanicStr(), PANICSTR_SIZE, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
GetStdOut()->PrintOnTermUnlocked(GetStdOut(), "\npanic!\n\n");
|
||||
GetStdOut()->PrintOnTermUnlocked(GetStdOut(), "\nPanic!\n\n");
|
||||
GetStdOut()->PrintOnTermUnlocked(GetStdOut(), GetPanicStr());
|
||||
|
||||
HaltCPU();
|
||||
|
|
Loading…
Reference in New Issue