Having problems with address space switching.
Posted: Sat Oct 22, 2005 9:02 am
Now that I have implemented multitasking, memory management, and flat binary loading/execution, the next step would be multitasking flat binaries. Problem is I have all of my binaries linked at 0x600000. I could either switch to ELF and use relocation (not much information about that besides white papers on the format's specs), require all user programs to link at a different address (yuck), or create a separate virtual address space for each one by mapping the physical address I loaded the program at to 0x600000 (where I linked it).
Well I tried to do option 3. Now I hate pasting lots of code on here but I really have no way of debugging this unless Bochs can output its memory map for me and I have looked this over multiple times and tried out various things but to no avail.
InitMem SHOULD set up a linear mapping of physical -> virtual memory based on the amount of physical memory in KB (obtained from GRUB via multiboot header). Then it should set the rest of the page directory as not present and install the page directory into CR3 and enable CR0.
The map page function should do just as it implies, map a physical to virtual address.
The reload_page_mapping function is called to switch address spaces.
Upon loading a program, I allocate a page for it and map it to 0x600000.
I then copy the code to address 0x600000 which SHOULD now point to the allocated page from step 1. Now I just create a new task structure and set address to the physical address.
Cut to when the scheduler runs. After picking a new task, I switch address spaces.
When I actually run it, the first program I load is run in each virtual console instead of having both programs run at the same time. Something is awry with address space switching.
Well I tried to do option 3. Now I hate pasting lots of code on here but I really have no way of debugging this unless Bochs can output its memory map for me and I have looked this over multiple times and tried out various things but to no avail.
InitMem SHOULD set up a linear mapping of physical -> virtual memory based on the amount of physical memory in KB (obtained from GRUB via multiboot header). Then it should set the rest of the page directory as not present and install the page directory into CR3 and enable CR0.
The map page function should do just as it implies, map a physical to virtual address.
The reload_page_mapping function is called to switch address spaces.
Upon loading a program, I allocate a page for it and map it to 0x600000.
I then copy the code to address 0x600000 which SHOULD now point to the allocated page from step 1. Now I just create a new task structure and set address to the physical address.
Cut to when the scheduler runs. After picking a new task, I switch address spaces.
When I actually run it, the first program I load is run in each virtual console instead of having both programs run at the same time. Something is awry with address space switching.