flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Getting Into 64-bits...

Author
Thread Post new topic Reply to topic
smiddy



Joined: 31 Oct 2004
Posts: 559
smiddy
Well, I think tonight I make the plunge and try to get into 64-bits Long Mode with my OS. Before I go try, I have a few questions for you smart guys who've already wandered down this path:

    I am using MZ EXE to launch my OS, which means my GDT carries the offset-ed base address, and 4G space. My thoughts are to place all my 64 bit code at the end of my current code, which goes to flat 32 bits, without paging BTW, with a couple of selector entries for 0 - 4G, and base address - 4G. So, I can add the two CODE and DATA selectors for 64 bits, where base address is ignored, along with size: can I simply use the ORG [address] at teh end of my current code where I intend to place the 64-bits, copy that 64-bit code and data to that address, and FASM will keep track as if it was at that ORG from then on out?

    Is there anything specifically I need to do in order to return to 32-bits, and even then, to 16-bits (or real mode): other than keeping track of all the selectors and switching the correct registers, turn off paging?

    In paging, when I jump to the 64-bit code, my kernel shouldn't need to be "placed" into a page, it should continue to run in the physical locales, correct, or do I have to consider the kernel code as running from "the paged" memory?

That's it for now, I know I will have many more questions.
Post 10 Feb 2015, 18:01
View user's profile Send private message Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 619
cod3b453
For the first paragraph it's a double yes (I think - don't know if MZ offsets you describe introduce any issues). I can't comment on the second, I've never done it.

On the last, you'll definitely want to map your 64bit entry point as an executable paged location as well as mapping every single bit of memory that is getting used for other data (boot tables in 16/32bit code/GDT/IDT/VESA LFB/VGA/etc) in the 64bit code before you get to code that modifies the mappings. [I found it was just as easy to map everything from E820 as 2MB pages mapped 1:1 to get things up and running].

Hope that helps.
Post 10 Feb 2015, 23:20
View user's profile Send private message Reply with quote
smiddy



Joined: 31 Oct 2004
Posts: 559
smiddy
Yes, thanks! Your second paragraph is huge, much appreciated! If I can figure out the mapping that is (I assume if I map everything then the OS will use it [for now]). I am having issues elsewhere, not able to code tonight like I would prefer, so it will have to wait until I can get to it, maybe tomorrow.

I've been going back and forth between real and protected modes, and want the ability to go between real, protected, and now long mode. Lots of transitions, so long as I've set it up correctly, it [cross your fingers] should just work. Smile

What sucks is I've been thinking about this all day and I'm sure it will work, but I cannot get to it right now. <sniff>
Post 11 Feb 2015, 01:53
View user's profile Send private message 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.