Bunch of stuff, and readd stuff for bochs
This commit is contained in:
parent
1e52f2b5e7
commit
f75fd15a7a
4
.ccls
Normal file
4
.ccls
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
clang
|
||||||
|
%c -std=c99
|
||||||
|
%c -isystem./src/kernel/
|
||||||
|
%c -fno-builtin
|
||||||
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,3 +1,5 @@
|
|||||||
.vscode/
|
.vscode/
|
||||||
|
.ccls-cache/
|
||||||
build/
|
build/
|
||||||
toolchain/
|
toolchain/
|
||||||
|
bochs_dbg.log
|
||||||
7
bochs_config
Normal file
7
bochs_config
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
megs: 128
|
||||||
|
romimage: file=/usr/share/bochs/BIOS-bochs-legacy, address=0xffff0000
|
||||||
|
ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14
|
||||||
|
ata0-master: type=disk, path=build/main.img, mode=flat
|
||||||
|
boot: disk
|
||||||
|
mouse: enabled=0
|
||||||
|
display_library: x, options="gui_debug"
|
||||||
26
bx_enh_dbg.ini
Normal file
26
bx_enh_dbg.ini
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
# bx_enh_dbg_ini
|
||||||
|
SeeReg[0] = TRUE
|
||||||
|
SeeReg[1] = TRUE
|
||||||
|
SeeReg[2] = TRUE
|
||||||
|
SeeReg[3] = TRUE
|
||||||
|
SeeReg[4] = FALSE
|
||||||
|
SeeReg[5] = FALSE
|
||||||
|
SeeReg[6] = FALSE
|
||||||
|
SeeReg[7] = FALSE
|
||||||
|
SingleCPU = FALSE
|
||||||
|
ShowIOWindows = TRUE
|
||||||
|
ShowButtons = TRUE
|
||||||
|
SeeRegColors = TRUE
|
||||||
|
ignoreNxtT = TRUE
|
||||||
|
ignSSDisasm = TRUE
|
||||||
|
UprCase = 0
|
||||||
|
DumpInAsciiMode = 3
|
||||||
|
isLittleEndian = TRUE
|
||||||
|
DefaultAsmLines = 512
|
||||||
|
DumpWSIndex = 0
|
||||||
|
DockOrder = 0x123
|
||||||
|
ListWidthPix[0] = 487
|
||||||
|
ListWidthPix[1] = 665
|
||||||
|
ListWidthPix[2] = 760
|
||||||
|
MainWindow = 1440, 23, 1916, 1030
|
||||||
|
FontName = Normal
|
||||||
94
debug.sh
Executable file
94
debug.sh
Executable file
@ -0,0 +1,94 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
echo --------
|
||||||
|
echo STARTING
|
||||||
|
echo --------
|
||||||
|
read -p "Do you want to clean old build files? (y/n) " yn
|
||||||
|
|
||||||
|
case $yn in
|
||||||
|
y )
|
||||||
|
|
||||||
|
echo ---------------------------;
|
||||||
|
echo Removing Old Build Files...;
|
||||||
|
echo ---------------------------;
|
||||||
|
|
||||||
|
make clean;
|
||||||
|
echo -----;
|
||||||
|
echo Done!;
|
||||||
|
echo -----;
|
||||||
|
;;
|
||||||
|
n )
|
||||||
|
echo ---------;
|
||||||
|
echo Proceding;
|
||||||
|
echo ---------;
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
echo ------------
|
||||||
|
echo COMPILING OS
|
||||||
|
echo ------------
|
||||||
|
|
||||||
|
make -s
|
||||||
|
|
||||||
|
echo ---------
|
||||||
|
echo Finished!
|
||||||
|
echo ---------
|
||||||
|
read -p "Do you want to make to make a bootable image? [Requires sudo] (y/n) " yn
|
||||||
|
case $yn in
|
||||||
|
y)
|
||||||
|
echo ----------------
|
||||||
|
echo Installing GRUB!
|
||||||
|
echo ----------------
|
||||||
|
|
||||||
|
sudo losetup -d /dev/loop800
|
||||||
|
dd if=/dev/zero of=build/main.img bs=512 count=50000
|
||||||
|
mkdir -p build/mnt
|
||||||
|
sudo losetup -P /dev/loop800 build/main.img
|
||||||
|
sudo parted /dev/loop800 mktable msdos
|
||||||
|
sudo parted /dev/loop800 mkpart primary fat16 2048s 100%
|
||||||
|
sudo parted /dev/loop800p1 set 1 boot on
|
||||||
|
sudo mkfs.fat -F16 /dev/loop800p1
|
||||||
|
sudo mount /dev/loop800p1 build/mnt
|
||||||
|
sudo mkdir build/mnt/boot
|
||||||
|
sudo mkdir build/mnt/boot/grub
|
||||||
|
sudo mkdir build/mnt/misc
|
||||||
|
sudo mkdir build/mnt/misc/src
|
||||||
|
sudo cp -r src/* build/mnt/src
|
||||||
|
sudo cp -r grub/* build/mnt/boot/grub
|
||||||
|
sudo cp build/nanite.bin build/mnt/boot/nanite
|
||||||
|
sudo grub-install \
|
||||||
|
--modules="part_msdos" \
|
||||||
|
--boot-directory=build/mnt/boot \
|
||||||
|
--target=i386-pc \
|
||||||
|
--bootloader-id=GRUB \
|
||||||
|
/dev/loop800 -v
|
||||||
|
sudo umount build/mnt
|
||||||
|
sudo losetup -d /dev/loop800
|
||||||
|
|
||||||
|
;;
|
||||||
|
n ) echo exiting...;
|
||||||
|
exit;;
|
||||||
|
* ) echo invalid response;
|
||||||
|
exit 1;;
|
||||||
|
esac
|
||||||
|
echo ---------
|
||||||
|
echo Finished!
|
||||||
|
echo ---------
|
||||||
|
|
||||||
|
read -p "Do you want to Start BOCHS? (y/n) " yn
|
||||||
|
|
||||||
|
case $yn in
|
||||||
|
y )
|
||||||
|
echo -------------
|
||||||
|
echo STARTING BOCHS
|
||||||
|
echo -------------
|
||||||
|
bochs -f bochs_config -dbg -dbglog bochs_dbg.log
|
||||||
|
echo --------
|
||||||
|
echo Finshed!
|
||||||
|
echo --------
|
||||||
|
|
||||||
|
;;
|
||||||
|
n ) echo exiting...;
|
||||||
|
exit;;
|
||||||
|
* ) echo invalid response;
|
||||||
|
exit 1;;
|
||||||
|
esac
|
||||||
|
|
||||||
@ -16,11 +16,11 @@ terminal_input console
|
|||||||
terminal_output gfxterm
|
terminal_output gfxterm
|
||||||
|
|
||||||
insmod gfxmenu
|
insmod gfxmenu
|
||||||
loadfont /boot/grub/themes/nanite/font10.pf2
|
# loadfont /boot/grub/themes/nanite/font10.pf2
|
||||||
loadfont /boot/grub/themes/nanite/font12.pf2
|
# loadfont /boot/grub/themes/nanite/font12.pf2
|
||||||
loadfont /boot/grub/themes/nanite/font14.pf2
|
# loadfont /boot/grub/themes/nanite/font14.pf2
|
||||||
set theme=/boot/grub/themes/nanite/theme.txt
|
# set theme=/boot/grub/themes/nanite/theme.txt
|
||||||
export theme
|
# export theme
|
||||||
insmod png
|
insmod png
|
||||||
|
|
||||||
menuentry "NANITE" {
|
menuentry "NANITE" {
|
||||||
|
|||||||
@ -9,6 +9,9 @@
|
|||||||
#include "io.h"
|
#include "io.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
#include <dri/serial.h>>
|
||||||
|
|
||||||
|
extern uint16_t DEBUG_COM_PORT;
|
||||||
|
|
||||||
ISRHandler g_ISRHandlers[256];
|
ISRHandler g_ISRHandlers[256];
|
||||||
|
|
||||||
@ -62,13 +65,13 @@ void __attribute__((cdecl)) ISR_Handler(Registers* regs) {
|
|||||||
g_ISRHandlers[regs->interrupt](regs);
|
g_ISRHandlers[regs->interrupt](regs);
|
||||||
|
|
||||||
else if (regs->interrupt >= 32)
|
else if (regs->interrupt >= 32)
|
||||||
printf("Unhandled Interrupt %d\n", regs->interrupt);
|
Serial_Printf(DEBUG_COM_PORT, "Unhandled Interrupt %d\n", regs->interrupt);
|
||||||
else {
|
else {
|
||||||
printf("Unhandled Exception %d %s\n", regs->interrupt, g_Exceptions[regs->interrupt]);
|
Serial_Printf(DEBUG_COM_PORT, "Unhandled Exception %d %s\n", regs->interrupt, g_Exceptions[regs->interrupt]);
|
||||||
printf(" EAX=%x EBX=%x ECX=%x EDX=%x ESI=%x EDI=%x\n", regs->eax, regs->ebx, regs->ecx, regs->edx, regs->esi, regs->edi);
|
Serial_Printf(DEBUG_COM_PORT, " EAX=%x EBX=%x ECX=%x EDX=%x ESI=%x EDI=%x\n", regs->eax, regs->ebx, regs->ecx, regs->edx, regs->esi, regs->edi);
|
||||||
printf(" ESP=%x EBP=%x EIP=%x EFLAGS=%x CS=%x DS=%x SS=%x\n", regs->esp, regs->ebp, regs->eip, regs->eflags, regs->cs, regs->ds, regs->ss);
|
Serial_Printf(DEBUG_COM_PORT, " ESP=%x EBP=%x EIP=%x EFLAGS=%x CS=%x DS=%x SS=%x\n", regs->esp, regs->ebp, regs->eip, regs->eflags, regs->cs, regs->ds, regs->ss);
|
||||||
printf(" INTERRUPT=%x ERRORCODE=%x\n", regs->interrupt, regs->error);
|
Serial_Printf(DEBUG_COM_PORT, " INTERRUPT=%x ERRORCODE=%x\n", regs->interrupt, regs->error);
|
||||||
printf("KERNEL PANIC!\n");
|
Serial_Printf(DEBUG_COM_PORT, "KERNEL PANIC!\n");
|
||||||
kernel_panic();
|
kernel_panic();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -7,13 +7,13 @@
|
|||||||
|
|
||||||
global Reboot
|
global Reboot
|
||||||
Reboot:
|
Reboot:
|
||||||
XOR AL, AL
|
xor al, al
|
||||||
IN AL, 0x64
|
in al, 0x64
|
||||||
TEST AL, 0x02
|
test al, 0x02
|
||||||
JNZ Reboot
|
jnz Reboot
|
||||||
|
|
||||||
MOV AL, 0xFC
|
mov al, 0xFC
|
||||||
OUT 0x64, AL
|
out 0x64, al
|
||||||
|
|
||||||
global Read_CR0
|
global Read_CR0
|
||||||
Read_CR0:
|
Read_CR0:
|
||||||
@ -25,7 +25,9 @@ Write_CR0:
|
|||||||
push ebp
|
push ebp
|
||||||
mov ebp, esp
|
mov ebp, esp
|
||||||
mov eax, [ebp+8]
|
mov eax, [ebp+8]
|
||||||
|
push eax
|
||||||
mov cr0, eax
|
mov cr0, eax
|
||||||
|
pop eax
|
||||||
pop ebp
|
pop ebp
|
||||||
retn
|
retn
|
||||||
|
|
||||||
@ -42,3 +44,9 @@ Write_CR3:
|
|||||||
mov cr3, eax
|
mov cr3, eax
|
||||||
pop ebp
|
pop ebp
|
||||||
retn
|
retn
|
||||||
|
|
||||||
|
global Enable_Paging
|
||||||
|
Enable_Paging:
|
||||||
|
mov eax, cr4
|
||||||
|
or eax, 0x00000010
|
||||||
|
mov cr4, eax
|
||||||
|
|||||||
@ -12,3 +12,4 @@ unsigned long __attribute__((cdecl)) Read_CR0();
|
|||||||
void __attribute__((cdecl)) Write_CR0(unsigned long value);
|
void __attribute__((cdecl)) Write_CR0(unsigned long value);
|
||||||
unsigned long* __attribute__((cdecl)) Read_CR3();
|
unsigned long* __attribute__((cdecl)) Read_CR3();
|
||||||
void __attribute__((cdecl)) Write_CR3(unsigned long* value);
|
void __attribute__((cdecl)) Write_CR3(unsigned long* value);
|
||||||
|
void __attribute__((cdecl)) Enable_Paging();
|
||||||
|
|||||||
@ -12,8 +12,8 @@
|
|||||||
|
|
||||||
extern uint16_t DEBUG_COM_PORT;
|
extern uint16_t DEBUG_COM_PORT;
|
||||||
|
|
||||||
unsigned long* Page_Directory = (unsigned long*) 0x9c000;
|
unsigned long* Page_Directory = (unsigned long*) 0x9C000;
|
||||||
unsigned long* Page_Table = (unsigned long*) 0x9d000;
|
unsigned long* Page_Table = (unsigned long*) 0x9D000;
|
||||||
|
|
||||||
void Memory_Page_Init()
|
void Memory_Page_Init()
|
||||||
{
|
{
|
||||||
@ -28,11 +28,14 @@ void Memory_Page_Init()
|
|||||||
Serial_Printf(DEBUG_COM_PORT, "MEMORY:> Inititalizing Page Directory and Table.\n");
|
Serial_Printf(DEBUG_COM_PORT, "MEMORY:> Inititalizing Page Directory and Table.\n");
|
||||||
|
|
||||||
// fill the first entry of the page directory
|
// fill the first entry of the page directory
|
||||||
// Page_Directory[0] = Page_Table;
|
Page_Directory[0] = *Page_Table;
|
||||||
Page_Directory[0] = Page_Directory[0] | 3; // attribute set to: supervisor level, read/write
|
Page_Directory[0] = Page_Directory[0] | 3; // attribute set to: supervisor level, read/write
|
||||||
for(i=1; i<1024; i++) {
|
for(i=1; i<1024; i++) {
|
||||||
Page_Directory[i] = 0 | 2; // attribute set to: supervisor level, read/write
|
Page_Directory[i] = 0 | 2; // attribute set to: supervisor level, read/write
|
||||||
}
|
}
|
||||||
|
Enable_Paging();
|
||||||
Write_CR3(Page_Directory);
|
Write_CR3(Page_Directory);
|
||||||
Write_CR0(Read_CR0() | 0x80000000); // set the paging bit in CR0 to 1
|
// Write_CR0(Read_CR0() | 0x80000000); // set the paging bit in CR0 to 1
|
||||||
|
/* THATS IT... I GIVE UP! */
|
||||||
|
Serial_Printf(DEBUG_COM_PORT, "HERE!\n");
|
||||||
}
|
}
|
||||||
@ -2,10 +2,9 @@ ENTRY(start)
|
|||||||
|
|
||||||
SECTIONS
|
SECTIONS
|
||||||
{
|
{
|
||||||
. = 1M;
|
. = ALIGN(8);
|
||||||
|
|
||||||
.boot : { KEEP(*(.multiboot_header))}
|
.entry : { KEEP(*(.multiboot_header)) __entry_start = .; *(.entry) }
|
||||||
.entry : { __entry_start = .; *(.entry) }
|
|
||||||
.text : { __text_start = .; *(.text) }
|
.text : { __text_start = .; *(.text) }
|
||||||
.data : { __data_start = .; *(.data) }
|
.data : { __data_start = .; *(.data) }
|
||||||
.rodata : { __rodata_start = .; *(.rodata) }
|
.rodata : { __rodata_start = .; *(.rodata) }
|
||||||
|
|||||||
@ -61,7 +61,7 @@ void __attribute__((section(".entry"))) start(uint64_t multiboot_magic, void *mu
|
|||||||
|
|
||||||
// unsure why this is not working, will look into it later...
|
// unsure why this is not working, will look into it later...
|
||||||
printf("Initializing Memory Paging...");
|
printf("Initializing Memory Paging...");
|
||||||
// Memory_Page_Init();
|
Memory_Page_Init();
|
||||||
printf("Done!\n");
|
printf("Done!\n");
|
||||||
printf("Multiboot Magic: %d\n", multiboot_magic);
|
printf("Multiboot Magic: %d\n", multiboot_magic);
|
||||||
|
|
||||||
|
|||||||
@ -5,6 +5,8 @@
|
|||||||
\*----------------*/
|
\*----------------*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
#define FLAG_SET(x, flag) x |= (flag)
|
#define FLAG_SET(x, flag) x |= (flag)
|
||||||
#define FLAG_UNSET(x, flag) x &= ~(flag)
|
#define FLAG_UNSET(x, flag) x &= ~(flag)
|
||||||
#define BCD2BIN(bcd) ((((bcd)&15) + ((bcd)>>4)*10))
|
#define BCD2BIN(bcd) ((((bcd)&15) + ((bcd)>>4)*10))
|
||||||
|
|||||||
@ -21,20 +21,20 @@ void append(char s[], char n) {
|
|||||||
s[len + 1] = '\0';
|
s[len + 1] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
void Print_Storage_Types(int masterFDDType, int slaveFDDType)
|
// void Print_Storage_Types(int masterFDDType, int slaveFDDType)
|
||||||
{
|
// {
|
||||||
// Master FDD
|
// // Master FDD
|
||||||
if (masterFDDType == 0) printf("No Master Floppy Drive Detected!\n");
|
// if (masterFDDType == 0) printf("No Master Floppy Drive Detected!\n");
|
||||||
if (masterFDDType == 1) printf("Master Floppy Drive Detected!\nType: 360 KB 5.25 Inch Drive\n");
|
// if (masterFDDType == 1) printf("Master Floppy Drive Detected!\nType: 360 KB 5.25 Inch Drive\n");
|
||||||
if (masterFDDType == 2) printf("Master Floppy Drive Detected!\nType: 1.2 MB 5.25 Inch Drive\n");
|
// if (masterFDDType == 2) printf("Master Floppy Drive Detected!\nType: 1.2 MB 5.25 Inch Drive\n");
|
||||||
if (masterFDDType == 3) printf("Master Floppy Drive Detected!\nType: 720 KB 3.5 Inch Drive\n");
|
// if (masterFDDType == 3) printf("Master Floppy Drive Detected!\nType: 720 KB 3.5 Inch Drive\n");
|
||||||
if (masterFDDType == 4) printf("Master Floppy Drive Detected!\nType: 1.44 MB 3.5 Inch Drive\n");
|
// if (masterFDDType == 4) printf("Master Floppy Drive Detected!\nType: 1.44 MB 3.5 Inch Drive\n");
|
||||||
if (masterFDDType == 5) printf("Master Floppy Drive Detected!\nType: 2.88 MB 3.5 Inch Drive\n");
|
// if (masterFDDType == 5) printf("Master Floppy Drive Detected!\nType: 2.88 MB 3.5 Inch Drive\n");
|
||||||
// Slave FDD
|
// // Slave FDD
|
||||||
if (slaveFDDType == 0) printf("No Slave Floppy Drive Detected!\n");
|
// if (slaveFDDType == 0) printf("No Slave Floppy Drive Detected!\n");
|
||||||
if (slaveFDDType == 1) printf("Slave Floppy Drive Detected!\nType: 360 KB 5.25 Inch Drive\n");
|
// if (slaveFDDType == 1) printf("Slave Floppy Drive Detected!\nType: 360 KB 5.25 Inch Drive\n");
|
||||||
if (slaveFDDType == 2) printf("Slave Floppy Drive Detected!\nType: 1.2 MB 5.25 Inch Drive\n");
|
// if (slaveFDDType == 2) printf("Slave Floppy Drive Detected!\nType: 1.2 MB 5.25 Inch Drive\n");
|
||||||
if (slaveFDDType == 3) printf("Slave Floppy Drive Detected!\nType: 720 KB 3.5 Inch Drive\n");
|
// if (slaveFDDType == 3) printf("Slave Floppy Drive Detected!\nType: 720 KB 3.5 Inch Drive\n");
|
||||||
if (slaveFDDType == 4) printf("Slave Floppy Drive Detected!\nType: 1.44 MB 3.5 Inch Drive\n");
|
// if (slaveFDDType == 4) printf("Slave Floppy Drive Detected!\nType: 1.44 MB 3.5 Inch Drive\n");
|
||||||
if (slaveFDDType == 5) printf("Slave Floppy Drive Detected!\nType: 2.88 MB 3.5 Inch Drive\n");
|
// if (slaveFDDType == 5) printf("Slave Floppy Drive Detected!\nType: 2.88 MB 3.5 Inch Drive\n");
|
||||||
}
|
// }
|
||||||
@ -9,4 +9,4 @@
|
|||||||
|
|
||||||
int string_length(char s[]);
|
int string_length(char s[]);
|
||||||
void append(char s[], char n);
|
void append(char s[], char n);
|
||||||
void Print_Storage_Types(int masterFDDType, int slaveFDDType);
|
// void Print_Storage_Types(int masterFDDType, int slaveFDDType);
|
||||||
@ -6,4 +6,4 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define LOGO " _ _____ _ __________________\n / | / / | / | / / _/_ __/ ____/\n / |/ / /| | / |/ // / / / / __/ \n / /| / ___ |/ /| // / / / / /___ \n/_/ |_/_/ |_/_/ |_/___/ /_/ /_____/ \n"
|
#define LOGO " _ _____ _ __________________\n / | / / | / | / / _/_ __/ ____/\n / |/ / /| | / |/ // / / / / __/ \n / /| / ___ |/ /| // / / / / /___ \n/_/ |_/_/ |_/_/ |_/___/ /_/ /_____/ \n"
|
||||||
#define VERSION "RD-00042"
|
#define VERSION "RD-00043"
|
||||||
Loading…
x
Reference in New Issue
Block a user