returninfinity / baremetal-os-legacy Goto Github PK
View Code? Open in Web Editor NEWBareMetal is a 64-bit OS for x86-64 based computers. The OS is written entirely in Assembly while applications can be written in Assembly, C/C++, and Rust.
BareMetal is a 64-bit OS for x86-64 based computers. The OS is written entirely in Assembly while applications can be written in Assembly, C/C++, and Rust.
there should be a function (named os_mem_most_allocatable_pages or something like this) which gives the most number of free pages in succession
To be coded...
The kernel's compiled size is now larger than 16KiB. Take a look at slimming this down.
Ideas:
Move the CLI into its own program.
Remove the Ethernet ring buffer and use a callback instead.
Remove some of the os_string functions that are not really necessary.
Shorten the exception code in interrupt.asm.
Rework the FAT16 driver.
system_status in misc.asm could be optimized.
It currently can only report 16GiB of RAM; many 64-bit systems have more than this.
printf("NewLib Test Application\n=======================\n");
Seems to only print "NewLib Test Application\n"
printf("You entered: '%s'", tempstring);
Seems to only print "You entered: '%s". Trailing ' is gone.
Need to investigate what is being passed to os_output_chars.
kernel64 is not compiling and it fails with
cli.asm:143: error: symbol `os_file_list' undefined
command used:
nasm kernel64.asm -o kernel.sys
Use the PML4 to keep track of pages in use instead of a separate area of memory?
Hello Ian,
When I compile the code, it gives this error and fails:
syscalls/screen.asm:299: error: short jump is out of range
Currently all disk calls are done via PIO. For performance this should be replaced with proper DMA calls.
UDMA is supported on all hardware that BareMetal targets. However UDMA transfers are limited to 32-bit memory addresses
ADMA is supported in all SATA chipsets and transfers work with any 64-bit memory address.
UDMA links:
http://wiki.osdev.org/ATA/ATAPI_using_DMA
http://savrus.blogspot.com/2009/10/writing-dma-bootloader.html
ADMA links:
http://wiki.osdev.org/ADMA
ATA links:
http://wiki.osdev.org/Category:ATA
This needs to be completed before the disk block calls. PIO can read/write 128KiB per call and we want something closer to 2MiB.
Add HPET support on IRQ 2 (to replace the legacy timer). Disabled by default but configurable via system calls.
Move the kernel to the higher half of memory (0xFFFF800000000000).
Required adjustment of the PML4.
keyboard interrupt handler could be a bit smarter
This didn't occur in older release.
The CLI should store a history of last entered commands (Similar to DOSKEY back in the day). Up and down arrows would scroll through the history.
Need to look into the latest chips that are coming out from Intel and check if they will be supported by the current i8254x driver. If not then a new driver will need to be written.
When running in VirtualBox, over 90% of CPU cycles used during boot are spent finding an appropriate NIC/driver pair, specifically in iterating over all PCI devices for each supported vendor/device ID.
If the init_net code iterated over attached PCI devices in the outer loop, then over supported vendors/device IDs in the inner loop, the process would be much faster.
you may also be interested in: http://www.menuetos.net/index.htm
Compared to the amount of syscalls in the source code, bmdev.asm
is relatively empty. This means you can only use a limited subset of the syscalls in assembly. This is the same with libBareMetal.h
. Is there any reason for this or should I go ahead and add them?
I loaded the latest (0.5.3) VMDK into VirtualBox on my Mac OS X machine and the setup seems to hang on "Initializing system".
I can provide more details as needed.
BareMetal is used as a verb:
"At the moment there is no plan to BareMetal into a general-purpose operating system" [...]
BM OS successfully boots from the disk but the init_hdd routine does not seem to find it.
The disk is connected to SATA port 0
ftp://sourceware.org/pub/newlib/index.html
Calls to exit() cause a GP fault.
Some functions will break if the direction flag is set.
Should this be left to the app programmer to verify? Or should the OS save/restore the state of the flag on all calls?
b_file_open
b_file_close
b_file_read
b_file_write
b_file_seek
A defective network callback will freeze the system if the interrupt never returns. The callback should be called after the interrupt has been handled. The stack will need to be modified.
b_output and b_output_chars need to be updated to convert code 0x09 to align to 8 chars.
Replace FAT16 with a native file system.
Also see Adrien's advice here: http://www.google.com/url?sa=D&q=https://docs.google.com/document/d/1nd-R4ixSNRjwTyJ1gZ8ILgvdxxRnwa1GqvmLFCdkRiE/edit&usg=AFQjCNGVBNgHNfc8dUHYlgXO69LyGZ3GrA
Driver issue?
The latest version of Pure64 now enables and configures the IO-APIC. All interrupts are still being sent to the BSP still.
Have the RTC interrupt increment a 64-bit value every second.
On the first call to gettimeofday() check this value.
If the value is less than 946684800 (2000/1/1 00:00:00) then we have an invalid date.
gettimeofday() can then call the RTC hardware and calculate the real epoch time.
gettimeofday() will then update the OS timer.
Replace with application callback.
Need to implement the following
Currently being worked on.
Compile kernel
hamilok ~/projects/baremetal $ nasm kernel64.asm -o kernel64.sys
syscalls/smp.asm:109: warning: instruction is not lockable
syscalls/smp.asm:167: warning: instruction is not lockable
syscalls/smp.asm:290: warning: instruction is not lockable
Patch
index d1be871..c569fd3 100644
--- a/os/syscalls/smp.asm
+++ b/os/syscalls/smp.asm
@@ -106,8 +106,7 @@ os_smp_enqueue:
os_smp_enqueue_spin:
bt word [os_QueueLock], 0 ; Check if the mutex is free
jc os_smp_enqueue_spin ; If not check it again
- lock ; The mutex was free, lock the bus
- bts word [os_QueueLock], 0 ; Try to grab the mutex
+ lock bts word [os_QueueLock], 0 ; The mutex was free, lock the bus. Try to grab the mutex
jc os_smp_enqueue_spin ; Jump if we were unsuccessful
cmp word [os_QueueLen], 256 ; aka cpuqueuemax
@@ -122,7 +121,7 @@ os_smp_enqueue_spin:
stosq ; Store the code address from RAX
mov rax, rsi
stosq ; Store the variable
-
+
add word [os_QueueLen], 1
shr rcx, 4 ; Quickly divide RCX by 16
add cx, 1
@@ -164,8 +163,7 @@ os_smp_dequeue:
os_smp_dequeue_spin:
bt word [os_QueueLock], 0 ; Check if the mutex is free
jc os_smp_dequeue_spin ; If not check it again
- lock ; The mutex was free, lock the bus
- bts word [os_QueueLock], 0 ; Try to grab the mutex
+ lock bts word [os_QueueLock], 0 ; The mutex was free, lock the bus. Try to grab the mutex
jc os_smp_dequeue_spin ; Jump if we were unsuccessful
cmp word [os_QueueLen], 0
@@ -287,8 +285,7 @@ skipit:
os_smp_lock:
bt word [rax], 0 ; Check if the mutex is free (Bit 0 cleared to 0)
jc os_smp_lock ; If not check it again
- lock ; The mutex was free, lock the bus
- bts word [rax], 0 ; Try to grab the mutex (Bit 0 set to 1)
+ lock bts word [rax], 0 ; The mutex was free, lock the bus. Try to grab the mutex (Bit 0 set to 1)
jc os_smp_lock ; Jump if we were unsuccessful
ret ; Lock acquired. Return to the caller
; -----------------------------------------------------------------------------
The Command Line Interface should be removed from the kernel binary. It should be treated as an application instead of a kernel component. This could be a good opportunity to re-write the CLI in C.
The current ATA PIO driver is slow and obsolete. Going forward a driver should be written that supports SATA drives on an ACHI controller. The PIO driver could then be removed.
C compilers assume that .bss section is filled with zeros, so cli.asm should clear it after loading the file
For example:
int x[256] = {0}; //this compiles to .bss
int y[256] = {1}; //this compiles to .data
so if i check x[0], this should be 0
PS: modifying linker script's last line to ".bss ALIGN(0x08) : { *(.bss) }" will make bss section start on an address divisible by 8
temporary solution:
gcc-option: -fno-zero-initialized-in-bss
os_ethernet_tx should send a pre-built packet.
os_ethernet_rx should process the latest packet that was received on the wire.
Remove the ring buffer.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.