Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > alt.os.development > #8336
| From | "Benjamin David Lunt" <zfysz@fysnet.net> |
|---|---|
| Newsgroups | alt.os.development |
| Subject | Re: 64-bit detection |
| Date | 2015-07-10 08:38 -0700 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <mnp0o7$c64$1@speranza.aioe.org> (permalink) |
| References | <mnn174$dd$1@speranza.aioe.org> <op.x1jgivqzyfako5@localhost> |
"Rod Pemberton" <boo@fasdfrewar.cdm> wrote in message
news:op.x1jgivqzyfako5@localhost...
> On Thu, 09 Jul 2015 19:47:49 -0400, Benjamin David Lunt <zfysz@fysnet.net>
> wrote:
>
>> Hi guys,
>
> Hi Ben.
>
>> Sorry I have been away for a little while. I have been
>> trying to follow some of the threads here, but haven't
>> had much time to read them all.
>
> ...
>
>> However, I had a thought a few days ago. Will my 32-bit
>> OS run on a 64-bit machine?
>
> Why wouldn't it? AFAIK, they didn't remove 32-bit mode.
As you probably can tell, I haven't read about it much at all.
My first experience was trying to install WinXP SP3 (32-bit)
on a 64-bit machine. It didn't even get past the initialization.
Don't know why, but it wouldn't install.
I later tried to run my OS on that same machine and it crashed
with a tripple fault.
I was just curious so at that time, I didn't persue the
tripple fault.
>> Well, after a few tweaks and fixes, yes it does.
>
> Why did it need any tweaks?
> What were the tweaks?
The modifications that I made may not have anything to do with
64-bit versus 32-bit cpus, it just so happened that I had to
make them to get it to work on a 64-bit machine.
For example, the first change had nothing to do with the CPU
and everything to do with my code. As you probably remember,
we recently had a discussion on the BIOS' memory reporting.
On this particular machine, it was reporting just over 6 gig
of RAM. Since that value uses at least 33 bits and my code
used a 32-bit value to store the total RAM, I was getting far
less than the 6-gig I expected.
A simple change from:
bit32u max_memory_in_bytes;
to
bit64u max_memory_in_bytes;
solved the issue. My memory handler uses 64-bit integers, but
I had completely forgotten about the limit check which still used
a 32-bit value. :-)
As for the triple fault, this was a little more complicated.
My loader file runs in unreal mode and has a 32-bit stack located
above the 1 meg mark (at 4 meg if I remember correctly, but the
location is arbitrary, can be anywhere in the 32-bit range
and of any size).[1]
However, the loader file still calls the BIOS which expects
the SS:SP value to be below the 1 meg limit. Therefore, I
call a BIOS wrapper that sets up a 16-bit stack, copies the
relevant stack contents from the 32-bit stack, calls the BIOS
and upon return, copies the relevant stack contents from the
16-bit stack to the 32-bit stack, then returning.
It just so happened that one of my functions was calling the
BIOS, bypassing the wrapper, and working just fine on a
32-bit machine. However, just as soon as I moved to the
64-bit machine, it faulted.
It was by chance that the high part of ESP was either not
being modified or was being preserved on return from the
call on the 32-bit machine, but on the 64-bit machine, the
high 32-bits was being modified and not preserved. Faulty
BIOS for not preserving all of ESP? Maybe, but why would it
have to save it knowing that in general, a call to the BIOS
would be from a 16-bit environment?
Anyway, I wrapped that BIOS call, changing
_asm {
mov eax,service number
...
int interrupt_num
}
to
regs.eax = service number
...
intx(interrupt_num, ®s);
and we were in business.
Anyway, with these modifications, you are absolutely right,
as far as I can tell, my OS runs on the 64-bit CPU as if it
was a 32-bit CPU, on top of that, paging is enabled.
My purpose for this thread is simply to indicate to the user,
especially myself in the debug logs, that the CPU is a 64-bit
processor. With the other posts in this thread, I believe
I will be able to do that just fine.
Thanks guys,
Ben
[1] Just an interesting note, this 32-bit stack which is
at least 4 meg in size is used just fine in C code produced
by Alex's SmallerC. All I did was include some assembly
code to set up the stack and his code generation uses
this 32-bit stack just fine. Which reminds me, I need
to finish those promised modifications so that I can release
my modified version of his compiler. So much to do, so little
time to do it in...
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Forever Young Software
http://www.fysnet.net/index.htm
http://www.fysnet.net/osdesign_book_series.htm
To reply by email, please remove the zzzzzz's
Batteries not included, some Assembly required.
Back to alt.os.development | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
64-bit detection "Benjamin David Lunt" <zfysz@fysnet.net> - 2015-07-09 16:47 -0700
Re: 64-bit detection "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-07-09 23:41 -0400
Re: 64-bit detection "James Harris" <james.harris.1@gmail.com> - 2015-07-10 08:30 +0100
Re: 64-bit detection "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-07-10 05:17 -0400
Re: 64-bit detection "James Harris" <james.harris.1@gmail.com> - 2015-07-10 13:41 +0100
Re: 64-bit detection "James Harris" <james.harris.1@gmail.com> - 2015-07-12 19:04 +0100
Re: 64-bit detection "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-07-13 02:30 -0400
Re: 64-bit detection "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-07-13 02:07 -0700
Re: 64-bit detection "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-07-13 23:10 -0400
Re: 64-bit detection "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-07-14 01:23 -0700
Re: 64-bit detection "James Harris" <james.harris.1@gmail.com> - 2015-07-13 12:34 +0100
Re: 64-bit detection "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-07-13 22:50 -0400
Re: 64-bit detection "James Harris" <james.harris.1@gmail.com> - 2015-07-14 08:37 +0100
Re: 64-bit detection "Alexei A. Frounze" <alexfrunews@gmail.com> - 2015-07-14 01:41 -0700
Re: 64-bit detection "James Harris" <james.harris.1@gmail.com> - 2015-07-14 10:04 +0100
Re: 64-bit detection "Benjamin David Lunt" <zfysz@fysnet.net> - 2015-07-10 08:44 -0700
Re: 64-bit detection "Benjamin David Lunt" <zfysz@fysnet.net> - 2015-07-10 10:52 -0700
Re: 64-bit detection "Benjamin David Lunt" <zfysz@fysnet.net> - 2015-07-10 08:38 -0700
Re: 64-bit detection "Benjamin David Lunt" <zfysz@fysnet.net> - 2015-07-10 10:58 -0700
Re: 64-bit detection CN <qmbmnp3799@pacbell.net> - 2015-07-09 23:00 -0700
Re: 64-bit detection "Benjamin David Lunt" <zfysz@fysnet.net> - 2015-07-10 08:40 -0700
Re: 64-bit detection "James Harris" <james.harris.1@gmail.com> - 2015-07-10 21:29 +0100
csiph-web