Page 1 of 1
Whats wrong with my pointer?
Posted: Tue Nov 23, 2004 12:28 am
by astrocrep
In my 16bit loader, I pass the address of my struct to the stack before loading my 32bit kernel like so:
Code: Select all
runkernel ("kernel.bin", &mystruct);
Now If I
I get 100 in my 32bit kernel.
Once the 32bit kernel is up, I do:
Code: Select all
OSStruct *OSDT;
OSDT = (OSStruct *)dtptr;
Now OSStruct is a typedef struct, found in an include file common to both the loader and the kernel.
In the loader i do:
but in the kernel when i print out the contents of
Its null.
I have tried many different things, what could I be doing wrong?
Thanks,
Rich
Re:Whats wrong with my pointer?
Posted: Tue Nov 23, 2004 2:23 am
by Solar
Pff... wrong contents of segment registers, mistakes in the memory management (what's dtptr?), any number of other mistakes (what does OSStruct look like? has OSStruct.name enough space for the string you copy there? Did you pass OSDT to runkernel() correctly?).
Too little information.
Re:Whats wrong with my pointer?
Posted: Tue Nov 23, 2004 3:57 pm
by astrocrep
Ok fair enough, I tried to provide enough info before (but being generic about it) but
Code: Select all
typedef struct {
int mode;
int rX;
int rY;
int rD;
long lfb;
long VRam;
} VideoMode;
typedef struct
{
char OSLoaderName[32];
int OSLoaderVer;
long SysRam;
VideoMode vid;
} OSStruct;
In my 16bit code I want to pass the address of osstruct structure called OSDT (for operating system data table)
My runkernel command can successfuly pass parameters to the 32bit kernel because one of the other commands I pass in the address to the vesa lfb, and It works for my kernel.
my kernel takes the passed adress and assigns it to the OSDT (in the kernel) like so
Code: Select all
//dtptr is an unsigned long hopefully holding the address to the // datatable pointer
OSStruct *OSDT;
OSDT = (OSStruct *)dtptr;
In the loader the OSDT is declared like a regular struct:
Code: Select all
OSStruct OSDT;
//And values are given to its elements...
Now as far as getting the address of my struct and passing it, I've tried:
Code: Select all
runkernel("kernel.o", &OSDT);
-or-
MK_FP(_DS, &OSDT);
//where _DS = my data segment
So I am not sure what to do.
Its got me completely lost.
Thanks for the help,
Rich
Re:Whats wrong with my pointer?
Posted: Wed Nov 24, 2004 7:18 am
by Pype.Clicker
if i were you, i'd try to add a 'magic' number (0x05d7 ?) at the start of your structure and check the magic number is there ...
Imho, the easiest solution for you could be to write the OSDT at some well-defined address (something like 0:0x7B00) and then use a constant pointer to access it from the 32bits kernel.
Passing pointers between 16 bits and 32bits code almost always require an adjustment ...