MCPcopy Create free account
hub / github.com/bendudson/EuraliOS / kernel_thread_main

Function kernel_thread_main

kernel/src/main.rs:27–66  ·  view source on GitHub ↗

Main kernel thread entry point This is the first process added to the scheduler which is started once basic kernel functions have been initialised in kernel_entry

()

Source from the content-addressed store, hash-verified

25/// which is started once basic kernel functions have
26/// been initialised in kernel_entry
27fn kernel_thread_main() {
28 // User-space init process
29 let null = Arc::new(RwLock::new(Rendezvous::Empty));
30 let init_screen = Arc::new(RwLock::new(Rendezvous::Empty));
31 let init_thread = process::new_user_thread(
32 include_bytes!("../../user/init"),
33 process::Params{
34 handles: Vec::from([
35 // Null input
36 null,
37 // Output used to pass data
38 init_screen.clone()
39 ]),
40 io_privileges: true,
41 mounts: vfs::VFS::new(), // Create a Virtual File System
42 args: Vec::new(),
43 envs: Vec::new(),
44 }).unwrap();
45
46 // Allocate a memory chunk mapping video memory
47 let (virtaddr, _) = process::special_memory_chunk(
48 &init_thread,
49 32, // Pages, 128k. 0xC0000 - 0xA0000
50 0xA0000).unwrap();
51
52 // Remove chunk from table so it can be sent
53 let (physaddr, _) = init_thread.take_memory_chunk(virtaddr).unwrap();
54
55 // Send a message to init process containing the chunk.
56 // When received the chunk will be mapped into address space
57 init_screen.write().send(None, Message::Long(
58 message::VIDEO_MEMORY,
59 (0xC0000 - 0xA0000).into(),
60 physaddr.into()
61 ));
62
63 process::schedule_thread(init_thread);
64
65 kernel::hlt_loop();
66}
67
68/// Function called by the bootloader
69/// via _start entry point declared in entry_point! above

Callers

nothing calls this directly

Calls 8

new_user_threadFunction · 0.85
special_memory_chunkFunction · 0.85
schedule_threadFunction · 0.85
hlt_loopFunction · 0.85
cloneMethod · 0.80
take_memory_chunkMethod · 0.80
sendMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected