Problems encountered in memory detection by operating system

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
benji
Posts: 22
Joined: Fri Nov 23, 2018 10:53 pm
Libera.chat IRC: os student

Problems encountered in memory detection by operating system

Post by benji »

Hi, everyone. I am a complete beginner in Operating System. I find a problem which is I found an error occurred while I refreshed memory. I found 0x502243 is not available. When I try to change the value of the address, my os will crash!!! but 0x502242 & 0x502244 is available. And I found every several KBs, there will be some memory that cannot be used. I am so confused. My virtual box is qemu. The platform is X86. the is my OS source code:https://github.com/FTOlaf/DolphinOS. I use refresh() to refresh memory. The function in memory.c. :cry:
Attachments
memory.c
(5.97 KiB) Downloaded 60 times
MichaelPetch
Member
Member
Posts: 799
Joined: Fri Aug 26, 2016 1:41 pm
Libera.chat IRC: mpetch

Re: Problems encountered in memory detection by operating sy

Post by MichaelPetch »

I don't see the code in your file that is allegedly crashing.There is a bunch of stuff commented out but that's about it.You seem to have a lot of peculiar things in your makefile. I question your use of -shared . The way you are building things would probably not work well with that option. In types.h you use #define and terminate it with a semicolon. That is a problem. You seem to use typedefs for something and not others. In idt.c you have the function

Code: Select all

void set_idt_gatedesc(IDT_Gate_Descriptor *gd, uint32_t offset, uint32_t selector, uint32_t ar, uint8_t privilege)
but then call it with fewer parameters like:

Code: Select all

set_idt_gatedesc(idt + i, 0, 0, 0);
.
Your makefile has explicit rules for object files in the wrong directory so it defaults to the builtin make rules for compiling/assembling those files to objects.
You really should be compiling with -ffreestanding .
I think if your compiler is throwing warnings you should not ignore them.
benji
Posts: 22
Joined: Fri Nov 23, 2018 10:53 pm
Libera.chat IRC: os student

Re: Problems encountered in memory detection by operating sy

Post by benji »

MichaelPetch wrote:I don't see the code in your file that is allegedly crashing.There is a bunch of stuff commented out but that's about it.You seem to have a lot of peculiar things in your makefile. I question your use of -shared . The way you are building things would probably not work well with that option. In types.h you use #define and terminate it with a semicolon. That is a problem. You seem to use typedefs for something and not others. In idt.c you have the function

Code: Select all

void set_idt_gatedesc(IDT_Gate_Descriptor *gd, uint32_t offset, uint32_t selector, uint32_t ar, uint8_t privilege)
but then call it with fewer parameters like:

Code: Select all

set_idt_gatedesc(idt + i, 0, 0, 0);
.
Your makefile has explicit rules for object files in the wrong directory so it defaults to the builtin make rules for compiling/assembling those files to objects.
You really should be compiling with -ffreestanding .
I think if your compiler is throwing warnings you should not ignore them.
Thank you very much, I had found this problem which is the paging isn't installed correctly. You give me a very good suggestion which is considered the warning of the compiler. But, it is difficult to correct all warnings.
mallard
Member
Member
Posts: 280
Joined: Tue May 13, 2014 3:02 am
Location: Private, UK

Re: Problems encountered in memory detection by operating sy

Post by mallard »

benji wrote:But, it is difficult to correct all warnings.
It really isn't and it'll save you a lot of headaches in the long run. I compile pretty much all my programming projects (including my OS) with all warnings enabled and "warnings are errors" ("-Wall -Wextra -Werror" for GCC). If you're competent enough in the language to build a working OS, you're competent enough to write code that compiles without warnings.
Image
benji
Posts: 22
Joined: Fri Nov 23, 2018 10:53 pm
Libera.chat IRC: os student

Re: Problems encountered in memory detection by operating sy

Post by benji »

mallard wrote:
benji wrote:But, it is difficult to correct all warnings.
It really isn't and it'll save you a lot of headaches in the long run. I compile pretty much all my programming projects (including my OS) with all warnings enabled and "warnings are errors" ("-Wall -Wextra -Werror" for GCC). If you're competent enough in the language to build a working OS, you're competent enough to write code that compiles without warnings.
Yes, I think so. But I afraid I haven't enough ability to solve those problems. I need to train myself first. I very appreciate you give this advice!
no92
Member
Member
Posts: 307
Joined: Wed Oct 30, 2013 1:57 pm
Libera.chat IRC: no92
Location: Germany
Contact:

Re: Problems encountered in memory detection by operating sy

Post by no92 »

mallard wrote:(...)I compile pretty much all my programming projects (including my OS) with all warnings enabled and "warnings are errors" ("-Wall -Wextra -Werror" for GCC).
Unrelated and minor, but "-Wall -Wextra" does not enable all warnings (to pick one example, I find -Wshadow quite useful but not enabled by this). For a comprehensive list, see the GCC documentation.

Source: the list of warning options I use is longer than I'd like to admit.
Post Reply