Compare commits
1 Commits
DebugLoggi
...
Temp
| Author | SHA1 | Date | |
|---|---|---|---|
| b3392eb322 |
@ -59,6 +59,10 @@ _start:
|
|||||||
movl $(boot_page_table - 0xC0000000 + 0x003), boot_page_directory - 0xC0000000 + 0
|
movl $(boot_page_table - 0xC0000000 + 0x003), boot_page_directory - 0xC0000000 + 0
|
||||||
movl $(boot_page_table - 0xC0000000 + 0x003), boot_page_directory - 0xC0000000 + 768 * 4
|
movl $(boot_page_table - 0xC0000000 + 0x003), boot_page_directory - 0xC0000000 + 768 * 4
|
||||||
|
|
||||||
|
# movl source, destination
|
||||||
|
movl $(boot_page_directory - 0xC0000000 + 0x003), boot_page_directory - 0xC0000000 + 1024 * 4
|
||||||
|
|
||||||
|
|
||||||
# Set cr3 to the address of the boot_page_directory
|
# Set cr3 to the address of the boot_page_directory
|
||||||
movl $(boot_page_directory - 0xC0000000), %ecx
|
movl $(boot_page_directory - 0xC0000000), %ecx
|
||||||
movl %ecx, %cr3
|
movl %ecx, %cr3
|
||||||
@ -98,7 +102,7 @@ isPaging:
|
|||||||
call prekernelSetup
|
call prekernelSetup
|
||||||
|
|
||||||
# Unmap the identity mapping as it is now unnecessary
|
# Unmap the identity mapping as it is now unnecessary
|
||||||
# movl $0, boot_page_directory + 0
|
movl $0, boot_page_directory + 0
|
||||||
|
|
||||||
|
|
||||||
call kernel
|
call kernel
|
||||||
|
|||||||
35
kernel/drivers/rtl8139/rtl8139.cpp
Normal file
35
kernel/drivers/rtl8139/rtl8139.cpp
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#include "rtl8139.h"
|
||||||
|
#include "../io/io.h"
|
||||||
|
|
||||||
|
|
||||||
|
rtl8139::rtl8139(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
rtl8139::~rtl8139(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void rtl8139::Wake(){
|
||||||
|
outb(ioaddr + CONFIG_1, 0x0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void rtl8139::Reset(){
|
||||||
|
outb(ioaddr + CMD_OFFSET, 0x10);
|
||||||
|
// Wait for the reset procedure
|
||||||
|
while((inb(ioaddr + CMD_OFFSET) & 0x10) != 0) continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void rtl8139::Sleep(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void rtl8139::Receive(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void rtl8139::Transmit(){
|
||||||
|
|
||||||
|
}
|
||||||
35
kernel/drivers/rtl8139/rtl8139.h
Normal file
35
kernel/drivers/rtl8139/rtl8139.h
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#pragma once
|
||||||
|
#define MAC05_OFFSET 0x00 // size 6
|
||||||
|
#define MAC07_OFFSET 0x08 // size 8
|
||||||
|
#define RBSTART_OFFSET 0x30 // size 4
|
||||||
|
#define CMD_OFFSET 0x37 // size 1
|
||||||
|
#define IMR_OFFSET 0x3C // size 2
|
||||||
|
#define ISR_OFFSET 0x3E // size 2
|
||||||
|
#define CONFIG_1 0x52
|
||||||
|
|
||||||
|
// Copyright © Nigel Barink 2023
|
||||||
|
// Information source: https://wiki.osdev.org/RTL8139
|
||||||
|
|
||||||
|
// Get me some networking !! XD
|
||||||
|
class NetworkDevice {
|
||||||
|
protected:
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class rtl8139 : public NetworkDevice {
|
||||||
|
public:
|
||||||
|
rtl8139();
|
||||||
|
~rtl8139();
|
||||||
|
|
||||||
|
|
||||||
|
void Wake();
|
||||||
|
void Reset();
|
||||||
|
|
||||||
|
void Sleep();
|
||||||
|
void Receive();
|
||||||
|
void Transmit();
|
||||||
|
private:
|
||||||
|
int ioaddr ;
|
||||||
|
|
||||||
|
};
|
||||||
@ -4,7 +4,7 @@
|
|||||||
#include "../i386/processor.h"
|
#include "../i386/processor.h"
|
||||||
#include "../memory/VirtualMemoryManager.h"
|
#include "../memory/VirtualMemoryManager.h"
|
||||||
#include "../syscalls.h"
|
#include "../syscalls.h"
|
||||||
|
#include "../klog.h"
|
||||||
|
|
||||||
IDT_entry idt_table[256];
|
IDT_entry idt_table[256];
|
||||||
IDT_ptr idt_ptr;
|
IDT_ptr idt_ptr;
|
||||||
@ -91,7 +91,6 @@ void irs_handler (registers* regs) {
|
|||||||
printf("EIP: 0x%x\n", regs->eip);
|
printf("EIP: 0x%x\n", regs->eip);
|
||||||
printf("EAX: 0x%x\n", regs->eax);
|
printf("EAX: 0x%x\n", regs->eax);
|
||||||
printf("EBP: 0x%x\n", regs->ebp);
|
printf("EBP: 0x%x\n", regs->ebp);
|
||||||
while(true);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 9:
|
case 9:
|
||||||
|
|||||||
@ -1,23 +1,22 @@
|
|||||||
/*
|
/*
|
||||||
Copyright © Nigel Barink 2023
|
Copyright © Nigel Barink 2023
|
||||||
*/
|
*/
|
||||||
#include "memory/memory.h"
|
|
||||||
#include "memory/KernelHeap.h"
|
|
||||||
#include "memory/gdt/gdtc.h"
|
|
||||||
#include "memory/TaskStateSegment.h"
|
|
||||||
#include "supervisorterminal/superVisorTerminal.h"
|
|
||||||
#include "drivers/vga/VBE.h"
|
|
||||||
#include "pci/pci.h"
|
|
||||||
#include "drivers/pit/pit.h"
|
|
||||||
#include "i386/processor.h"
|
|
||||||
#include "terminal/kterm.h"
|
|
||||||
#include "interrupts/idt.h"
|
|
||||||
#include "storage/vfs/vfs.h"
|
|
||||||
#include "storage/filesystems/FAT/FAT.h"
|
|
||||||
#include "acpi/acpi.h"
|
#include "acpi/acpi.h"
|
||||||
#include "memory/VirtualMemoryManager.h"
|
#include "drivers/pit/pit.h"
|
||||||
|
#include "drivers/vga/VBE.h"
|
||||||
|
#include "i386/processor.h"
|
||||||
|
#include "interrupts/idt.h"
|
||||||
#include "klog.h"
|
#include "klog.h"
|
||||||
|
#include "memory/KernelHeap.h"
|
||||||
|
#include "memory/TaskStateSegment.h"
|
||||||
|
#include "memory/VirtualMemoryManager.h"
|
||||||
|
#include "memory/gdt/gdtc.h"
|
||||||
|
#include "memory/memory.h"
|
||||||
|
#include "pci/pci.h"
|
||||||
|
#include "storage/filesystems/FAT/FAT.h"
|
||||||
|
#include "storage/vfs/vfs.h"
|
||||||
|
#include "supervisorterminal/superVisorTerminal.h"
|
||||||
|
#include "terminal/kterm.h"
|
||||||
|
|
||||||
extern BootInfoBlock *BIB;
|
extern BootInfoBlock *BIB;
|
||||||
extern "C" void LoadGlobalDescriptorTable();
|
extern "C" void LoadGlobalDescriptorTable();
|
||||||
@ -37,29 +36,40 @@ void initBootDrive(){
|
|||||||
printf("Part1: %d, Part2: %d, Part3: %d\n", part1, part2, part3);
|
printf("Part1: %d, Part2: %d, Part3: %d\n", part1, part2, part3);
|
||||||
ATAPIO::Identify(ATAPIO_PORT::Primary, DEVICE_DRIVE::MASTER);
|
ATAPIO::Identify(ATAPIO_PORT::Primary, DEVICE_DRIVE::MASTER);
|
||||||
}
|
}
|
||||||
|
extern uint32_t *boot_page_directory;
|
||||||
|
extern "C" void kernel() {
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
__asm__ __volatile__("NOP");
|
||||||
|
};
|
||||||
|
// kterm_init();
|
||||||
|
|
||||||
|
uint32_t cr3;
|
||||||
|
__asm__ __volatile__("mov %%cr3, %%eax\n\t"
|
||||||
|
"mov %%eax, %0\n\t"
|
||||||
|
: "=m"(cr3)
|
||||||
|
:
|
||||||
|
: "%eax");
|
||||||
|
|
||||||
|
printf("value of cr3: 0x%x\n", cr3);
|
||||||
|
// printf("page directory entry : 0x%x\n" , boot_page_directory[1023]);
|
||||||
|
while (true)
|
||||||
|
;
|
||||||
|
|
||||||
extern "C" void kernel ()
|
|
||||||
{
|
|
||||||
kterm_init();
|
|
||||||
setup_tss();
|
setup_tss();
|
||||||
initGDT();
|
initGDT();
|
||||||
initidt();
|
initidt();
|
||||||
LoadGlobalDescriptorTable();
|
LoadGlobalDescriptorTable();
|
||||||
flush_tss();
|
flush_tss();
|
||||||
|
|
||||||
|
|
||||||
print_info("Memory setup complete!\n");
|
print_info("Memory setup complete!\n");
|
||||||
// Enable interrupts
|
// Enable interrupts
|
||||||
asm volatile("STI");
|
asm volatile("STI");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
initHeap();
|
initHeap();
|
||||||
//pit_initialise();
|
pit_initialise();
|
||||||
|
|
||||||
|
PCI::Scan();
|
||||||
//ACPI::initialize();
|
|
||||||
//PCI::Scan();
|
|
||||||
processor::initialize();
|
processor::initialize();
|
||||||
processor::enable_protectedMode();
|
processor::enable_protectedMode();
|
||||||
initBootDrive();
|
initBootDrive();
|
||||||
@ -69,11 +79,13 @@ extern "C" void kernel ()
|
|||||||
print_info("Hello info!\n");
|
print_info("Hello info!\n");
|
||||||
print_err("Hello error!\n");
|
print_err("Hello error!\n");
|
||||||
|
|
||||||
|
ACPI::initialize();
|
||||||
|
|
||||||
#define VFS_EXAMPLE
|
#define VFS_EXAMPLE
|
||||||
#ifdef VFS_EXAMPLE
|
#ifdef VFS_EXAMPLE
|
||||||
auto fontFile = VirtualFileSystem::open("/FONT PSF", 0);
|
auto fontFile = VirtualFileSystem::open("/FONT PSF", 0);
|
||||||
printf("Size of font file: %d bytes\n", fontFile->root->size); // COOL This Works like a charm
|
printf("Size of font file: %d bytes\n",
|
||||||
|
fontFile->root->size); // COOL This Works like a charm
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -84,5 +96,4 @@ extern "C" void kernel ()
|
|||||||
startSuperVisorTerminal();
|
startSuperVisorTerminal();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -53,7 +53,7 @@ extern "C" void prekernelSetup ( unsigned long magic, multiboot_info_t* mbi)
|
|||||||
if(mmap->type == MULTIBOOT_MEMORY_ACPI_RECLAIMABLE)
|
if(mmap->type == MULTIBOOT_MEMORY_ACPI_RECLAIMABLE)
|
||||||
allocate_region(mmap->addr, mmap->len);
|
allocate_region(mmap->addr, mmap->len);
|
||||||
// memory map
|
// memory map
|
||||||
Immediate_Map(mmap->addr , mmap->addr);
|
Immediate_Map(PADDR_TO_VADDR(mmap->addr) , mmap->addr);
|
||||||
if(mmap->type == MULTIBOOT_MEMORY_RESERVED)
|
if(mmap->type == MULTIBOOT_MEMORY_RESERVED)
|
||||||
allocate_region(mmap->addr, mmap->len);
|
allocate_region(mmap->addr, mmap->len);
|
||||||
if(mmap->type == MULTIBOOT_MEMORY_NVS)
|
if(mmap->type == MULTIBOOT_MEMORY_NVS)
|
||||||
|
|||||||
Reference in New Issue
Block a user