Skip to content

Commit 5e78833

Browse files
author
Diego Ferrari
committed
[PROJ] TODO and log cleanup
1 parent 34f8065 commit 5e78833

7 files changed

Lines changed: 13 additions & 25 deletions

File tree

kernel/console/kconsole/terminal.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,6 @@ void Terminal::run_command(){
104104
command_running = true;
105105
}
106106

107-
//TODO: implement the full state machine explained at https://vt100.net/emu/dec_ansi_parser & https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
108-
//The current implementation is not standard compliant and uses hex colors as [FF0000;
109107
void Terminal::TMP_test(int argc, const char* args[]){
110108
// const char *term = seek_to(args, '\033');
111109
// if (*term == 0) return;

kernel/filesystem/filesystem.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ file_offset shared_seek(file *fd, file_offset offset){
9393
}
9494

9595
sizedptr shared_readdir(const char* path){
96-
kprintf("Here?");
9796
//TODO: Need to pass a buffer and write to that, returning size
9897
return p9Driver->list_contents(path);
9998
}
@@ -176,7 +175,6 @@ size_t write_file(file *descriptor, const char* buf, size_t size){
176175

177176
sizedptr list_directory_contents(const char *path){
178177
const char *search_path = path;
179-
kprintf("Searching in %s",search_path);
180178
driver_module *mod = get_module(&search_path);
181179
if (!mod){
182180
kprintf("No module for path");

kernel/graph/drivers/virtio_gpu_pci/virtio_gpu_pci.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232

3333
#define VIRTIO_GPU_FORMAT_B8G8R8A8_UNORM 1
3434

35-
//TODO: format logs
3635
VirtioGPUDriver* VirtioGPUDriver::try_init(gpu_size preferred_screen_size){
3736
VirtioGPUDriver* driver = new VirtioGPUDriver();
3837
if (driver->init(preferred_screen_size))
@@ -483,7 +482,6 @@ void VirtioGPUDriver::set_cursor_pressed(bool pressed){
483482
}
484483

485484
void VirtioGPUDriver::create_window(uint32_t x, uint32_t y, uint32_t width, uint32_t height, draw_ctx *new_ctx){
486-
// TODO: use separate resources for windows. Will probably make rendering a lot faster. Do before DOOM
487485
new_ctx->fb = (uint32_t*)palloc(width * height * BPP, MEM_PRIV_SHARED, MEM_RW, true);
488486
new_ctx->width = width;
489487
new_ctx->height = height;

kernel/input/input_dispatch.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,6 @@ bool sys_shortcut_triggered(uint16_t pid, uint16_t sid){
170170
return false;
171171
}
172172

173-
// TODO: discard input before DOOM
174-
175173
bool input_init(){
176174
for (int i = 0; i < 16; i++) shortcuts[i] = {};
177175
if (BOARD_TYPE == 2 && RPI_BOARD != 5){

kernel/input/usb_types.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ typedef struct __attribute__((packed)) {
6868
uint8_t bDescriptorType;
6969
uint8_t wDescriptorLength;
7070
}__attribute__((packed)) descriptors[1];
71-
//TODO: wDescriptorLength is supposed to be 16, but for some reason the descriptor from usb-kbd is 8. Will need to fix this once we do a real device
7271
} usb_hid_descriptor;
7372

7473
typedef struct __attribute__((packed)) {
@@ -77,7 +76,6 @@ typedef struct __attribute__((packed)) {
7776
uint8_t bmAttributes;
7877
uint8_t wMaxPacketSize;
7978
uint8_t bInterval;
80-
//TODO: wMaxPacketSize is supposed to be 16, but for some reason the descriptor from usb-kbd is 8. Will need to fix this once we do a real device
8179
} usb_endpoint_descriptor;
8280

8381
typedef struct __attribute__((packed)) {

kernel/memory/mmu.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ void mmu_unmap(uint64_t va, uint64_t pa){
172172

173173
void mmu_alloc(){
174174
page_table_l0 = (uint64_t*)talloc(PAGE_SIZE);
175-
//TODO: use palloc, but consider it won't be able to add sections to MMU during that init
176175
}
177176

178177
extern uint64_t shared_start;
@@ -195,13 +194,13 @@ void mmu_init() {
195194
mmu_map_4kb(addr, addr, MAIR_IDX_DEVICE, MEM_RW, MEM_PRIV_KERNEL);
196195

197196
for (uint64_t addr = (uintptr_t)&shared_start; addr < (uintptr_t)&shared_code_end; addr += GRANULE_4KB)
198-
mmu_map_4kb(addr, addr, MAIR_IDX_NORMAL, MEM_EXEC | MEM_RO, MEM_PRIV_SHARED);//TODO: separate into sections and mark as shared
197+
mmu_map_4kb(addr, addr, MAIR_IDX_NORMAL, MEM_EXEC | MEM_RO, MEM_PRIV_SHARED);
199198

200199
for (uint64_t addr = (uintptr_t)&shared_code_end; addr < (uintptr_t)&shared_ro_end; addr += GRANULE_4KB)
201-
mmu_map_4kb(addr, addr, MAIR_IDX_NORMAL, MEM_RO, MEM_PRIV_SHARED);//TODO: separate into sections and mark as share
200+
mmu_map_4kb(addr, addr, MAIR_IDX_NORMAL, MEM_RO, MEM_PRIV_SHARED);
202201

203202
for (uint64_t addr = (uintptr_t)&shared_ro_end; addr < (uintptr_t)&shared_end; addr += GRANULE_4KB)
204-
mmu_map_4kb(addr, addr, MAIR_IDX_NORMAL, MEM_RW, MEM_PRIV_SHARED);//TODO: separate into sections and mark as shared
203+
mmu_map_4kb(addr, addr, MAIR_IDX_NORMAL, MEM_RW, MEM_PRIV_SHARED);
205204

206205
if (XHCI_BASE)
207206
for (uint64_t addr = XHCI_BASE; addr <= XHCI_BASE + 0x1000; addr += GRANULE_4KB)

kernel/memory/page_allocator.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "exceptions/exception_handler.h"
66
#include "std/memory.h"
77
#include "math/math.h"
8+
#include "console/kio.h"
89

910
#define PD_TABLE 0b11
1011
#define PD_BLOCK 0b01
@@ -55,8 +56,6 @@ void pfree(void* ptr, uint64_t size) {
5556
uint64_t start;
5657
uint64_t end;
5758

58-
#include "console/kio.h"
59-
6059
void* palloc(uint64_t size, uint8_t level, uint8_t attributes, bool full) {
6160
if (!start) start = count_pages(get_user_ram_start(),PAGE_SIZE);
6261
if (!end) end = count_pages(get_user_ram_end(),PAGE_SIZE);
@@ -169,7 +168,7 @@ bool page_used(uintptr_t ptr){
169168
void mark_used(uintptr_t address, size_t pages)
170169
{
171170
if ((address & (PAGE_SIZE - 1)) != 0) {
172-
// kprintf("[mark_used error] address %x not aligned", address);
171+
kprintf("[mark_used error] address %x not aligned", address);
173172
return;
174173
}
175174
if (pages == 0) return;
@@ -193,7 +192,7 @@ void* kalloc(void *page, uint64_t size, uint16_t alignment, uint8_t level){
193192

194193
size = (size + alignment - 1) & ~(alignment - 1);
195194

196-
// kprintfv("[in_page_alloc] Requested size: %x", size);
195+
kprintfv("[in_page_alloc] Requested size: %x", size);
197196

198197
mem_page *info = (mem_page*)page;
199198

@@ -206,43 +205,43 @@ void* kalloc(void *page, uint64_t size, uint16_t alignment, uint8_t level){
206205
FreeBlock** curr = &info->free_list;
207206
while (*curr) {
208207
if ((*curr)->size >= size) {
209-
// kprintfv("[in_page_alloc] Reusing free block at %x",(uintptr_t)*curr);
208+
kprintfv("[in_page_alloc] Reusing free block at %x",(uintptr_t)*curr);
210209

211210
uint64_t result = (uint64_t)*curr;
212211
*curr = (*curr)->next;
213212
memset((void*)result, 0, size);
214213
info->size += size;
215214
return (void*)result;
216215
}
217-
// kprintfv("-> %x",(uintptr_t)&(*curr)->next);
216+
kprintfv("-> %x",(uintptr_t)&(*curr)->next);
218217
curr = &(*curr)->next;
219218
}
220219

221-
// kprintfv("[in_page_alloc] Current next pointer %x",info->next_free_mem_ptr);
220+
kprintfv("[in_page_alloc] Current next pointer %x",info->next_free_mem_ptr);
222221

223222
info->next_free_mem_ptr = (info->next_free_mem_ptr + alignment - 1) & ~(alignment - 1);
224223

225-
// kprintfv("[in_page_alloc] Aligned next pointer %x",info->next_free_mem_ptr);
224+
kprintfv("[in_page_alloc] Aligned next pointer %x",info->next_free_mem_ptr);
226225

227226
if (info->next_free_mem_ptr + size > (((uintptr_t)page) + PAGE_SIZE)) {
228227
if (!info->next)
229228
info->next = palloc(PAGE_SIZE, level, info->attributes, false);
230-
// kprintfv("[in_page_alloc] Page full. Moving to %x",(uintptr_t)info->next);
229+
kprintfv("[in_page_alloc] Page full. Moving to %x",(uintptr_t)info->next);
231230
return kalloc(info->next, size, alignment, level);
232231
}
233232

234233
uint64_t result = info->next_free_mem_ptr;
235234
info->next_free_mem_ptr += size;
236235

237-
// kprintfv("[in_page_alloc] Allocated address %x",result);
236+
kprintfv("[in_page_alloc] Allocated address %x",result);
238237

239238
memset((void*)result, 0, size);
240239
info->size += size;
241240
return (void*)result;
242241
}
243242

244243
void kfree(void* ptr, uint64_t size) {
245-
// kprintfv("[page_alloc_free] Freeing block at %x size %x",(uintptr_t)ptr, size);
244+
kprintfv("[page_alloc_free] Freeing block at %x size %x",(uintptr_t)ptr, size);
246245

247246
memset((void*)ptr,0,size);
248247

0 commit comments

Comments
 (0)