Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Memory Detection w/o BIOS call

41 views
Skip to first unread message

Sergio Carvalho

unread,
Sep 21, 2003, 9:13:31 PM9/21/03
to
Hi,

How do i detect the amoung of main memory w/o calling the BIOS.

Thanks
Sergio Carvalho


cr88192

unread,
Sep 21, 2003, 9:42:06 PM9/21/03
to
Sergio Carvalho wrote:

> Hi,
>
> How do i detect the amoung of main memory w/o calling the BIOS.
>

I think I did something like writing values into memory at regular
intervals (eg: once per MB), and noting when the values stop "sticking"...

--
<cr88192 at hotmail dot com>
<http://bgb-sys.sourceforge.net>
<http://sourceforge.net/projects/bgb-sys/>

mr. xsism

unread,
Sep 22, 2003, 2:30:10 AM9/22/03
to
> I think I did something like writing values into memory at regular
> intervals (eg: once per MB), and noting when the values stop "sticking"...
yeah. ie-
loop while memory!='TeSt'
{
memory = 'TeSt'
memory+=1MB
count+=1MB
}

memory is a pointer. I would start it at 2MB.Thus count should start at 2MB
not 0. this is not the best way to detect memory as you could interfere with
ROM or other extended memory.

Regards,
mr. xsism


Richard Hayden

unread,
Sep 22, 2003, 6:22:45 AM9/22/03
to
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

"cr88192" <cr8...@NOSPAM.hotmail.com> wrote in message
news:vmskqmk...@corp.supernews.com...

This is a highly discouraged method of detecting available memory for many
reasons, see http://my.execpc.com/~geezer/osd/gotchas/index.htm#memsize for
more details.

- --

Richard Hayden (rahayden...@yahoo.co.uk)
Webmaster: http://www.dx-dev.com
DXOS (My Operating System): http://www.dx-dev.com/dxos

"I contend that we are both atheists. I just believe in one fewer god than
you do. When you understand why you dismiss all the other possible gods,
you will understand why I dismiss yours."
- -Stephen Roberts

-----BEGIN PGP SIGNATURE-----
Version: 6.5.8ckt http://www.ipgpp.com/
Comment: KeyID: 0x779D0625
Comment: Fingerprint: 5642 852D 88BD BD0B 1A88 94B0 BFD2 C47C 779D 0625

iQA/AwUBP27Nb7/SxHx3nQYlEQI0PgCfbVFgV6ewHZoC+4/vu3Ysjlq+Ts0AoPND
pQEqBMG4FN53Kx0TIA+YKGuC
=7TXQ
-----END PGP SIGNATURE-----


Richard Hayden

unread,
Sep 22, 2003, 6:24:27 AM9/22/03
to
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

"Sergio Carvalho" <sergio....@netvisao.pt> wrote in message
news:newscache$2ocllh$5ij$1...@newsfront4.netvisao.pt...

I don't think there is really a reliable way to detect the amount of
extended memory without using the BIOS functions. What is the problem with
using BIOS functions? Surely, you can just do it before your O/S enters
protected mode.

Regards,

- --

Richard Hayden (rahayden...@yahoo.co.uk)
Webmaster: http://www.dx-dev.com
DXOS (My Operating System): http://www.dx-dev.com/dxos

"I contend that we are both atheists. I just believe in one fewer god than
you do. When you understand why you dismiss all the other possible gods,
you will understand why I dismiss yours."
- -Stephen Roberts

-----BEGIN PGP SIGNATURE-----
Version: 6.5.8ckt http://www.ipgpp.com/
Comment: KeyID: 0x779D0625
Comment: Fingerprint: 5642 852D 88BD BD0B 1A88 94B0 BFD2 C47C 779D 0625

iQA/AwUBP27N2L/SxHx3nQYlEQLpGgCgy8Ddw/AmiI4qqQIpm2IA9ArI0Q8An0Tm
aPwz2a4Wm4GcvUKOpQ09yzbb
=cf0N
-----END PGP SIGNATURE-----


cr88192

unread,
Sep 22, 2003, 5:02:58 PM9/22/03
to
Richard Hayden wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> "cr88192" <cr8...@NOSPAM.hotmail.com> wrote in message
> news:vmskqmk...@corp.supernews.com...
>> Sergio Carvalho wrote:
>>
>> > Hi,
>> >
>> > How do i detect the amoung of main memory w/o calling the BIOS.
>> >
>> I think I did something like writing values into memory at regular
>> intervals (eg: once per MB), and noting when the values stop
>> "sticking"...
>>
>> --
>> <cr88192 at hotmail dot com>
>> <http://bgb-sys.sourceforge.net>
>> <http://sourceforge.net/projects/bgb-sys/>
>>
>
> This is a highly discouraged method of detecting available memory for many
> reasons, see http://my.execpc.com/~geezer/osd/gotchas/index.htm#memsize
> for more details.
>

in my experience it has worked, and the person was asking about doing it
w/o bios...

the probe code in my case was written in assembler, and my teqnique for
enabling the a20 has worked on the various computers I have tested my os
on...

so I think, good enough for now. it is not like I am making an os others
will use anyways...

I have crap to do now though.

cr88192

unread,
Sep 22, 2003, 5:51:47 PM9/22/03
to

"mr. xsism" <monkeyk...@hotmail.com> wrote in message
news:YHwbb.1200$gi2.551@fed1read01...
yes, in my case it worked so I used it.
otherwise I would have to call the bios...

it could be possible to call the bios in my second stage loader. my kernel
does not care that much how the memory is counted (it is currently just a
small fragment of assembler that runs when the kernel starts...).
actually, my second stage loader is also where I keep my real mode vesa
stuff, and the code to jump temporarily into real mode to call vbe
functions...
my test computer has a newer vbe version so I can probably use lfb, which
could cut down the number of jumps into real mode a bit...

I am thinking I may have to set up a version of gcc for cross compilation.
for now I am too stuck to windows...

cr88192

unread,
Sep 22, 2003, 6:44:21 PM9/22/03
to
>
> I am thinking I may have to set up a version of gcc for cross compilation.
> for now I am too stuck to windows...
>
I discover objcopy. this is looking somewhat convinient...

next step: creating working boot disks on windows...

there is a minor difference between linux and windows wrt source though:
in linux there are no underscores but there are in windows;
I might have to build slightly different source for linux and windows or
something.

an easy approach would be to make use of macros or defines to rename calls
in c, eg:

_inportb:
in the asm, and for linux a define:
#define inportb(p) _inportb(p)
in the headers or something...

Mark & Candice White

unread,
Sep 23, 2003, 1:02:57 PM9/23/03
to
cr88192 wrote:

Geezer recomends:
If your GCC supports it, leading underscores can be turned off with the
compiler option -fno-leading-underscore

OR
Assembly-language macros EXP and IMP, to interface asm code to C with or
without DOS/Windows/COFF underscores:
Using as
.ifdef UNDERBARS

.macro EXP sym
.GLOBAL _\sym
_\sym:
\sym:
.endm
.macro IMP sym
.EXTERN _\sym
.EQU \sym,_\sym
.endm

.else

.macro EXP sym
.GLOBAL \sym
\sym:
.endm
.macro IMP sym
.EXTERN \sym
.endm

.endif

Using NASM
%ifdef UNDERBARS

%macro EXP 1
GLOBAL $_%1
$_%1:
$%1:
%endmacro
%macro IMP 1
EXTERN $_%1
%define %1 $_%1
%endmacro

%else

%macro EXP 1
GLOBAL $%1
$%1:
%endmacro
%macro IMP 1
EXTERN $%1
%endmacro

%endif

If the assembly-language code is meant for use with DOS, Windows, or a
compiler that produces COFF output, use the leading underscores:

nasm -dUNDERBARS=1 ...
as --defsym UNDERBARS=1 ...

ELF systems (e.g. Linux) do not require leading underscores.


Hope this helps.
----------------
Mark & Candice White


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----

mrugesh gajjar

unread,
Sep 25, 2003, 5:08:43 AM9/25/03
to
"Sergio Carvalho" <sergio....@netvisao.pt> wrote in message news:<newscache$2ocllh$5ij$1...@newsfront4.netvisao.pt>...
Write some specific value (e.g. AA) to each byte and then read it. If
you get the value just written then its RAM. do that until you dont
get different value.

(obviously u have to switch to protected mode or after swithcing to
pmode enable A20 and then get back to real mode)

I have done this. Start from address (10000H=1MB).
This has a flaw ofcourse, if your extended RAM is not mapped just
above 1MB then could be problem!
but i tried on so much machines but i found that it works, i think
there is some mechanism that automatically maps new RAM above 1MB in
contigious fashion.

-Mrugesh
PS: I am assuming PC (x86) architecture.

cr88192

unread,
Sep 24, 2003, 11:03:30 PM9/24/03
to

"Mark & Candice White" <mhe...@britsys.net> wrote in message
news:3f707...@corp.newsgroups.com...

> cr88192 wrote:
>
> >>
> >> I am thinking I may have to set up a version of gcc for cross
> >> compilation. for now I am too stuck to windows...
> >>
> > I discover objcopy. this is looking somewhat convinient...
> >
> > next step: creating working boot disks on windows...
> >
> > there is a minor difference between linux and windows wrt source though:
> > in linux there are no underscores but there are in windows;
> > I might have to build slightly different source for linux and windows or
> > something.
> >
> > an easy approach would be to make use of macros or defines to rename
calls
> > in c, eg:
> >
> > _inportb:
> > in the asm, and for linux a define:
> > #define inportb(p) _inportb(p)
> > in the headers or something...
>
> Geezer recomends:
> If your GCC supports it, leading underscores can be turned off with the
> compiler option -fno-leading-underscore
>
yes, cool.
couldn't respond because net was down most of the day and the ethernet cable
to the other connection apparently got crushed in the file cabinet by my dad
or something (and thus now doesn't work...).

these are cool options, of course I have allready modified my assembler
files to include the underscore and it would be work to go and change them
again...

I am now working on implementing user side processes. basically I kept
threads, but modified them a little to allow them to be grouped into
processes and change page tables and such (need to optimize a little, they
should generally not swap the page tables if the new ones would be the same
as the old ones...).

I am beating together basic syscall functionality and stuff. this and a
loader and maybe I will be able to test with a few basic apps...
as of right now I am unsure how to approach fork, so this may be a little
later...

0 new messages