Skip to content

Memory#67

Open
CodeAnarchist wants to merge 26 commits intodifferrari:mainfrom
CodeAnarchist:mem
Open

Memory#67
CodeAnarchist wants to merge 26 commits intodifferrari:mainfrom
CodeAnarchist:mem

Conversation

@CodeAnarchist
Copy link
Contributor

No description provided.

@@ -1,25 +1,30 @@
ENTRY(main)
PHDRS {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These linker files aren't used AFAIR, we can get rid of them entirely


USE_FB=true
USE_NET=false
USE_FB=false
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep defaults as they are

} __attribute__((packed)) t_clunk;

bool Virtio9PDriver::clunk(virtio_device *dev, uint32_t fid, uint16_t tag) {
t_clunk *cmd = (t_clunk*)kalloc(dev->memory_page, sizeof(t_clunk), ALIGN_4KB, MEM_PRIV_KERNEL);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

9p now uses the p9_helper to create packet, to avoid alignment issues on new versions of qemu

//https://www.qemu.org/docs/master/system/arm/raspi.html
//raspi4b has no pcie root
//TODO use DTB as source
#if QEMU
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PCI(e) needs some work. the real pi has pcie, qemu does not, let's leave it as is for now

extern char __bss_start[];
extern char __bss_end[];
void kernel_main(uint64_t board_type, uint64_t dtb_pa) {
for (uintptr_t p = (uintptr_t)__bss_start; p < (uintptr_t)__bss_end; p += 8) *(uint64_t*)p = 0;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be a memset call? Slightly more optimal, cleaner and open to future optimization

{ "monitor", monitor_procs },
};

process_t* load_proc(const char *full_name, const char *prog_name, int argc, const char *argv[]){
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's some new logic that needs to be included if you merge:

  • Any program that specifies a full path gets loaded from that path, there's some extra logic to set its bundle (.red) if it's part of the path. So if we try to exec /shared/applications/doom.red/doom.elf, it'll load that exact executable and everything before the doom.elf as the bundle
  • Any program that's just an executable name (ping, test, read) gets loaded as such from the bin folder
  • Any program not found in the bin folder gets loaded from the ones hardcoded here if it exists

if (buf->write_index == buf->read_index)
buf->read_index = (buf->read_index + 1) % INPUT_BUFFER_CAPACITY;

if (focused_proc->sleeping) wake_process(focused_proc);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't wake the proces in here or register event, it'll mess with any waiting logic, and the input is registered anyway.

gpu_set_cursor_pressed(last_cursor_state);
gpu_update_cursor(mouse_loc, true);
}
if (focused_proc && focused_proc->sleeping) wake_process(focused_proc);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't wake


if (buf->write_index == buf->read_index)
buf->read_index = (buf->read_index + 1) % INPUT_BUFFER_CAPACITY;
if (focused_proc->sleeping) wake_process(focused_proc);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't wake


proc->pc = PHYS_TO_VIRT(((uintptr_t)func));
kprintf("Kernel process %s (%i) allocated with address at %llx, stack at %llx-%llx, heap at %llx. %i argument(s)", (uintptr_t)name, proc->id, proc->pc, proc->sp - proc->stack_size, proc->sp, proc->heap, argc);
proc->output = (kaddr_t)palloc(PROC_OUT_BUF, MEM_PRIV_KERNEL, MEM_RW, true);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Output has been moved to being generated in the scheduler when writing to it


extern "C" void init_usb_process(){
if (!input_driver->use_interrupts)
USBDriver *driver = input_driver;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be possible to put this part in a function, or even on initialization

return false;
}

memset(disk_cmd, 0, sizeof(virtio_blk_req));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mem is always zero'd. Here and in the header files there's no need for explicit memset or default initialize alloc'd values

draw_ctx* gpu_get_ctx(){
if (!gpu_ready()) return 0;
return gpu_driver->get_ctx();
draw_ctx *ctx = gpu_driver->get_ctx();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems redundant

}

sizedptr audio_request_buffer(uint32_t device){
if (!audio_driver || !audio_driver->out_dev) panic("audio not ready", 0);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this and the other funcs, should be enough to return an error, not panic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants