-
segmentation fault
Hi,
I'm writing a C program in Linux to display memory content of BIOS data area at segement 0040h with offset 0013h. Below is my program:
#include <stdio.h>
int *ptr;
int main(void)
{
ptr = 00400013
printf("\nContent is %d\n", *ptr);
return 0;
}
When I ran this program, I got this error "segmentation fault". Does it related to protected mode in Linux? If so, what can I do?
-
> Does it related to protected mode in Linux?
Yes - you can't point at random bits of real memory anymore
> If so, what can I do?
State what it is you are actually trying to do.
I'm not even sure if linux even bothers with the BIOS data area (as it is used from say DOS).
-
When a PC boots up, some memory areas are reserved to contain initialization data. I want to access and display information on these specific memory addresses. Any possible solution in Linux?
-
I am pretty sure you would have to write a kernel module. I don't think linux would let you do it any other way. I am going to have to ask my brother though. He'll know. He'll probably post next
-
Muhahah <posting to prove linuxdude wrong>
Why are you declaring the pointer as a global btw?
-
linux doesn't deal with BIOS data structures, like dos.
-
Well if you really want to go looking in physical memory, then start with reading
man 4 mem
Which tells you all about reading the /dev/mem file.
But like I (and others) have said, I don't think the BIOS information will be there. Sure it may write some stuff there when the machine starts, but once Linux takes over, I don't think the BIOS plays any further part, so that memory gets claimed by the OS for it's own use.
-
Salem,
Do you mean that Linux overwrites the contents of these memory areas?
-
Download the source for the kernel and find out
Write a program using /dev/mem and find out
-
Well, what the others have said, but I'd like to point out the errors in the program. When you're assigning 00400013 to the pointer, there is a problem with the base you're using.
You want to use hexadecimal number base, and you're in fact using octal. Any number that starts with a 0 is treated as octal, and the actual memory location you're accessing is way off. You'd need to use 0x00400013. Any number that starts with 0x (that's a zero, same with octal) is treated as hexadecimal.
I just thought I'd point that out.