v86
Posted: Tue Mar 05, 2013 4:13 pm
I'm trying to avoid v86, but it's apparent that if i want over 1MB available for use (later i want to try to implement some sort of audio driver, and loading raw audio files for that driver will probably require more than 1MB for anything longer than 5 seconds, also i want to allow importation of raw RGB16 images as well), i'm going to need to implement virtual86 mode (turns out EDD's dword loading pointer is seg:off). The problem is, alot of the information out there already makes assumptions that I'm not only already doing certain things (already implementing task switching, etc), but that I plan to implement certain other things as well (enable page mode, etc). So, I am going to state my current kernel and the basic plans for it.
Current State:
0: My kernel gets loaded to 0x7E0:0x0000 by a bootloader that does nothing more than use EDD bios functions to call the usb drive (emulated hard drive).
1: A20 Enabled
2: GDT with 2 entries (code and data) with access to all possible 32bit memory is loaded
3: VBE mode set
4: jumped to pmode
5: IDT is loaded with custom interrupts
6: pic is remapped
7: write-back enabled in MTRR for all addresses except 0xC0000000 and up, which have write-combine enabled
8: A few ISRs are implmented for basic graphics functions (double buffering, char-mapped images, etc)
9: Some testing code to prove everything i have so far works
A: Entirely in x86 FASM
B: RAM locations marked "conventional" on the wiki's memory map are the only adultered locations (except wherever the LFB is hiding)
Plans:
-Primarily single threaded application (other threads will exist, but they are merely to handle keyboard, clock, etc and will preserve regs with pusha and popa)
-Both graphical and "console" modes
-Load and save functions based on disk sectors (LBA format)
-int 0x31 (kernel use only intended) will be given a pointer to copy a 16bit block of code to address 0x0070:0x0000 to be run by v86
-a "user program" (still ring 0) will be loaded into high memory then executed
-overwritable exception handlers (default is green screen of death and capslock light turned on)
-all pentium 4 instruction sets enabled (FPU, etc: I'm assuming my userbase is using at least a pentium 4 [probably later considering HD emulation USB is required to boot])
Goal:
I want to keep this kernel as simple as possible. This helps me (and others reading the source) learn and understand with minimal hair-ripping. This kernel is meant to be a simple learning tool to learn the bare basics from the ground up (the "user program" will be basic beginner lessons for learning x86 assembly assuming it to be the first programming language, but as lessons continue, it will eventually move into the kernel's source code [mostly for information, not really for writing a whole tutorial on OS development]).
I'm not too worried about the speed of the thing, so if hardware task switching (which i know nothing about at this point, aside from this mystical structure called a TSS which i don't fully understand) is simpler and gets us to 16bit real mode and back, I'm all for it. I assume that I will have to remap the IRQs back to ISR0 and up, but i'm not sure if i should keep Automatic EOI on and stuff like that or not. I just want to get to real mode and back to have the drive read, written to, video switch, etc without rewriting my kernel from scratch and going bald.
So how do i get that int 0x31 as painlessly as possible? (I can do the memcopy easily, obviously, i just need a way to get to real mode and back.)
Current State:
0: My kernel gets loaded to 0x7E0:0x0000 by a bootloader that does nothing more than use EDD bios functions to call the usb drive (emulated hard drive).
1: A20 Enabled
2: GDT with 2 entries (code and data) with access to all possible 32bit memory is loaded
3: VBE mode set
4: jumped to pmode
5: IDT is loaded with custom interrupts
6: pic is remapped
7: write-back enabled in MTRR for all addresses except 0xC0000000 and up, which have write-combine enabled
8: A few ISRs are implmented for basic graphics functions (double buffering, char-mapped images, etc)
9: Some testing code to prove everything i have so far works
A: Entirely in x86 FASM
B: RAM locations marked "conventional" on the wiki's memory map are the only adultered locations (except wherever the LFB is hiding)
Plans:
-Primarily single threaded application (other threads will exist, but they are merely to handle keyboard, clock, etc and will preserve regs with pusha and popa)
-Both graphical and "console" modes
-Load and save functions based on disk sectors (LBA format)
-int 0x31 (kernel use only intended) will be given a pointer to copy a 16bit block of code to address 0x0070:0x0000 to be run by v86
-a "user program" (still ring 0) will be loaded into high memory then executed
-overwritable exception handlers (default is green screen of death and capslock light turned on)
-all pentium 4 instruction sets enabled (FPU, etc: I'm assuming my userbase is using at least a pentium 4 [probably later considering HD emulation USB is required to boot])
Goal:
I want to keep this kernel as simple as possible. This helps me (and others reading the source) learn and understand with minimal hair-ripping. This kernel is meant to be a simple learning tool to learn the bare basics from the ground up (the "user program" will be basic beginner lessons for learning x86 assembly assuming it to be the first programming language, but as lessons continue, it will eventually move into the kernel's source code [mostly for information, not really for writing a whole tutorial on OS development]).
I'm not too worried about the speed of the thing, so if hardware task switching (which i know nothing about at this point, aside from this mystical structure called a TSS which i don't fully understand) is simpler and gets us to 16bit real mode and back, I'm all for it. I assume that I will have to remap the IRQs back to ISR0 and up, but i'm not sure if i should keep Automatic EOI on and stuff like that or not. I just want to get to real mode and back to have the drive read, written to, video switch, etc without rewriting my kernel from scratch and going bald.
So how do i get that int 0x31 as painlessly as possible? (I can do the memcopy easily, obviously, i just need a way to get to real mode and back.)