Re-add shell.nix
All checks were successful
Continuous Integration / Check (push) Successful in 1m38s
Continuous Integration / Clippy (push) Successful in 54s

This commit is contained in:
August 2026-06-01 23:50:05 -04:00
parent b3c92486b3
commit a2eb0c8a25
Signed by: shibedrill
SSH Key Fingerprint: SHA256:M0m3JW1s38BgO2t0fG146Yxd9OJ2IOqkvCAsuRHQ6Pw
10 changed files with 78 additions and 35 deletions

View File

@ -19,6 +19,9 @@ env_scripts = [
set_env QEMUCOMMAND "qemu-system-loongarch64"
set_env LIMINEBIN "BOOTLOONGARCH64.EFI"
end
if eq ${LIMINEDIR} ""
set_env LIMINEDIR "/usr/share/limine"
end
'''
]
@ -27,7 +30,7 @@ default_to_workspace = false
[env]
# Directory for Limine binaries
LIMINEDIR = "/usr/share/limine"
# Compile target
TARGET = "x86_64-unknown-none"

View File

@ -4,6 +4,5 @@ timeout: 0
protocol: limine
kernel_path: boot():/boot/${ARCH}/gila
cmdline: -loglevel=Trace -logdev=display,serial -initramfs=/boot/${ARCH}/initramfs.tar.lzma
module_path: boot():/boot/${ARCH}/initramfs.tar.lzma
kaslr: yes
randomize_hhdm_base: yes

View File

@ -54,14 +54,23 @@ containing system servers, such as the init server and device drivers.
This project uses [cargo-make](https://github.com/sagiegurari/cargo-make) to
handle building ISOs and managing files not associated with Cargo. You need to
install it before you can build an ISO automatically. To do so, you can run
`cargo install cargo-make`. In addition, you will also need:
`cargo install cargo-make`.
### Dependencies
If you use NixOS or the Nix package manager, simply run `nix-shell` in the root
directory. All necessary dependencies will be made available.
If not, the following dependencies will need to be manually installed:
- `rustup` command installed
- `limine` command installed
- `xorriso` command installed
- `qemu-system-{your target architecture}` command installed (for running)
Then run `cargo make` to invoke the [Makefile.toml](../Makefile.toml).
### Build System
Run `cargo make` to invoke the [Makefile.toml](../Makefile.toml).
- `cargo make clean_all`: Cleans all built binaries, libraries, initramfs
files, and ISOs.

View File

@ -44,6 +44,7 @@ pub fn read_gdt() -> GlobalDescriptorTable {
// Bits 16 through 79 are the virtual address of the GDT.
let limit = addr.bits(0..=15) as usize + 1;
let base = addr.bits(16..=79) as u64;
let gdt_raw: &[u64] = unsafe { core::slice::from_raw_parts(base as *const u64, (limit / 8) - 1) };
let gdt_raw: &[u64] =
unsafe { core::slice::from_raw_parts(base as *const u64, (limit / 8) - 1) };
GlobalDescriptorTable::from_raw_entries(gdt_raw)
}

View File

@ -19,15 +19,14 @@ pub static FILE_REQUEST: ExecutableFileRequest = limine::request::ExecutableFile
pub static MODULE_REQUEST: ModuleRequest = limine::request::ModuleRequest::new();
lazy_static! {
pub static ref MODULE_RESPONSE: &'static ModuleResponse = MODULE_REQUEST
.get_response()
.expect("Bootloader did not return kernel modules");
pub static ref MODULE_RESPONSE: Option<&'static ModuleResponse> = MODULE_REQUEST.get_response();
}
pub fn log_modules() {
if !MODULE_RESPONSE.modules().is_empty() {
if let Some(modules) = *MODULE_RESPONSE {
if !modules.modules().is_empty() {
let mut log_msg: String = String::from("Kernel modules list:\n");
for module in MODULE_RESPONSE.modules() {
for module in modules.modules() {
log_msg.push_str(&format!(
"\t{}",
String::from_utf8_lossy(module.path().to_bytes())
@ -35,4 +34,7 @@ pub fn log_modules() {
}
log_trace!("{log_msg}")
}
} else {
log_trace!("No modules found.");
}
}

View File

@ -16,8 +16,6 @@ mod panic;
mod process;
mod util;
use core::{arch::asm, ptr::addr_of};
use arch::x86_64::interrupts::IDT;
use arch::x86_64::serial::SerialPort;
use boot::{BASE_REVISION, params, *};
@ -31,7 +29,10 @@ use limine::firmware_type::FirmwareType;
use spin::mutex::Mutex;
use crate::{
arch::x86_64::{cpuid::{CPUID, virt_supported}, gdt::GdtEntryRead},
arch::x86_64::{
cpuid::{CPUID, virt_supported},
gdt::GdtEntryRead,
},
memory::HHDM_RESPONSE,
};
@ -168,7 +169,11 @@ unsafe extern "C" fn main() -> ! {
let gdt = crate::arch::x86_64::gdt::read_gdt();
log_info!("GDT length: {}", gdt.limit() + 1);
for entry in gdt.entries() {
log_info!("GDT entry: Flags 0b{:b}, Access 0b{:b}", entry.flags(), entry.access());
log_info!(
"GDT entry: Flags 0b{:b}, Access 0b{:b}",
entry.flags(),
entry.access()
);
}
panic!("Finished boot, but cannot start init because processes not implemented!");

View File

@ -96,7 +96,10 @@ pub fn log_address() {
resp.physical_base()
);
log_info!("Kernel virtual start address: 0x{:x}", resp.virtual_base());
log_info!("Kernel physical start address (calculated): 0x{:x}", 0i64 - resp.virtual_base() as i64 + resp.physical_base() as i64);
log_info!(
"Kernel physical start address (calculated): 0x{:x}",
0i64 - resp.virtual_base() as i64 + resp.physical_base() as i64
);
} else {
log_warning!("No kernel address response provided.");
}

View File

@ -1,17 +1,14 @@
use x86_64::structures::paging::PageTable;
use x86_64::VirtAddr;
use lazy_static::lazy_static;
use x86_64::VirtAddr;
use x86_64::structures::paging::PageTable;
use x86_64::structures::paging::PageTableFlags;
use crate::log::*;
use crate::memory::format;
use crate::memory::HHDM_RESPONSE;
use crate::memory::format;
#[allow(dead_code)]
pub unsafe fn active_level_4_table()
-> &'static mut PageTable
{
pub unsafe fn active_level_4_table() -> &'static mut PageTable {
use x86_64::registers::control::Cr3;
let (level_4_table_frame, _) = Cr3::read();
@ -44,9 +41,6 @@ pub fn iter_table(level: usize, table: &PageTable) {
}
}
/*
let l4_table = unsafe { active_level_4_table() };

View File

@ -5,8 +5,7 @@ use num_traits::FromPrimitive;
use crate::arch;
pub struct SyscallError {
}
pub struct SyscallError {}
#[repr(u32)]
#[derive(FromPrimitive, Debug)]

28
shell.nix Normal file
View File

@ -0,0 +1,28 @@
let
nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz";
pkgs = import nixpkgs { config = {}; overlays = []; };
in
pkgs.mkShell {
packages = with pkgs; [
bash
limine-full
xorriso
rustup
qemu
cargo-make
];
buildInputs = with pkgs; [
limine-full
];
shellHook = ''
rustup default nightly;
rustup target add x86_64-unknown-none
export LIMINEDIR="${pkgs.limine-full}/share/limine"
'';
}