34 const char **
argv =
nullptr;
72 pr_warn(
"init path not specified");
85 char *var_arg =
strdup(arg);
95 pr_emph(
"MOS %s on %s (%s, %s), compiler %s", MOS_KERNEL_VERSION, MOS_ARCH, MOS_KERNEL_REVISION, __DATE__, __VERSION__);
112 pr_dinfo2(vmm,
"initializing paging...");
121 pr_dinfo2(vmm,
"mapping kernel space...");
160 init_args.argv = kcalloc<const char *>(1);
168 mos_panic(
"failed to mount rootfs, vfs_mount returns %ld", ret);
173 mos_panic(
"failed to mount initrd, vfs_mount returns %ld", ret);
182 const stdio_t init_io = { .in = &init_con->
io, .out = &init_con->
io, .err = &init_con->
io };
183 const char *
const init_envp[] = {
184 "PATH=/initrd/programs:/initrd/bin:/bin",
195 for (
u32 i = 0; init_envp[i]; i++)
200 mos_panic(
"failed to create init process");
216 MOS_ASSERT_X(initrd_map,
"failed to map initrd into init process");
#define MOS_ASSERT_X(cond, msg,...)
#define MOS_UNREACHABLE()
#define MOS_DEFAULT_INIT_PATH
Process * elf_create_process(const char *path, Process *parent, const char *const argv[], const char *const envp[], const stdio_t *ios)
MOSAPI char * strdup(const char *src)
MOSAPI void linked_list_init(list_node_t *head_node)
Initialise a circular double linked list.
void mm_map_kernel_pages(MMContext *mmctx, ptr_t vaddr, pfn_t pfn, size_t npages, vm_flags 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, vm_flags flags, valloc_flags vaflags, vmap_type_t type, vmap_content_t content)
@ VALLOC_EXACT
Allocate pages at the exact address.
#define pmm_ref(thing, npages)
long vfs_mount(const char *device, const char *path, const char *fs, const char *options)
Mount a filesystem at a given existing path.
long vfs_mkdir(const char *path)
Create a directory.
static sysfs_item_t kernel_sysfs_items[]
static struct @274354113332067226201353316121227275173061230210 init_args
void mos_start_kernel(void)
static MMContext mos_kernel_mm
static bool init_sysfs_argv(sysfs_file_t *file)
void string_unquote(char *str)
const char ** cmdline_parse(const char **inargv, char *inbuf, size_t length, size_t *out_count)
#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_dinfo2(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
#define spinlock_init(lock)
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)