flat assembler
Message board for the users of flat assembler.

Index > OS Construction > x86/x86_64 compatible OS

Author
Thread Post new topic Reply to topic
Coty



Joined: 17 May 2010
Posts: 554
Location: ␀
Coty
OK, I got myself a new(sorta) 64bit computer... Now I was thinking of expanding my OS to fit 64bits, but I don't want to lose compatibility with all of my 32bit PCs. So I thought of re-writing my OS to run on both with no RAM limitations..

full planned booting method:
1. Check for i386, If no, stop.
2. Enable 32bit P-mode.
3. Check for 64bit OS, If no, skip to step 6
4. Enable Pagging (I think this is needed for long mode...)
5. Enable 64bit P-mode.
6. Load IDT
7. Re-map the P.I.C.
8. enable keyboard. and other used IRQs
9. Setup Memory maniger.
10. Start CLI.

I have not really looked into long mode yet, First I want to know if this is possible, if so please look over my boot method and point out what needs to change...

PS: I know that 32bit PCs Can not use 64bit regs, so I plan to use only 32bit regs...

PPS: I also know that ESI/EDI can not reach past 4GB, but my kernel will probibly never be a quarter of that size, just wanna give applications all the memory there is... and full use over regs... (single tasking OS also)

_________________
http://codercat.org/
Post 14 Sep 2010, 22:12
View user's profile Send private message Send e-mail Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4242
Location: 2018
edfed
i think that you should write the OS in 32 bits, with an extension for 64 bits, just a sort of bridge that let you use 64 bits registers, paging, and mode, within a 32 bits application.

something like an interrupt?

INT 64h:
if pmode then, switch longmode
if long mode then, switch pmode
if rmode then do nothing
iret

no?

then, to use 64 bits code in your app, just do that:
Code:
use32
...
 mov [eax],eax
...
int 64h
use64
...
mov rax,[rax]
...
int 64h
use32
...
mov eax,[eax+eax]
    
Post 14 Sep 2010, 22:22
View user's profile Send private message Visit poster's website Reply with quote
Coty



Joined: 17 May 2010
Posts: 554
Location: ␀
Coty
Wow, thanks for the fast reply!

So want I want to do is possible? OK, well that Manuel switch sounds good, I think I will:

automatically detect modes, save a 0 or a 1, (0=32, 1=64), then place in the front of every application 1 byte, that says what mode is needed and the OS auto swiches to it, for example in my OS I plan to load the first byte and test it:

Bit 0: If 1, Need to be 1 (help verify valid app.)
Bit 1: If 1, APP needs FPU
Bit 2: If 1, APP needs MMX
...
Bit 7: If 1, App needs 64bit

and the user can use an interupt to switch back and forth ect.

Thank you edfed!

_________________
http://codercat.org/
Post 14 Sep 2010, 22:34
View user's profile Send private message Send e-mail Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4242
Location: 2018
edfed
soon, i'll restart to play with protected mode switch, and hope to write a very good pm/rm switcher, using an interrupt.

for example, INT 64h Very Happy

good luck!
Post 14 Sep 2010, 22:44
View user's profile Send private message Visit poster's website Reply with quote
Coty



Joined: 17 May 2010
Posts: 554
Location: ␀
Coty
Why not 40h? Since 40h is translated into the real, whole number of 64, like an easter egg or something Very Happy

_________________
http://codercat.org/
Post 15 Sep 2010, 14:21
View user's profile Send private message Send e-mail Visit poster's website Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
Coty,

64h == 100 Wink
Post 15 Sep 2010, 15:04
View user's profile Send private message Reply with quote
Coty



Joined: 17 May 2010
Posts: 554
Location: ␀
Coty
baldr,

Your ability to convert numbers amazes me Laughing

int 40h == 64 dec, == 64bit swap (hidden surprise since everyone says the hex value not the dec in interrupt tables)... 64h is 100dec, long mode != 100 bits Wink

_________________
http://codercat.org/
Post 15 Sep 2010, 18:05
View user's profile Send private message Send e-mail Visit poster's website Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
Coty,

I don't know why edfed chooses int 64h, too. Wink
Post 15 Sep 2010, 18:50
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4242
Location: 2018
edfed
because i always write interrupt request in hexa.
then, in my idea, i want to create (the 12th october 2045) a set of interrupts, that uses letters A to F, and decimal digits as a mnemonic.

for example, int for the screen can be int 0FBh (Frame buffer)
int for IDE0 bus = int 0D0h, int 0D1h for ide1.

then, int for 64 bit mode is int 64h. to respect "the rule" of int in hexadecimal. Very Happy but it is not an obligation, just a suggestion.
Post 15 Sep 2010, 20:20
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.