Merge into main the new state of the operating system/kernel #1

Open
Nigel wants to merge 120 commits from dev into main
Owner

A long time has passed since Main was updated. Its time it gets updated to the latest iteration of the Operating system/Kernel.

A long time has passed since Main was updated. Its time it gets updated to the latest iteration of the Operating system/Kernel.
Nigel self-assigned this 2023-10-28 18:48:17 +00:00
Nigel added 120 commits 2023-10-28 18:48:24 +00:00
- Moved memcmp function to temporary libc/mem.h
- I/O functions are inlined
- ATA_DEVICE read function won't print the 512 bytes by default
Adding functions and structures to read the RSD.
The proper reading of folders and files is not yet implemented. Although
it is close.
- Drivers have now gotten Category folders
- RSDP is now called ACPI
- Ports folders is now called Serial to show that its a serial driver
- Paging assembly definition is moved to the memory folder
- VGA folder has moved into the drivers
- Patched the makefile and include statements to reflect the changes
	in the project structure
- Modified makefile to start the virtualbox vm on `make run`
- Listing files in rootdirectory with their properties and
	content
To ease the pain of debuggin I can now interact with the system through a
very simplistic terminal. Hopefully things can be tested more easily by activating
the piece through a simple command. The max characters for a command is 10.

To achieve this I have had to make the following changes.
- Changed IRQ to update a global status variable
- Added a standalone keyboard driver with getKey functions
- Changed the main kernel loop to display a prompt
- Added a strncmp function to the clib/string file
Any interrupt thrown for any Intel defined Exception is not only being caught but
displays an appropriate message to the screen.

Changes made in src/kernel/idt/idt.cpp
As this project grows it becomes important to keep things properly organised.
In this commit I've put some effort into making the kernel.cpp file more consise and thus improve its
readability.
Certain parts of the code have gotten their own definition file where before it
was only a header file.

- Moving the Supervisor Terminal into its own definition file.
- Subtracting debugging messages with preprocessor ifdef's
- Time and Date is now not just a header but has its own proper definition file
- Banner is displayed when booting up
- Terminal has a couple new commands

	Commmand		Description
	=================|||||===================================================
	DATE (was TIME)		Displays the curren time, date and ticks
	VERSION			Displays system version information
	MEMORY			Displays memory information
- 1 block = 4096 bytes : because this will make page fault handling possibly
somewhat easier

- 1 byte in the bitmap = 8 blocks of physical memory

unsure if the allocation is perfect ... guess i'll find out some day if this is actually correct.

The bitmap needs 16kb to keep track of 2gb of physical memory. Seems a decent percentage to me.
to ensure it doesn't get too out of date

We can now run the FAT command to demo reading out the FAT16 filesystem,
however this will cause the need for a reboot as after this command. We are FOR NOW
not able to put in any new commands
Followed wiki.osdev.org/Setting_Up_Paging
- Made a special assembly file to put CPU check function in. E.G. functions to get the state of
	specific registers

In this case I have created a simple assembly function to get the contents of the CR0 register.
With the help of the c++ preprocessor the value can then be used to check if certains bits are set.
For example to check if the PG (paging) bit is set, indicating that paging is enabled for the
processor.
The boot up process will be changed somewhat dramatically, therefor a
restructering of the kernel seems as a good starting point.
Removed non-sensical libc folder from project
We now can launch the kernel at 0xC0000000 (or 3 GiB mark) with paging enabled.
A lot of early main is currently not executed to keep debugging as simple as possible
during the initial testing of higher half kernel loading.

A lot of the implementation is straight from wiki.osdev.org/Higher_Half_x86_Bare_Bones. Thanks to all the folks
who keep that wiki updated, its really resourceful.
to explain what is going on.

I removed previously set barriers from the code to load
the kernel further.
* Added symbol files to .gitignore
* Improved text in #PG and #GP handlers
* Added the printing of the multiboot structure address and the magic value
* Added page fault screenshot to readme
Removed the need to map the extra MBI structure in as a seperate pagetable
Renaming / Restructuring the memory folder
Moved the PMM away from being object orientated as it is just plain annoying
renamed src folder to source
Set timeout to 5 seconds in the grub config
The first stage after GRUB will be Pre-Kernel. This stage will organize the
information we receive from the bootloader. (in our case that will be grub)

The second stage is for now called early_main. The program will at this
point already be running in virtual higher-half / higher-quarter address space.
The goal of the second stage is to set up the kernel in such a way that we are
ready to jump in to usermode.

The third stage is for now called kernel_main. This stage will jump us into
usermode and load the startup programs.

- Added a GRUB entry for tests
- Started writing the pre-kernel stage
- Removed knowledge of multiboot from early_main
- Edited the linkerscript to link variables in pre-kernel to
	lower address space. ( from 1MB and up)
Rewriting the setup to allow for physical memory allocation again to work.
Keyboard.h: remove the incorrect use of typedef

PhysicalMemoryManager.cpp:
Map the Bios region as used. This prevents us from allocation the area used by the bios
Removing quite a few unnecessary parts.
Folders now are alll lower case

Started working on the implementation of the Virtual memory manager. Implemented allocate and free page funtionality for as far as I can atm.

Implemented the
* Moved tests to a different folder
* Adjusted the memory map address locations
* Improved readability of `kernel.cpp`
* BUG: allocated blocks is possibly incorrect!
* prekernel no longer gets compiled as being in physical memory
- Created a scripts folder
- Written instructions on how to create the disk image
- Working on a python build script that executes all other scripts

The scripts folder should contain scripts to build a full installation of
our operating system. Scripts like creating a filesystem should be found here
This should help merging into dev branch
Hopefully with success
- Updated gdt assembly
- Updated Interrupt service request handlers
- Improved virtual memory manager
- NOTE: we're dependent on identity mappings for the heap to work
- slight clean up of PCI driver
- Added TaskSegment header
- Rename some folders
- Fixed issue with setting up the Task Segment Register
- The FAT command is no longer available
- At Startup the FileSystem initialise funciton
is called, it should execute the same code as the FAT command did.
- ACPI::initialise is commented out because it causes a Exception
Moving enable protected Mode to processor class
- The algorithm will work once I am of better mind to deal with
raw C strings
- The resolution should look at each entry divided by '/'.
  if the entry is not there then we can quit early, however for
now I am mostly concerned with getting the names of directory entries
we would need to look for.
Problem:
	As our kernel grows we need more complex datastructures and functions these would come from
	the standard C/C++ library with normal programs.
	The kernel is a freestanding programme and has no access to standard libraries.

Solution:
	We build a mini version of the standard C/C++ library which will contain the
	datastructures and functions we want. This library can then be statically linked
	into our kernel binary.

	Making it a statically linked library also gives more structure to the project.
	Keeping these random functions and datastructures in the kernel just clutters the
	kernel source code with less relevant source code.
It may or not be mlibc
Added new entries to .gitignore
Moved away from source directory as central spot for all source code
A python script can be run to run the scripts in the correct order and immediatly try the build.
- Added boot device info parsing to the kernel
- Added a pointer in the kernel to our pre-kernel BootInfo structure
- Created a layout for the FAT driver
- Created a layout for the virtual filesystem
- Separated IDE driver from the basic atapio driver.
	This will ensure we are not using one or the other
- The create_harddrive shell script will now actually build a harddrive image of
	the kernel
- The virtual filesystem initializes and creates a filesystem structure
	for every FAT16 partition in the master boot record
- Improved the run bash script to exit when an error occurs in one of the sub tasks
- Wrote basic FAT16 functions that should give enough information to properly implement the rest of the driver
- FAT structure namings are now in accordence with the microsoft spec of March 2005
Added FAT16 driver ability to list subdir entries
Removed structure of FAT32 (we won't be using it anytime soon)
memcpy implementation added
The uri has to contain 8.3 filenames for now as I have not yet figured out
how to convert from that to regular filenaming for the name comparison.

reading files is still limited to 1 sector
A software interrupt with vector 0x50 will cause a syscall to start executing.
The EAX register will hold the syscall_num.
Other registers and the stack can be used to hold further arguments.
* Commented out the map page function call to handle page not present
* Mapped the ACPI_RECLAIMABLE_MEMORY
* Set VBE to false when VBE is not initialized by the bootloader
Nigel added the
PR
label 2023-10-28 18:52:44 +00:00
Nigel changed title from WIP: Merge into main the new state of the operating system/kernel to Merge into main the new state of the operating system/kernel 2023-10-28 18:53:00 +00:00
This pull request can be merged automatically.
You are not authorized to merge this pull request.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin dev:dev
git checkout dev
Sign in to join this conversation.
No reviewers
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: Nigel/BarinkOS#1
No description provided.