OSDev.org

The Place to Start for Operating System Developers
It is currently Mon Apr 15, 2024 9:25 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Unclear in what mode I work and how to use uint64_t
PostPosted: Thu Dec 19, 2019 10:40 am 
Offline
Member
Member
User avatar

Joined: Sun Jul 21, 2019 7:34 am
Posts: 300
I'm using GRUB to boot and expect it to boot me into protected mode, but it looks like it's booting me into long mode.

I ran my operating system on a virtual machine with 5120 megabytes of RAM and got this output:

THIS INT32 OUTPUT SECTION
ram_available = 1073282048 bytes
ram_available = 1023 MB
THIS UINT32 OUTPUT SECTION
ram_available = 1073282048 bytes
ram_available = 1023 MB

It is obvious that I get such numbers because of variable overflow, but I expected to see 4 GB because in protected mode it is no longer available. In the end, you can see that all 5 GB are indexed but they are not impossible to remove.
I tried using uint64_t to implement the char* itoaUINT64(uint64_t value, char* result, int base); function, but got a compilation error: Undefined reference to '__divdi3'.

-static-libgcc -lgcc not help.

Source code here
gcc args here in string №73
itoaUINT64() here

How do I solve this problem?


Top
 Profile  
 
 Post subject: Re: Unclear in what mode I work and how to use uint64_t
PostPosted: Thu Dec 19, 2019 11:31 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5134
mrjbom wrote:
It is obvious that I get such numbers because of variable overflow, but I expected to see 4 GB because in protected mode it is no longer available.

If you use PAE, you can access all memory even in protected mode.

mrjbom wrote:
I tried using uint64_t but got a compilation error: Undefined reference to '__divdi3'.

All code compiled with GCC must be linked with libgcc. You can do that by changing line 94 to use GCC instead of LD for linking, and adding "-lgcc" to the command line after your object files. (You may also need to add ./i386-elf-4.9.1-Linux-x86_64/bin/ to your $PATH.)


Top
 Profile  
 
 Post subject: Re: Unclear in what mode I work and how to use uint64_t
PostPosted: Thu Dec 19, 2019 1:56 pm 
Offline
Member
Member
User avatar

Joined: Sun Oct 18, 2009 5:47 pm
Posts: 208
Location: Alexandria, Egypt | Ottawa, Canada
mrjbom wrote:
-static-libgcc -lgcc not help.

Because in your build_all_crosscompile.sh, you added '-lgcc' to your compiler command line, not the linker...


Top
 Profile  
 
 Post subject: Re: Unclear in what mode I work and how to use uint64_t
PostPosted: Thu Dec 19, 2019 5:55 pm 
Offline
Member
Member
User avatar

Joined: Sun Jul 21, 2019 7:34 am
Posts: 300
Octocontrabass wrote:
mrjbom wrote:
It is obvious that I get such numbers because of variable overflow, but I expected to see 4 GB because in protected mode it is no longer available.

If you use PAE, you can access all memory even in protected mode.

mrjbom wrote:
I tried using uint64_t but got a compilation error: Undefined reference to '__divdi3'.

All code compiled with GCC must be linked with libgcc. You can do that by changing line 94 to use GCC instead of LD for linking, and adding "-lgcc" to the command line after your object files. (You may also need to add ./i386-elf-4.9.1-Linux-x86_64/bin/ to your $PATH.)


Thanks.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Majestic-12 [Bot] and 244 guests


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group