mirror of
https://github.com/wichtounet/thor-os.git
synced 2025-09-09 20:43:34 -04:00
Testing
This commit is contained in:
parent
e319431a20
commit
d25e567201
@ -11,7 +11,9 @@ jmp second_step
|
|||||||
|
|
||||||
%include "intel_16.asm"
|
%include "intel_16.asm"
|
||||||
|
|
||||||
|
FREE_SEGMENT equ 0x5000
|
||||||
FREE_BASE equ 0x4500
|
FREE_BASE equ 0x4500
|
||||||
|
|
||||||
KERNEL_BASE equ 0x600 ; 0x600:0x0 (0x6000)
|
KERNEL_BASE equ 0x600 ; 0x600:0x0 (0x6000)
|
||||||
|
|
||||||
DAP:
|
DAP:
|
||||||
@ -42,7 +44,7 @@ second_step:
|
|||||||
mov ds, ax
|
mov ds, ax
|
||||||
|
|
||||||
; Used for disk access
|
; Used for disk access
|
||||||
xor ax, ax
|
mov ax, FREE_SEGMENT
|
||||||
mov gs, ax
|
mov gs, ax
|
||||||
|
|
||||||
mov si, load_kernel
|
mov si, load_kernel
|
||||||
@ -52,7 +54,7 @@ second_step:
|
|||||||
|
|
||||||
mov byte [DAP.count], 1
|
mov byte [DAP.count], 1
|
||||||
mov word [DAP.offset], FREE_BASE
|
mov word [DAP.offset], FREE_BASE
|
||||||
mov word [DAP.segment], 0
|
mov word [DAP.segment], FREE_SEGMENT
|
||||||
mov dword [DAP.lba], 0
|
mov dword [DAP.lba], 0
|
||||||
|
|
||||||
call extended_read
|
call extended_read
|
||||||
@ -64,7 +66,7 @@ second_step:
|
|||||||
|
|
||||||
mov byte [DAP.count], 1
|
mov byte [DAP.count], 1
|
||||||
mov word [DAP.offset], FREE_BASE
|
mov word [DAP.offset], FREE_BASE
|
||||||
mov word [DAP.segment], 0
|
mov word [DAP.segment], FREE_SEGMENT
|
||||||
|
|
||||||
mov di, [partition_start]
|
mov di, [partition_start]
|
||||||
mov word [DAP.lba], di
|
mov word [DAP.lba], di
|
||||||
@ -115,7 +117,7 @@ second_step:
|
|||||||
mov ah, [sectors_per_cluster]
|
mov ah, [sectors_per_cluster]
|
||||||
mov byte [DAP.count], ah
|
mov byte [DAP.count], ah
|
||||||
mov word [DAP.offset], FREE_BASE
|
mov word [DAP.offset], FREE_BASE
|
||||||
mov word [DAP.segment], 0
|
mov word [DAP.segment], FREE_SEGMENT
|
||||||
|
|
||||||
; Compute LBA from root_dir_start
|
; Compute LBA from root_dir_start
|
||||||
mov ax, [root_dir_start]
|
mov ax, [root_dir_start]
|
||||||
@ -212,6 +214,12 @@ second_step:
|
|||||||
mov si, star
|
mov si, star
|
||||||
call print_16
|
call print_16
|
||||||
|
|
||||||
|
mov di, [current_segment]
|
||||||
|
call print_int_16
|
||||||
|
|
||||||
|
mov si, star
|
||||||
|
call print_16
|
||||||
|
|
||||||
movzx ax, [sectors_per_cluster]
|
movzx ax, [sectors_per_cluster]
|
||||||
mov word [DAP.count], ax
|
mov word [DAP.count], ax
|
||||||
mov word [DAP.offset], 0x0
|
mov word [DAP.offset], 0x0
|
||||||
@ -229,6 +237,15 @@ second_step:
|
|||||||
|
|
||||||
mov word [DAP.lba], ax
|
mov word [DAP.lba], ax
|
||||||
|
|
||||||
|
mov di, ax
|
||||||
|
call print_int_16
|
||||||
|
|
||||||
|
mov si, star
|
||||||
|
call print_16
|
||||||
|
|
||||||
|
mov di, [current_cluster]
|
||||||
|
call print_int_16
|
||||||
|
|
||||||
call extended_read
|
call extended_read
|
||||||
|
|
||||||
mov ax, [loaded_clusters]
|
mov ax, [loaded_clusters]
|
||||||
@ -247,7 +264,7 @@ second_step:
|
|||||||
; Read the FAT sector
|
; Read the FAT sector
|
||||||
mov word [DAP.count], 1
|
mov word [DAP.count], 1
|
||||||
mov word [DAP.offset], FREE_BASE
|
mov word [DAP.offset], FREE_BASE
|
||||||
mov word [DAP.segment], 0x0
|
mov word [DAP.segment], FREE_SEGMENT
|
||||||
mov word [DAP.lba], ax
|
mov word [DAP.lba], ax
|
||||||
|
|
||||||
call extended_read
|
call extended_read
|
||||||
|
@ -31,8 +31,8 @@ struct bios_e820_entry {
|
|||||||
uint16_t acpi;
|
uint16_t acpi;
|
||||||
} __attribute__((packed));
|
} __attribute__((packed));
|
||||||
|
|
||||||
extern int16_t bios_e820_entry_count;
|
//extern bios_e820_entry bios_e820_entries[MAX_E820_ENTRIES];
|
||||||
extern bios_e820_entry bios_e820_entries[MAX_E820_ENTRIES];
|
//extern int16_t bios_e820_entry_count;
|
||||||
|
|
||||||
struct mmapentry {
|
struct mmapentry {
|
||||||
uint64_t base;
|
uint64_t base;
|
||||||
|
@ -31,9 +31,8 @@ typedef uint64_t size_t;
|
|||||||
#define CODE_16
|
#define CODE_16
|
||||||
#include "e820.hpp" //Just for the address of the e820 map
|
#include "e820.hpp" //Just for the address of the e820 map
|
||||||
|
|
||||||
|
//e820::bios_e820_entry e820::bios_e820_entries[e820::MAX_E820_ENTRIES];
|
||||||
e820::bios_e820_entry e820::bios_e820_entries[e820::MAX_E820_ENTRIES];
|
//int16_t e820::bios_e820_entry_count = 0;
|
||||||
int16_t e820::bios_e820_entry_count = 0;
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@ -66,7 +65,8 @@ void reset_segments(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
int detect_memory_e820(){
|
int detect_memory_e820(){
|
||||||
auto smap = &e820::bios_e820_entries[0];
|
auto smap = reinterpret_cast<e820::bios_e820_entry*>(0x5008);
|
||||||
|
//auto smap = &e820::bios_e820_entries[0];
|
||||||
|
|
||||||
uint16_t entries = 0;
|
uint16_t entries = 0;
|
||||||
|
|
||||||
@ -99,7 +99,10 @@ int detect_memory_e820(){
|
|||||||
void detect_memory(){
|
void detect_memory(){
|
||||||
//TODO If e820 fails, try other solutions to get memory map
|
//TODO If e820 fails, try other solutions to get memory map
|
||||||
|
|
||||||
e820::bios_e820_entry_count = detect_memory_e820();
|
auto t = detect_memory_e820();
|
||||||
|
//asm volatile("xchg bx, bx");
|
||||||
|
*reinterpret_cast<int16_t*>(0x5000) = t;
|
||||||
|
//asm volatile("xchg bx, bx");
|
||||||
}
|
}
|
||||||
|
|
||||||
void disable_interrupts(){
|
void disable_interrupts(){
|
||||||
|
@ -15,9 +15,11 @@ size_t _available_memory;
|
|||||||
} //end of namespace anonymous
|
} //end of namespace anonymous
|
||||||
|
|
||||||
void e820::finalize_memory_detection(){
|
void e820::finalize_memory_detection(){
|
||||||
if(bios_e820_entry_count > 0){
|
auto t = *reinterpret_cast<int16_t*>(0x5000);
|
||||||
for(int64_t i = 0; i < bios_e820_entry_count; ++i){
|
auto smap = reinterpret_cast<e820::bios_e820_entry*>(0x5008);
|
||||||
auto& bios_entry = bios_e820_entries[i];
|
if(t > 0){
|
||||||
|
for(int64_t i = 0; i < t; ++i){
|
||||||
|
auto& bios_entry = smap[i];
|
||||||
auto& os_entry = e820_mmap[i];
|
auto& os_entry = e820_mmap[i];
|
||||||
|
|
||||||
uint64_t base = bios_entry.base_low + (static_cast<uint64_t>(bios_entry.base_high) << 32);
|
uint64_t base = bios_entry.base_low + (static_cast<uint64_t>(bios_entry.base_high) << 32);
|
||||||
@ -39,11 +41,14 @@ void e820::finalize_memory_detection(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint64_t e820::mmap_entry_count(){
|
uint64_t e820::mmap_entry_count(){
|
||||||
return bios_e820_entry_count;
|
auto t = *reinterpret_cast<int16_t*>(0x5000);
|
||||||
|
return t;
|
||||||
|
//return bios_e820_entry_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e820::mmap_failed(){
|
bool e820::mmap_failed(){
|
||||||
return bios_e820_entry_count <= 0;
|
auto t = *reinterpret_cast<int16_t*>(0x5000);
|
||||||
|
return t <= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const e820::mmapentry& e820::mmap_entry(uint64_t i){
|
const e820::mmapentry& e820::mmap_entry(uint64_t i){
|
||||||
|
@ -120,10 +120,16 @@ uint64_t* allocate_block(uint64_t blocks){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
asm volatile("xchg bx, bx");
|
||||||
|
|
||||||
|
|
||||||
if(!current_mmap_entry){
|
if(!current_mmap_entry){
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
auto block = reinterpret_cast<uint64_t*>(current_mmap_entry_position);
|
auto block = reinterpret_cast<uint64_t*>(current_mmap_entry_position);
|
||||||
|
|
||||||
paging::identity_map(block, blocks);
|
paging::identity_map(block, blocks);
|
||||||
@ -206,16 +212,22 @@ void init_head(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void expand_heap(malloc_header_chunk* current){
|
void expand_heap(malloc_header_chunk* current){
|
||||||
|
asm volatile("xchg bx, bx");
|
||||||
|
|
||||||
//Allocate a new block of memory
|
//Allocate a new block of memory
|
||||||
uint64_t* block = allocate_block(MIN_BLOCKS);
|
uint64_t* block = allocate_block(MIN_BLOCKS);
|
||||||
|
|
||||||
//Transform it into a malloc chunk
|
//Transform it into a malloc chunk
|
||||||
auto header = reinterpret_cast<malloc_header_chunk*>(block);
|
auto header = reinterpret_cast<malloc_header_chunk*>(block);
|
||||||
|
|
||||||
|
asm volatile("xchg bx, bx");
|
||||||
|
|
||||||
//Update the sizes
|
//Update the sizes
|
||||||
header->size() = MIN_BLOCKS * BLOCK_SIZE - META_SIZE;
|
header->size() = MIN_BLOCKS * BLOCK_SIZE - META_SIZE;
|
||||||
header->footer()->size() = header->size();
|
header->footer()->size() = header->size();
|
||||||
|
|
||||||
|
asm volatile("xchg bx, bx");
|
||||||
|
|
||||||
//Insert the new block into the free list
|
//Insert the new block into the free list
|
||||||
insert_after(current, header);
|
insert_after(current, header);
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ command_definition commands[26] = {
|
|||||||
|
|
||||||
std::string current_input(16);
|
std::string current_input(16);
|
||||||
|
|
||||||
void exec_command();
|
void exec_shell_command();
|
||||||
|
|
||||||
template<bool Enable = History>
|
template<bool Enable = History>
|
||||||
void history_key(char key){
|
void history_key(char key){
|
||||||
@ -166,7 +166,7 @@ void start_shell(){
|
|||||||
k_print_line();
|
k_print_line();
|
||||||
|
|
||||||
if(current_input.size() > 0){
|
if(current_input.size() > 0){
|
||||||
exec_command();
|
exec_shell_command();
|
||||||
|
|
||||||
if(get_column() != 0){
|
if(get_column() != 0){
|
||||||
k_print_line();
|
k_print_line();
|
||||||
@ -202,7 +202,7 @@ void start_shell(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void exec_command(){
|
void exec_shell_command(){
|
||||||
history_save();
|
history_save();
|
||||||
|
|
||||||
auto params = std::split(current_input);;
|
auto params = std::split(current_input);;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user