String relocation PIO? Data address is execution dependant?
Posted: Tue Jun 24, 2014 8:14 am
First forgive me if my english is not perfect(it is not my native language)
If you don't understand something feel free to ask me.
I have again a problem during my OS development.
I have very basic code which switch to protected mode and read the hdd with PIO.
But when i try to execute it inside virtualbox it crashes( "guru meditation").
This is a voluntary crach( due to jmp 0x0) which i used as a perror().
The real problem is this one :
I have a constant string : char *mystring="blabla" inside a C function. let's call this piece of code "truekern code".
I compiled it and made my OS binary.
Once the firsts sectors are loaded, I use PIO to load this "truekern code" and so I'm loading the string into RAM.
then i locate where this string is(I do it findString() function which can be found in kern/kernel.c see below) and, after, I run "truekern code" which check if the address of the string is the address found previously by findString and this is often not the case(but sometimes it is. it seems to be random)
I simplified my code but I implemented a printf function and it seems the address found by my function findString() is not always the same at each execution.
I think my findString() is ok because i have done some others tests to check it so it is maybe a PIO bug ? maybe a virrtualbox emulated PIO?my code is for LBA28. maybe a compatibility error with LBA48?
----------------------------------------------------------------
VM configuration :
RAM : 1122 Mo
VT-x/AMD-V enabled
video memory : 16Mo
--
Host configuration:
NASM version 2.10.09 compiled on Dec 29 2013
gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1)
GNU ld (GNU Binutils for Ubuntu) 2.24
--
how i build it.
I just run Makefile in the root directory.
but each folder doens't depend on others folders.
> in boot/ folder i have a asm code to switch to protected mode and load some hdd sectors into RAM by running 0x10 BIOS interrupt. these sectors contains the code compiled in kern/ folder
> in kern/ folder i'm changing GDT and load other hdd sectors with PIO
these sectors contains the code compiled in the truekern/ folder and is mapped after ther 1Mo limit of real mode.
I also search where a string is located(this string is suppose to be defined in trueker/kernel.c)
> in truekern/
i'm just comparing if the address of the string found previously is the good one. and it seems it is not . actually the location of the string seems to change but i don't know why. it's probably because of PIO but why?
----------------------------------------------------------------
here are the files :
"root" Makefile : http://pastebin.com/HnCp99Cd
kern/gdt.c : http://pastebin.com/xp5WUU34
kern/gdt.h : http://pastebin.com/M3ZBM4F4
kern/io.h : http://pastebin.com/cDGzs05u
kern/kernel.c : http://pastebin.com/AAXuM1gT
kern/Makefile : http://pastebin.com/kkVTPSqk
kern/types.h : http://pastebin.com/XyG2Vcx9
truekern/funcTable.h : http://pastebin.com/50NAWkSk
truekern/kernel.c : http://pastebin.com/G2bT3MEc
truekern/lib.c : http://pastebin.com/EGWDX3xQ
truekern/lib.h : http://pastebin.com/2mspiweC
truekern/Makefile : http://pastebin.com/8evasLt1
truekern/overhead.c : http://pastebin.com/zTjk9u4S
truekern/types.h : http://pastebin.com/Qxm7FsPD
boot/bootsect.asm : http://pastebin.com/jsvCkYSU
boot/GDT.INC : http://pastebin.com/C182G2H9
boot/Makefile : http://pastebin.com/T8NiR4qc
----------------------------------------------------------
the journey begins with bootsect.asm.
bootsect.asm --jmp-> kern/kernel.c --jmp->truekern/kernel.c
the final image is /tmp/floppyA.img
I put this image on virtualbox hdd with `dd` comman (which i can use with a live cd on the vm)
if you want more information please ask me.
any help or suggestion will be helpful
thank you
If you don't understand something feel free to ask me.
I have again a problem during my OS development.
I have very basic code which switch to protected mode and read the hdd with PIO.
But when i try to execute it inside virtualbox it crashes( "guru meditation").
This is a voluntary crach( due to jmp 0x0) which i used as a perror().
The real problem is this one :
I have a constant string : char *mystring="blabla" inside a C function. let's call this piece of code "truekern code".
I compiled it and made my OS binary.
Once the firsts sectors are loaded, I use PIO to load this "truekern code" and so I'm loading the string into RAM.
then i locate where this string is(I do it findString() function which can be found in kern/kernel.c see below) and, after, I run "truekern code" which check if the address of the string is the address found previously by findString and this is often not the case(but sometimes it is. it seems to be random)
I simplified my code but I implemented a printf function and it seems the address found by my function findString() is not always the same at each execution.
I think my findString() is ok because i have done some others tests to check it so it is maybe a PIO bug ? maybe a virrtualbox emulated PIO?my code is for LBA28. maybe a compatibility error with LBA48?
----------------------------------------------------------------
VM configuration :
RAM : 1122 Mo
VT-x/AMD-V enabled
video memory : 16Mo
--
Host configuration:
NASM version 2.10.09 compiled on Dec 29 2013
gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1)
GNU ld (GNU Binutils for Ubuntu) 2.24
--
how i build it.
I just run Makefile in the root directory.
but each folder doens't depend on others folders.
> in boot/ folder i have a asm code to switch to protected mode and load some hdd sectors into RAM by running 0x10 BIOS interrupt. these sectors contains the code compiled in kern/ folder
> in kern/ folder i'm changing GDT and load other hdd sectors with PIO
these sectors contains the code compiled in the truekern/ folder and is mapped after ther 1Mo limit of real mode.
I also search where a string is located(this string is suppose to be defined in trueker/kernel.c)
> in truekern/
i'm just comparing if the address of the string found previously is the good one. and it seems it is not . actually the location of the string seems to change but i don't know why. it's probably because of PIO but why?
----------------------------------------------------------------
here are the files :
"root" Makefile : http://pastebin.com/HnCp99Cd
kern/gdt.c : http://pastebin.com/xp5WUU34
kern/gdt.h : http://pastebin.com/M3ZBM4F4
kern/io.h : http://pastebin.com/cDGzs05u
kern/kernel.c : http://pastebin.com/AAXuM1gT
kern/Makefile : http://pastebin.com/kkVTPSqk
kern/types.h : http://pastebin.com/XyG2Vcx9
truekern/funcTable.h : http://pastebin.com/50NAWkSk
truekern/kernel.c : http://pastebin.com/G2bT3MEc
truekern/lib.c : http://pastebin.com/EGWDX3xQ
truekern/lib.h : http://pastebin.com/2mspiweC
truekern/Makefile : http://pastebin.com/8evasLt1
truekern/overhead.c : http://pastebin.com/zTjk9u4S
truekern/types.h : http://pastebin.com/Qxm7FsPD
boot/bootsect.asm : http://pastebin.com/jsvCkYSU
boot/GDT.INC : http://pastebin.com/C182G2H9
boot/Makefile : http://pastebin.com/T8NiR4qc
----------------------------------------------------------
the journey begins with bootsect.asm.
bootsect.asm --jmp-> kern/kernel.c --jmp->truekern/kernel.c
the final image is /tmp/floppyA.img
I put this image on virtualbox hdd with `dd` comman (which i can use with a live cd on the vm)
if you want more information please ask me.
any help or suggestion will be helpful
thank you