30 typedef void (*init_function_t)(
void);
31 extern const init_function_t __init_array_start[], __init_array_end;
33 pr_dinfo2(setup,
"invoking constructors...");
34 for (
const init_function_t *func = __init_array_start; func != &__init_array_end; func++)
82 pr_warn(
"init path not specified");
95 char *var_arg =
strdup(arg);
105 pr_emph(
"MOS %s on %s (%s, %s), compiler %s", MOS_KERNEL_VERSION, MOS_ARCH, MOS_KERNEL_REVISION, __DATE__, __VERSION__);
122 pr_dinfo2(vmm,
"initializing paging...");
131 pr_dinfo2(vmm,
"mapping kernel space...");
173 init_args.argv = kcalloc(1,
sizeof(
char *));
181 mos_panic(
"failed to mount rootfs, vfs_mount returns %ld", ret);
186 mos_panic(
"failed to mount initrd, vfs_mount returns %ld", ret);
196 const stdio_t init_io = { .in = &init_con->
io, .out = &init_con->
io, .err = &init_con->
io };
197 const char *
const init_envp[] = {
198 "PATH=/initrd/programs:/initrd/bin:/bin",
209 for (
u32 i = 0; init_envp[i]; i++)
214 mos_panic(
"failed to create init process");
230 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_t * elf_create_process(const char *path, process_t *parent, const char *const argv[], const char *const envp[], const stdio_t *ios)
MOSAPI char * strdup(const char *src)
MOSAPI void(1, 2) fatal_abort(const char *fmt
MOSAPI void linked_list_init(list_node_t *head_node)
Initialise a circular double linked list.
vmap_t * mm_map_user_pages(mm_context_t *mmctx, ptr_t vaddr, pfn_t pfn, size_t npages, vm_flags flags, valloc_flags vaflags, vmap_type_t type, vmap_content_t content)
void mm_map_kernel_pages(mm_context_t *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.
@ 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 void invoke_constructors(void)
static mm_context_t mos_kernel_mm
static struct @25 init_args
void mos_start_kernel(void)
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.
__BEGIN_DECLS void tasks_init()
@ INIT_TARGET_SLAB_AUTOINIT
#define MOS_SETUP(_param, _fn)
__BEGIN_DECLS void startup_invoke_cmdline_hooks(void)
void startup_invoke_autoinit(init_target_t target)
#define spinlock_init(lock)
spinlock_t mm_lock
protects [pgd] and the [mmaps] list (the list itself, not the vmap_t objects)
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)