2023-11-03 02:48:21 -07:00
|
|
|
#include <glacier/string/str_format.h>
|
2023-11-09 12:55:44 -08:00
|
|
|
#include <glacier/string/str_split.h>
|
2023-11-22 16:58:13 -08:00
|
|
|
#include <mammoth/file/file.h>
|
2023-11-22 14:10:10 -08:00
|
|
|
#include <mammoth/proc/process.h>
|
2023-11-22 14:39:27 -08:00
|
|
|
#include <mammoth/util/debug.h>
|
|
|
|
#include <mammoth/util/init.h>
|
|
|
|
#include <mammoth/util/memory_region.h>
|
2023-06-07 00:19:15 -07:00
|
|
|
#include <zcall.h>
|
2023-11-09 11:20:41 -08:00
|
|
|
#include <ztypes.h>
|
2023-05-30 20:55:03 -07:00
|
|
|
|
2023-06-19 21:54:40 -07:00
|
|
|
#include "hw/gpt.h"
|
2023-06-07 22:45:42 -07:00
|
|
|
#include "hw/pcie.h"
|
2023-06-22 02:19:16 -07:00
|
|
|
#include "yellowstone_server.h"
|
2023-06-07 22:45:42 -07:00
|
|
|
|
2023-10-25 19:08:00 -07:00
|
|
|
glcr::ErrorCode SpawnProcess(z_cap_t vmmo_cap, z_cap_t yellowstone_cap) {
|
2023-11-22 14:59:41 -08:00
|
|
|
mmth::OwnedMemoryRegion region =
|
|
|
|
mmth::OwnedMemoryRegion::FromCapability(vmmo_cap);
|
|
|
|
return mmth::SpawnProcessFromElfRegion(region.vaddr(), yellowstone_cap);
|
2023-11-19 21:38:04 -08:00
|
|
|
}
|
|
|
|
|
2023-06-16 23:15:41 -07:00
|
|
|
uint64_t main(uint64_t port_cap) {
|
2023-06-16 23:51:49 -07:00
|
|
|
check(ParseInitPort(port_cap));
|
2023-11-03 02:48:21 -07:00
|
|
|
dbgln("Yellowstone Initializing.");
|
2023-06-16 23:51:49 -07:00
|
|
|
|
2023-06-26 11:38:17 -07:00
|
|
|
ASSIGN_OR_RETURN(auto server, YellowstoneServer::Create());
|
2023-08-01 16:08:34 -07:00
|
|
|
Thread server_thread = server->RunServer();
|
2023-06-19 21:54:40 -07:00
|
|
|
|
2023-10-25 19:08:00 -07:00
|
|
|
ASSIGN_OR_RETURN(YellowstoneClient client1, server->CreateClient());
|
|
|
|
check(SpawnProcess(gBootDenaliVmmoCap, client1.Capability()));
|
|
|
|
|
2023-11-22 13:30:59 -08:00
|
|
|
server->WaitDenaliRegistered();
|
2023-10-25 19:08:00 -07:00
|
|
|
|
|
|
|
ASSIGN_OR_RETURN(YellowstoneClient client2, server->CreateClient());
|
|
|
|
check(SpawnProcess(gBootVictoriaFallsVmmoCap, client2.Capability()));
|
2023-06-07 22:45:42 -07:00
|
|
|
|
2023-11-22 13:30:59 -08:00
|
|
|
server->WaitVictoriaFallsRegistered();
|
2023-11-02 18:55:05 -07:00
|
|
|
|
|
|
|
dbgln("VFS Available.");
|
|
|
|
|
2023-11-22 16:58:13 -08:00
|
|
|
mmth::File init_file = mmth::File::Open("/init.txt");
|
2023-11-02 19:28:27 -07:00
|
|
|
|
2023-11-22 16:58:13 -08:00
|
|
|
glcr::Vector<glcr::StringView> files =
|
|
|
|
glcr::StrSplit(init_file.as_str(), '\n');
|
2023-11-09 12:55:44 -08:00
|
|
|
|
|
|
|
for (uint64_t i = 0; i < files.size(); i++) {
|
|
|
|
if (!files[i].empty()) {
|
2023-11-22 16:58:13 -08:00
|
|
|
mmth::File binary =
|
|
|
|
mmth::File::Open(glcr::StrFormat("/bin/{}", files[i]));
|
2023-11-09 12:55:44 -08:00
|
|
|
|
|
|
|
ASSIGN_OR_RETURN(YellowstoneClient client3, server->CreateClient());
|
2023-11-22 16:58:13 -08:00
|
|
|
check(mmth::SpawnProcessFromElfRegion((uint64_t)binary.raw_ptr(),
|
|
|
|
client3.Capability()));
|
2023-11-09 12:55:44 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-01 16:08:34 -07:00
|
|
|
check(server_thread.Join());
|
2023-06-07 11:18:35 -07:00
|
|
|
dbgln("Yellowstone Finished Successfully.");
|
2023-05-29 00:32:54 -07:00
|
|
|
return 0;
|
|
|
|
}
|