64-bit kernel not passing (char *) correctly
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: 64-bit kernel not passing (char *) correctly
Are you using your own bootloader, and if yes, how many sectors do you load into memory?
Re: 64-bit kernel not passing (char *) correctly
I am using my own boot loader but it reads the fat12 partition, so it loads the file in to memory until it reaches the end of file marker (0x0FF0).
I loads everything in to memory because I can put the string before any of the data section and everything in the data section works, but the string still doesn't work.
If i even try this is doesn't work, it doesn't ever matter about it getting passed a (char *):
I mean it is basically the same thing, but shows that its not becuase the function is getting push the wrong address.
I am in long so it has to do with me linking it wrong, or how pointers are 64bit, but I do not know why it would matter if it derefrenced the pointer.
I loads everything in to memory because I can put the string before any of the data section and everything in the data section works, but the string still doesn't work.
If i even try this is doesn't work, it doesn't ever matter about it getting passed a (char *):
Code: Select all
/** Doesnt Work **/
void write(void) {
char *c = "hello";
int i = 0;
while(c[i]) {
put(c[i++]);
}
}
/** Does Work **/
void write(void) {
char c[6] = "hello";
int i = 0;
while(c[i]) {
contVideoPut(c[i++]);
}
}
I am in long so it has to do with me linking it wrong, or how pointers are 64bit, but I do not know why it would matter if it derefrenced the pointer.
Currently Working On:
Bootloader (Stage 1) (Complete)
Bootloader (Stage 2) (Inprogress)
Bootloader (Stage 1) (Complete)
Bootloader (Stage 2) (Inprogress)
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: 64-bit kernel not passing (char *) correctly
Given that you use your own bootloader, I still suspect there's something wrong in there. The possibilities are however too many to list here, so you'll have to give us some indication of what does and what does not happen.
Given that the output binary contains the string, I suggest you get a copy of bochs with x86_64 and debugging enabled. Then when it has loaded your kernel, and when it enters your kernel you can see what is in virtual memory, physical memory, the processor state, and everything else that might be involved.
Look at memory, page tables, step through the "broken" code, so you can see what the processor actually thinks of your work, as the "printf debugging" you did can not show you all the variables.
Besides, knowing how to use Bochs' debugger is a very useful ability of itself already too
Given that the output binary contains the string, I suggest you get a copy of bochs with x86_64 and debugging enabled. Then when it has loaded your kernel, and when it enters your kernel you can see what is in virtual memory, physical memory, the processor state, and everything else that might be involved.
Look at memory, page tables, step through the "broken" code, so you can see what the processor actually thinks of your work, as the "printf debugging" you did can not show you all the variables.
Besides, knowing how to use Bochs' debugger is a very useful ability of itself already too
Re: 64-bit kernel not passing (char *) correctly
thank you Combuster, I have been trying to do this awhile and i never had bochs debugger installed like an idiot, but I installed it, and started looking at the memory and where my function was looking, and then found that I have my linker script to the wrong address.
I feel like an idiot.
Thank you to all that work with me on my stupidity.
I feel like an idiot.
Thank you to all that work with me on my stupidity.
Currently Working On:
Bootloader (Stage 1) (Complete)
Bootloader (Stage 2) (Inprogress)
Bootloader (Stage 1) (Complete)
Bootloader (Stage 2) (Inprogress)