Clear Screen
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Clear Screen
except you could like using a -O3 compile flag, your code seems absolutely correct ... maybe you have something wrong with your interrupt handler (give it a try with interrupt disabled ...)
Re:Clear Screen
interupts should be disabled. I haven't enabled interrupts yet. All i have done is jumped to my C Kernel and then called the clear screen function.
Peter
Peter
Re:Clear Screen
The assembly looks correct, but I haven't seen the full picture, with register values from bochsout.txt at the point where you exit.
Re:Clear Screen
Bochs output when i quit
Code: Select all
protected mode
00004516500i[CPU ] CS.d_b = 32 bit
00004516500i[CPU ] SS.d_b = 32 bit
00004516500i[CPU ] | EAX=c00b8000 EBX=00000007 ECX=00000000 EDX=00000080
00004516500i[CPU ] | ESP=000000df EBP=000000e7 ESI=c0041000 EDI=c0101000
00004516500i[CPU ] | IOPL=0 NV UP DI NG NZ NA PE NC
00004516500i[CPU ] | SEG selector base limit G D
00004516500i[CPU ] | SEG sltr(index|ti|rpl) base limit G D
00004516500i[CPU ] | DS:0010( 0002| 0| 0) 40000000 000fffff 1 1
00004516500i[CPU ] | ES:0010( 0002| 0| 0) 40000000 000fffff 1 1
00004516500i[CPU ] | FS:0010( 0002| 0| 0) 40000000 000fffff 1 1
00004516500i[CPU ] | GS:0010( 0002| 0| 0) 40000000 000fffff 1 1
00004516500i[CPU ] | SS:0008( 0001| 0| 0) 00800000 000f00ff 1 1
00004516500i[CPU ] | CS:0018( 0003| 0| 0) 40000000 000fffff 1 1
00004516500i[CPU ] | EIP=c0100053 (c0100053)
00004516500i[CPU ] | CR0=0x60000011 CR1=0x00000000 CR2=0x00000000
00004516500i[CPU ] | CR3=0x00000000 CR4=0x00000000
00004516500i[ ] restoring default signal behavior
00004516500i[CTRL ] quit_sim called with exit code 1
Re:Clear Screen
Ah, much better.
You've got a very strange stack setup. C compilers expect you to have the stack segment aliased with the data segment; that is, they expect than an offset in one points to the same memory as the same offset in the other. In reality this means that your DS and SS descriptors must have the same base and limit, which they don't here. You should use selector 0x10 for SS as well as DS, and set ESP to point to the end of a large (say, 4096 bytes) array in your program before you call any C code.
You've got a very strange stack setup. C compilers expect you to have the stack segment aliased with the data segment; that is, they expect than an offset in one points to the same memory as the same offset in the other. In reality this means that your DS and SS descriptors must have the same base and limit, which they don't here. You should use selector 0x10 for SS as well as DS, and set ESP to point to the end of a large (say, 4096 bytes) array in your program before you call any C code.
Re:Clear Screen
Ah okay
when i do that i get a really weird problem in that my code will just crash when i jump to a function. Does the data segment also have to be aligned with the code segment?
Also if this is teh case how would i go about making my kernel so that teh stack is at the top of 4Gb and works down where as the codes at 3Gb or is this not possible?
Peter
when i do that i get a really weird problem in that my code will just crash when i jump to a function. Does the data segment also have to be aligned with the code segment?
Also if this is teh case how would i go about making my kernel so that teh stack is at the top of 4Gb and works down where as the codes at 3Gb or is this not possible?
Peter
Re:Clear Screen
Do you really need the stack to be at the top of the address space? Once you've enabled paging you can put it at any address you want, but before then it's not possible without a hack. I'd recommend you set aside a large array, put the stack there until paging it set up, then reclaim the old stack.
Re:Clear Screen
Thats sounds like a good way to do it. So do i need to have my data segment in teh same place as my code segment?
Peter
Peter
Re:Clear Screen
When i try and run the stack in the data segment i get a running in Bogus memory area. I think this is because i have set my Data selector to have a base of 0x40100000 so when it accesses the stack it is accessing memory way above physical. The problem then is if i move the data segment the C Kernel links to 3Gb but is loaded at 1Mb so if i set the Data selector to physical memory it will no longer be able to access the data segment in C.
Peter
Peter
Re:Clear Screen
ESP is a normal pointer. Set it to a high value, near C000_0000, and the normal wraparound will equate that to a physical address near 0010_0000. Trust me.
Re:Clear Screen
Hey Guys
I managed to get it working. By setting my data segment to 0Mb and stack segment to the same place i have now got it working. So all i have is my code segment at 0xC0000000 and my data and stacka at 0x0. The only problem i can see arising is when i turn on paging but i guess ill have to wait and see for that.
Cheers
Peter
I managed to get it working. By setting my data segment to 0Mb and stack segment to the same place i have now got it working. So all i have is my code segment at 0xC0000000 and my data and stacka at 0x0. The only problem i can see arising is when i turn on paging but i guess ill have to wait and see for that.
Cheers
Peter
Re:Clear Screen
Cheers Tim
I checked out what you said to do and that works as well. I am now spoilt for options . Ill see which one makes getting paging enabled easier.
Peter
I checked out what you said to do and that works as well. I am now spoilt for options . Ill see which one makes getting paging enabled easier.
Peter