[victoria] Create and start VictoriaFalls process
This commit is contained in:
parent
dc63084d61
commit
f0e8ce14a4
|
@ -22,7 +22,7 @@ set(QEMU_CMD qemu-system-x86_64 -machine q35 -d guest_errors -m 1G -serial stdio
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT disk.img
|
OUTPUT disk.img
|
||||||
COMMAND sudo sh ../scripts/build_image.sh disk.img
|
COMMAND sudo sh ../scripts/build_image.sh disk.img
|
||||||
DEPENDS zion yellowstone denali
|
DEPENDS zion yellowstone denali victoriafalls
|
||||||
USES_TERMINAL
|
USES_TERMINAL
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ uint64_t gSelfVmasCap = 0;
|
||||||
uint64_t gInitEndpointCap = 0;
|
uint64_t gInitEndpointCap = 0;
|
||||||
|
|
||||||
uint64_t gBootDenaliVmmoCap = 0;
|
uint64_t gBootDenaliVmmoCap = 0;
|
||||||
|
uint64_t gBootVictoriaFallsVmmoCap = 0;
|
||||||
|
|
||||||
z_err_t ParseInitPort(uint64_t init_port_cap) {
|
z_err_t ParseInitPort(uint64_t init_port_cap) {
|
||||||
Port port(init_port_cap);
|
Port port(init_port_cap);
|
||||||
|
@ -35,6 +36,10 @@ z_err_t ParseInitPort(uint64_t init_port_cap) {
|
||||||
dbgln("received denali");
|
dbgln("received denali");
|
||||||
gBootDenaliVmmoCap = init_cap;
|
gBootDenaliVmmoCap = init_cap;
|
||||||
break;
|
break;
|
||||||
|
case Z_BOOT_VICTORIA_FALLS_VMMO:
|
||||||
|
dbgln("received victoria falls");
|
||||||
|
gBootVictoriaFallsVmmoCap = init_cap;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
dbgln("Unexpected init type %x, continuing.", init_sig);
|
dbgln("Unexpected init type %x, continuing.", init_sig);
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,5 +39,6 @@ cp zion/zion efi/
|
||||||
mkdir -p efi/sys
|
mkdir -p efi/sys
|
||||||
cp sys/yellowstone/yellowstone efi/sys/yellowstone
|
cp sys/yellowstone/yellowstone efi/sys/yellowstone
|
||||||
cp sys/denali/denali efi/sys/denali
|
cp sys/denali/denali efi/sys/denali
|
||||||
|
cp sys/victoriafalls/victoriafalls efi/sys/victoriafalls
|
||||||
|
|
||||||
chown drew:drew $1
|
chown drew:drew $1
|
||||||
|
|
|
@ -1,5 +1,11 @@
|
||||||
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
|
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
|
||||||
|
|
||||||
add_subdirectory(yellowstone)
|
|
||||||
add_subdirectory(denali)
|
add_subdirectory(denali)
|
||||||
|
add_subdirectory(victoriafalls)
|
||||||
|
add_subdirectory(yellowstone)
|
||||||
|
|
||||||
|
set(SYS_BUNDLE
|
||||||
|
denali
|
||||||
|
victoriafalls
|
||||||
|
yellowstone)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
add_executable(victoriafalls
|
||||||
|
victoriafalls.cpp)
|
||||||
|
|
||||||
|
target_include_directories(victoriafalls
|
||||||
|
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/include")
|
||||||
|
|
||||||
|
target_link_libraries(victoriafalls
|
||||||
|
glacier
|
||||||
|
mammoth_lib
|
||||||
|
)
|
||||||
|
|
||||||
|
set_target_properties(victoriafalls PROPERTIES
|
||||||
|
COMPILE_FLAGS "${CMAKE_CXX_FLAGS} ${BASE_COMPILE_FLAGS}"
|
||||||
|
LINK_FLAGS "${CMAKE_EXE_LINK_FLAGS} ${BASE_LINK_FLAGS}"
|
||||||
|
)
|
|
@ -0,0 +1,9 @@
|
||||||
|
#include <mammoth/debug.h>
|
||||||
|
#include <mammoth/init.h>
|
||||||
|
|
||||||
|
uint64_t main(uint64_t init_cap) {
|
||||||
|
ParseInitPort(init_cap);
|
||||||
|
|
||||||
|
dbgln("VFs Started");
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -28,6 +28,11 @@ uint64_t main(uint64_t port_cap) {
|
||||||
|
|
||||||
check(reader.ParsePartitionTables());
|
check(reader.ParsePartitionTables());
|
||||||
|
|
||||||
|
check(ZAddressSpaceMap(gSelfVmasCap, 0, gBootVictoriaFallsVmmoCap, &vaddr));
|
||||||
|
auto error_or = SpawnProcessFromElfRegion(vaddr);
|
||||||
|
if (!error_or) {
|
||||||
|
check(error_or.error());
|
||||||
|
}
|
||||||
dbgln("Yellowstone Finished Successfully.");
|
dbgln("Yellowstone Finished Successfully.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,3 +8,4 @@ TIMEOUT=0
|
||||||
KERNEL_PATH=boot:///zion
|
KERNEL_PATH=boot:///zion
|
||||||
MODULE_PATH=boot:///sys/yellowstone
|
MODULE_PATH=boot:///sys/yellowstone
|
||||||
MODULE_PATH=boot:///sys/denali
|
MODULE_PATH=boot:///sys/denali
|
||||||
|
MODULE_PATH=boot:///sys/victoriafalls
|
||||||
|
|
|
@ -8,3 +8,4 @@ extern uint64_t gSelfVmasCap;
|
||||||
extern uint64_t gInitEndpointCap;
|
extern uint64_t gInitEndpointCap;
|
||||||
|
|
||||||
extern uint64_t gBootDenaliVmmoCap;
|
extern uint64_t gBootDenaliVmmoCap;
|
||||||
|
extern uint64_t gBootVictoriaFallsVmmoCap;
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
#pragma once
|
|
|
@ -88,3 +88,4 @@ typedef uint64_t z_cap_t;
|
||||||
#define Z_INIT_ENDPOINT 0x4100'0000
|
#define Z_INIT_ENDPOINT 0x4100'0000
|
||||||
|
|
||||||
#define Z_BOOT_DENALI_VMMO 0x4200'0000
|
#define Z_BOOT_DENALI_VMMO 0x4200'0000
|
||||||
|
#define Z_BOOT_VICTORIA_FALLS_VMMO 0x4200'0001
|
||||||
|
|
|
@ -114,36 +114,42 @@ const limine_file& GetInitProgram(glcr::String path) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
panic("Program not found: %s", path);
|
panic("Program not found: %s", path);
|
||||||
|
UNREACHABLE
|
||||||
|
}
|
||||||
|
|
||||||
|
void WriteInitProgram(glcr::RefPtr<Port> port, glcr::String name, uint64_t id) {
|
||||||
|
const limine_file& prog = GetInitProgram(name);
|
||||||
|
glcr::RefPtr<MemoryObject> prog_vmmo =
|
||||||
|
glcr::MakeRefCounted<MemoryObject>(prog.size);
|
||||||
|
prog_vmmo->CopyBytesToObject(reinterpret_cast<uint64_t>(prog.address),
|
||||||
|
prog.size);
|
||||||
|
port->WriteKernel(id,
|
||||||
|
MakeRefCounted<Capability>(prog_vmmo, ZC_READ | ZC_WRITE));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void LoadInitProgram() {
|
void LoadInitProgram() {
|
||||||
DumpModules();
|
DumpModules();
|
||||||
const limine_file& init_prog = GetInitProgram("/sys/yellowstone");
|
|
||||||
|
|
||||||
|
// Create process.
|
||||||
glcr::RefPtr<Process> proc = Process::Create();
|
glcr::RefPtr<Process> proc = Process::Create();
|
||||||
gProcMan->InsertProcess(proc);
|
gProcMan->InsertProcess(proc);
|
||||||
|
|
||||||
uint64_t entry = LoadElfProgram(
|
// Write init data.
|
||||||
*proc, reinterpret_cast<uint64_t>(init_prog.address), init_prog.size);
|
|
||||||
|
|
||||||
const limine_file& prog2 = GetInitProgram("/sys/denali");
|
|
||||||
glcr::RefPtr<MemoryObject> prog2_vmmo =
|
|
||||||
glcr::MakeRefCounted<MemoryObject>(prog2.size);
|
|
||||||
prog2_vmmo->CopyBytesToObject(reinterpret_cast<uint64_t>(prog2.address),
|
|
||||||
prog2.size);
|
|
||||||
|
|
||||||
auto port = glcr::MakeRefCounted<Port>();
|
auto port = glcr::MakeRefCounted<Port>();
|
||||||
uint64_t port_cap = proc->AddNewCapability(port, ZC_READ | ZC_WRITE);
|
uint64_t port_cap = proc->AddNewCapability(port, ZC_READ | ZC_WRITE);
|
||||||
|
|
||||||
port->WriteKernel(Z_INIT_SELF_PROC,
|
port->WriteKernel(Z_INIT_SELF_PROC,
|
||||||
MakeRefCounted<Capability>(
|
MakeRefCounted<Capability>(
|
||||||
proc, ZC_PROC_SPAWN_PROC | ZC_PROC_SPAWN_THREAD));
|
proc, ZC_PROC_SPAWN_PROC | ZC_PROC_SPAWN_THREAD));
|
||||||
port->WriteKernel(Z_INIT_SELF_VMAS,
|
port->WriteKernel(Z_INIT_SELF_VMAS,
|
||||||
MakeRefCounted<Capability>(proc->vmas(), ZC_WRITE));
|
MakeRefCounted<Capability>(proc->vmas(), ZC_WRITE));
|
||||||
port->WriteKernel(Z_BOOT_DENALI_VMMO,
|
WriteInitProgram(port, "/sys/denali", Z_BOOT_DENALI_VMMO);
|
||||||
MakeRefCounted<Capability>(prog2_vmmo, ZC_READ | ZC_WRITE));
|
WriteInitProgram(port, "/sys/victoriafalls", Z_BOOT_VICTORIA_FALLS_VMMO);
|
||||||
|
|
||||||
|
// Start process.
|
||||||
|
const limine_file& init_prog = GetInitProgram("/sys/yellowstone");
|
||||||
|
uint64_t entry = LoadElfProgram(
|
||||||
|
*proc, reinterpret_cast<uint64_t>(init_prog.address), init_prog.size);
|
||||||
proc->CreateThread()->Start(entry, port_cap, 0);
|
proc->CreateThread()->Start(entry, port_cap, 0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue