What's problem with this code?
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: What's problem with this code?
Practically all OSes use paging over segmentation. That means they get rid of the segmentation as much as they can, by loading 4G selector into all segments.
And of course, you'll have to set your own GDT because GRUB is not guarantueed to leave you one, and several system functions will still need the GDT to reload segments (like interrupts and friends)
And of course, you'll have to set your own GDT because GRUB is not guarantueed to leave you one, and several system functions will still need the GDT to reload segments (like interrupts and friends)
-
- Member
- Posts: 2566
- Joined: Sun Jan 14, 2007 9:15 pm
- Libera.chat IRC: miselin
- Location: Sydney, Australia (I come from a land down under!)
- Contact:
Re: What's problem with this code?
Not to mention not setting your own GDT means adding things like TSSs or userland selectors will be quite difficult
-
- Member
- Posts: 76
- Joined: Mon Aug 18, 2008 6:17 am
Re: What's problem with this code?
To: JameM
About: my post on Tue Sep 23, 2008 8:32 pm
As you said, all segment are set to be the same. Ok, and what about esp? 0xffffffff to 0????? is not a risk????
About: my post on Tue Sep 23, 2008 8:32 pm
As you said, all segment are set to be the same. Ok, and what about esp? 0xffffffff to 0????? is not a risk????
-
- Member
- Posts: 2566
- Joined: Sun Jan 14, 2007 9:15 pm
- Libera.chat IRC: miselin
- Location: Sydney, Australia (I come from a land down under!)
- Contact:
Re: What's problem with this code?
The stack segment is set to the same as DS - base 0, limit 0xffffffff.
Re: What's problem with this code?
You are quite right to worry about the risk here and if the x86 only used segmentation, you would not do this.InsightSoft wrote:As you said, all segment are set to be the same. Ok, and what about esp? 0xffffffff to 0????? is not a risk????
Fortunately, paging negates this. You will eventually have a setup where the page immediately below your stack is not present. This will mean that if the stack overflows, you will get a harmless Page Fault Exception rather than overwriting your heap.
Cheers,
Adam
-
- Member
- Posts: 76
- Joined: Mon Aug 18, 2008 6:17 am
Re: What's problem with this code?
about my problems: all solved... gdt, idt, c code ...all is working FINEEEEEEEEEEEEEEEEEEEEEEEEEEE! (thanks you guys)
Now I have another question: I load my kernel to 9000:0000 using 0x13 disk function, taking advantage while in rm (16 bit code)...
now, how can load from disk, to the 'deep water' (high memory)??? the same 0x13 function?
Now I have another question: I load my kernel to 9000:0000 using 0x13 disk function, taking advantage while in rm (16 bit code)...
now, how can load from disk, to the 'deep water' (high memory)??? the same 0x13 function?
-
- Member
- Posts: 76
- Joined: Mon Aug 18, 2008 6:17 am
Re: What's problem with this code?
Ok... I see... (thanks)AJ wrote:You are quite right to worry about the risk here and if the x86 only used segmentation, you would not do this.InsightSoft wrote:As you said, all segment are set to be the same. Ok, and what about esp? 0xffffffff to 0????? is not a risk????
Fortunately, paging negates this. You will eventually have a setup where the page immediately below your stack is not present. This will mean that if the stack overflows, you will get a harmless Page Fault Exception rather than overwriting your heap.
Cheers,
Adam
Re: What's problem with this code?
There are several threads about this - IIRC it's either unreal mode or jumping back and forth between PM and RM, using int 0x13 in RM to transfer a sector to somewhere <1MB, then going to PM to copy that >1MB, repeat...InsightSoft wrote:about my problems: all solved... gdt, idt, c code ...all is working FINEEEEEEEEEEEEEEEEEEEEEEEEEEE! (thanks you guys)
Now I have another question: I load my kernel to 9000:0000 using 0x13 disk function, taking advantage while in rm (16 bit code)...
now, how can load from disk, to the 'deep water' (high memory)??? the same 0x13 function?
-
- Member
- Posts: 76
- Joined: Mon Aug 18, 2008 6:17 am
Re: What's problem with this code?
What about creating a descriptor (16bit opcode) to point to 16 bit code of interrupt (taking from IVT)... and then use it on PM? what about?JamesM wrote:There are several threads about this - IIRC it's either unreal mode or jumping back and forth between PM and RM, using int 0x13 in RM to transfer a sector to somewhere <1MB, then going to PM to copy that >1MB, repeat...InsightSoft wrote:about my problems: all solved... gdt, idt, c code ...all is working FINEEEEEEEEEEEEEEEEEEEEEEEEEEE! (thanks you guys)
Now I have another question: I load my kernel to 9000:0000 using 0x13 disk function, taking advantage while in rm (16 bit code)...
now, how can load from disk, to the 'deep water' (high memory)??? the same 0x13 function?
Re: What's problem with this code?
You'd be running 16 bit real-mode code in 32-bit protected mode. Think about it.InsightSoft wrote:What about creating a descriptor (16bit opcode) to point to 16 bit code of interrupt (taking from IVT)... and then use it on PM? what about?JamesM wrote:There are several threads about this - IIRC it's either unreal mode or jumping back and forth between PM and RM, using int 0x13 in RM to transfer a sector to somewhere <1MB, then going to PM to copy that >1MB, repeat...InsightSoft wrote:about my problems: all solved... gdt, idt, c code ...all is working FINEEEEEEEEEEEEEEEEEEEEEEEEEEE! (thanks you guys)
Now I have another question: I load my kernel to 9000:0000 using 0x13 disk function, taking advantage while in rm (16 bit code)...
now, how can load from disk, to the 'deep water' (high memory)??? the same 0x13 function?
-
- Member
- Posts: 76
- Joined: Mon Aug 18, 2008 6:17 am
Re: What's problem with this code?
I will take a tour to the IIRC... So, the only way is:
1) goto RM;
2) run the code;
3) back do PM;
4) copy from Low memory to deep water;
5) Run code...
right?
1) goto RM;
2) run the code;
3) back do PM;
4) copy from Low memory to deep water;
5) Run code...
right?