Re-add shell.nix
This commit is contained in:
parent
b3c92486b3
commit
a2eb0c8a25
@ -19,6 +19,9 @@ env_scripts = [
|
|||||||
set_env QEMUCOMMAND "qemu-system-loongarch64"
|
set_env QEMUCOMMAND "qemu-system-loongarch64"
|
||||||
set_env LIMINEBIN "BOOTLOONGARCH64.EFI"
|
set_env LIMINEBIN "BOOTLOONGARCH64.EFI"
|
||||||
end
|
end
|
||||||
|
if eq ${LIMINEDIR} ""
|
||||||
|
set_env LIMINEDIR "/usr/share/limine"
|
||||||
|
end
|
||||||
'''
|
'''
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -27,7 +30,7 @@ default_to_workspace = false
|
|||||||
|
|
||||||
[env]
|
[env]
|
||||||
# Directory for Limine binaries
|
# Directory for Limine binaries
|
||||||
LIMINEDIR = "/usr/share/limine"
|
|
||||||
# Compile target
|
# Compile target
|
||||||
TARGET = "x86_64-unknown-none"
|
TARGET = "x86_64-unknown-none"
|
||||||
|
|
||||||
|
|||||||
@ -4,6 +4,5 @@ timeout: 0
|
|||||||
protocol: limine
|
protocol: limine
|
||||||
kernel_path: boot():/boot/${ARCH}/gila
|
kernel_path: boot():/boot/${ARCH}/gila
|
||||||
cmdline: -loglevel=Trace -logdev=display,serial -initramfs=/boot/${ARCH}/initramfs.tar.lzma
|
cmdline: -loglevel=Trace -logdev=display,serial -initramfs=/boot/${ARCH}/initramfs.tar.lzma
|
||||||
module_path: boot():/boot/${ARCH}/initramfs.tar.lzma
|
|
||||||
kaslr: yes
|
kaslr: yes
|
||||||
randomize_hhdm_base: yes
|
randomize_hhdm_base: yes
|
||||||
|
|||||||
@ -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
|
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
|
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
|
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
|
- `rustup` command installed
|
||||||
- `limine` command installed
|
- `limine` command installed
|
||||||
- `xorriso` command installed
|
- `xorriso` command installed
|
||||||
- `qemu-system-{your target architecture}` command installed (for running)
|
- `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
|
- `cargo make clean_all`: Cleans all built binaries, libraries, initramfs
|
||||||
files, and ISOs.
|
files, and ISOs.
|
||||||
|
|||||||
@ -44,6 +44,7 @@ pub fn read_gdt() -> GlobalDescriptorTable {
|
|||||||
// Bits 16 through 79 are the virtual address of the GDT.
|
// Bits 16 through 79 are the virtual address of the GDT.
|
||||||
let limit = addr.bits(0..=15) as usize + 1;
|
let limit = addr.bits(0..=15) as usize + 1;
|
||||||
let base = addr.bits(16..=79) as u64;
|
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)
|
GlobalDescriptorTable::from_raw_entries(gdt_raw)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,20 +19,22 @@ pub static FILE_REQUEST: ExecutableFileRequest = limine::request::ExecutableFile
|
|||||||
pub static MODULE_REQUEST: ModuleRequest = limine::request::ModuleRequest::new();
|
pub static MODULE_REQUEST: ModuleRequest = limine::request::ModuleRequest::new();
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
pub static ref MODULE_RESPONSE: &'static ModuleResponse = MODULE_REQUEST
|
pub static ref MODULE_RESPONSE: Option<&'static ModuleResponse> = MODULE_REQUEST.get_response();
|
||||||
.get_response()
|
|
||||||
.expect("Bootloader did not return kernel modules");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn log_modules() {
|
pub fn log_modules() {
|
||||||
if !MODULE_RESPONSE.modules().is_empty() {
|
if let Some(modules) = *MODULE_RESPONSE {
|
||||||
let mut log_msg: String = String::from("Kernel modules list:\n");
|
if !modules.modules().is_empty() {
|
||||||
for module in MODULE_RESPONSE.modules() {
|
let mut log_msg: String = String::from("Kernel modules list:\n");
|
||||||
log_msg.push_str(&format!(
|
for module in modules.modules() {
|
||||||
"\t{}",
|
log_msg.push_str(&format!(
|
||||||
String::from_utf8_lossy(module.path().to_bytes())
|
"\t{}",
|
||||||
));
|
String::from_utf8_lossy(module.path().to_bytes())
|
||||||
|
));
|
||||||
|
}
|
||||||
|
log_trace!("{log_msg}")
|
||||||
}
|
}
|
||||||
log_trace!("{log_msg}")
|
} else {
|
||||||
|
log_trace!("No modules found.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,8 +16,6 @@ mod panic;
|
|||||||
mod process;
|
mod process;
|
||||||
mod util;
|
mod util;
|
||||||
|
|
||||||
use core::{arch::asm, ptr::addr_of};
|
|
||||||
|
|
||||||
use arch::x86_64::interrupts::IDT;
|
use arch::x86_64::interrupts::IDT;
|
||||||
use arch::x86_64::serial::SerialPort;
|
use arch::x86_64::serial::SerialPort;
|
||||||
use boot::{BASE_REVISION, params, *};
|
use boot::{BASE_REVISION, params, *};
|
||||||
@ -31,7 +29,10 @@ use limine::firmware_type::FirmwareType;
|
|||||||
use spin::mutex::Mutex;
|
use spin::mutex::Mutex;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
arch::x86_64::{cpuid::{CPUID, virt_supported}, gdt::GdtEntryRead},
|
arch::x86_64::{
|
||||||
|
cpuid::{CPUID, virt_supported},
|
||||||
|
gdt::GdtEntryRead,
|
||||||
|
},
|
||||||
memory::HHDM_RESPONSE,
|
memory::HHDM_RESPONSE,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -168,7 +169,11 @@ unsafe extern "C" fn main() -> ! {
|
|||||||
let gdt = crate::arch::x86_64::gdt::read_gdt();
|
let gdt = crate::arch::x86_64::gdt::read_gdt();
|
||||||
log_info!("GDT length: {}", gdt.limit() + 1);
|
log_info!("GDT length: {}", gdt.limit() + 1);
|
||||||
for entry in gdt.entries() {
|
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!");
|
panic!("Finished boot, but cannot start init because processes not implemented!");
|
||||||
|
|||||||
@ -96,7 +96,10 @@ pub fn log_address() {
|
|||||||
resp.physical_base()
|
resp.physical_base()
|
||||||
);
|
);
|
||||||
log_info!("Kernel virtual start address: 0x{:x}", resp.virtual_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 {
|
} else {
|
||||||
log_warning!("No kernel address response provided.");
|
log_warning!("No kernel address response provided.");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,17 +1,14 @@
|
|||||||
|
|
||||||
use x86_64::structures::paging::PageTable;
|
|
||||||
use x86_64::VirtAddr;
|
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
|
use x86_64::VirtAddr;
|
||||||
|
use x86_64::structures::paging::PageTable;
|
||||||
use x86_64::structures::paging::PageTableFlags;
|
use x86_64::structures::paging::PageTableFlags;
|
||||||
|
|
||||||
use crate::log::*;
|
use crate::log::*;
|
||||||
use crate::memory::format;
|
|
||||||
use crate::memory::HHDM_RESPONSE;
|
use crate::memory::HHDM_RESPONSE;
|
||||||
|
use crate::memory::format;
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub unsafe fn active_level_4_table()
|
pub unsafe fn active_level_4_table() -> &'static mut PageTable {
|
||||||
-> &'static mut PageTable
|
|
||||||
{
|
|
||||||
use x86_64::registers::control::Cr3;
|
use x86_64::registers::control::Cr3;
|
||||||
|
|
||||||
let (level_4_table_frame, _) = Cr3::read();
|
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() };
|
let l4_table = unsafe { active_level_4_table() };
|
||||||
|
|
||||||
|
|||||||
@ -5,8 +5,7 @@ use num_traits::FromPrimitive;
|
|||||||
|
|
||||||
use crate::arch;
|
use crate::arch;
|
||||||
|
|
||||||
pub struct SyscallError {
|
pub struct SyscallError {}
|
||||||
}
|
|
||||||
|
|
||||||
#[repr(u32)]
|
#[repr(u32)]
|
||||||
#[derive(FromPrimitive, Debug)]
|
#[derive(FromPrimitive, Debug)]
|
||||||
|
|||||||
28
shell.nix
Normal file
28
shell.nix
Normal 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"
|
||||||
|
'';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user