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
()
| 25 | /// which is started once basic kernel functions have |
| 26 | /// been initialised in kernel_entry |
| 27 | fn 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 |
nothing calls this directly
no test coverage detected