70 pr_warn(
"init path not specified");
84 char *var_arg =
strdup(arg.data());
97 pr_dinfo(vmm,
"initializing paging...");
101 pr_dinfo(vmm,
"mapping kernel space...");
133 mInfo <<
"Welcome to MOS!";
134 mInfo <<
fmt(
"MOS {}-{} on ({}, {}), compiler {}", MOS_KERNEL_VERSION, MOS_ARCH, MOS_KERNEL_REVISION, __DATE__, __VERSION__);
138 mInfo <<
"MOS Kernel cmdline";
164 mos_panic(
"failed to mount rootfs, vfs_mount returns %ld", ret.getErr());
169 mos_panic(
"failed to create /initrd, vfs_mkdir returns %ld", ret.getErr());
172 const auto ret =
vfs_mount(
"none",
"/initrd/",
"cpiofs",
NULL);
174 mos_panic(
"failed to mount initrd, vfs_mount returns %ld", ret.getErr());
183 const stdio_t init_io = { .in = init_con, .out = init_con, .err = init_con };
185 "PATH=/initrd/programs:/initrd/bin:/bin",
191 mInfo <<
" with arguments:";
194 mInfo <<
" with environment:";
195 for (
u32 i = 0; i < init_envp.
size(); i++)
196 mInfo <<
" " << init_envp[i].c_str();
200 mos_panic(
"failed to create init process");
206 MOS_ASSERT_X(m,
"failed to map initrd into init process");
#define MOS_ASSERT_X(cond, msg,...)
#define MOS_UNREACHABLE()
#define MOS_DEFAULT_INIT_PATH
auto size() const noexcept
Process * elf_create_process(mos::string_view path, Process *parent, const mos::vector< mos::string > &argv, const mos::vector< mos::string > &envp, const stdio_t *ios)
MOSAPI char * strdup(const char *src)
void mm_map_kernel_pages(MMContext *mmctx, ptr_t vaddr, pfn_t pfn, size_t npages, VMFlags flags)
Map a block of virtual memory to a block of physical memory.
PtrResult< vmap_t > mm_map_user_pages(MMContext *mmctx, ptr_t vaddr, pfn_t pfn, size_t npages, VMFlags flags, vmap_type_t type, vmap_content_t content, bool exact=false)
#define pmm_ref(thing, npages)
PtrResult< void > vfs_mount(const char *device, const char *path, const char *fs, const char *options)
Mount a filesystem at a given existing path.
PtrResult< void > vfs_mkdir(const char *path)
Create a directory.
mos::vector< mos::string > init_args
static sysfs_item_t kernel_sysfs_items[]
static void setup_sane_environment()
void mos_start_kernel(void)
static bool init_sysfs_argv(sysfs_file_t *file)
mos::vector< mos::string > cmdline_parse_vector(char *inbuf, size_t length)
void string_unquote(char *str)
#define ALIGN_UP_TO_PAGE(addr)
#define mos_panic(fmt,...)
static size_t strlen(const char *s)
#define pml_create_table(x)
#define pr_info2(fmt,...)
#define pr_dinfo(feat, fmt,...)
void unblock_scheduler(void)
Unblock the scheduler, so that APs can start scheduling.
void enter_scheduler(void)
Enter the scheduler and switch to the next thread.
void startup_invoke_cmdline_hooks(void)
#define MOS_SETUP(_param, _fn)
void startup_invoke_autoinit(init_target_t target)
void slab_init()
initialise the slab allocator
A wrapper type for the standard I/O streams.
ssize_t sysfs_printf(sysfs_file_t *file, const char *fmt,...)
#define SYSFS_ITEM_RO_STRING(name, value)
#define SYSFS_ITEM_RO_PRINTF(name, fmt,...)
#define SYSFS_RO_ITEM(_name, _show_fn)
#define SYSFS_AUTOREGISTER(sysfs_name, sysfs_items)