Page 1 of 1
Help with text in pmode
Posted: Wed Sep 06, 2006 6:53 pm
by dhacker14
OK i followed all instructions in the mega-tokyo.com osfaq and the osdever.net a simple c kernel, and it will not work on any of my computers it prints only 4 to 5 chars and on what i wanted my exact string, only one of the 5 of them, was "Pleaz wait booting....DONE!" it put the paragraph and pi simbly withe =. can anyone help me out.
Posted: Thu Sep 07, 2006 1:52 am
by matthias
Some code could help us help you
Posted: Thu Sep 07, 2006 2:18 am
by hailstorm
Well, at least you got something on screen!
But just like Matthias wrote, we need some more info to help you out.
Greetz.
Posted: Fri Sep 08, 2006 7:09 am
by dhacker14
here is my code:
Code: Select all
K_main()
{
k_print(0x07, “Hello Booting....Done”);
for(;;);
}
k_print(int colour, char *string)
{
char *video=(char*)0xB8000;
while(*string!=0)
{
*video=*string;
string++;
video++;
*video=colour;
video++;
}
}
Posted: Fri Sep 08, 2006 8:24 am
by hailstorm
I don't see any direct problems with your code... What does your datasegment descriptor look like?
Posted: Fri Sep 08, 2006 10:50 am
by bubach
whats up with the ” ? is that really a " ?
Posted: Fri Sep 08, 2006 11:47 am
by gaf
You did include rodata in your linker-script ?
Code: Select all
SECTIONS
{
.text 0xDEADBEEF :
{
*(.text)
*(.rodata*)
}
.data :
{
*(.data)
}
.bss :
{
*(.bss*)
*(.comment*)
}
}
cheers,
gaf
Posted: Fri Sep 08, 2006 12:29 pm
by hailstorm
@Buback: It probably compiles, so that can't be the problem (I think
)
@Gaf:
What does that extra statement do exactly?
I shall try to explain why I ask this. Since I first compiled my kernel, I was always using the following compiler option: "-fwritable-strings", to make sure that all strings were included in the data section, instead of the code section. Cause, before I did this, I passed a string and only the offset was passed to the called function. The called function however, thought that this offset was related to the data segment and the only thing I got was garbage on screen, just like dhacker14 does.
If this is resolving that problem I had, I would sure like to know more about this .rodata section...
Sorry for this long and boring story...
Posted: Fri Sep 08, 2006 1:29 pm
by gaf
The rodata section (read-only data) includes all constant global data that the executable uses. As string literals are constant by definition, they also get put into this section. If your linker-script doesn't include the rodata section, the linker can't add the strings to the binary and all strings pointers are invalid. The garbage that does get printed is just some data/code that happends to be at the wrong place at the wrong time..
If this is resolving that problem I had..
It solves 9 out of 10 problems related to string output. I actually already thought about putting it into my signature
regards,
gaf
Posted: Fri Sep 08, 2006 1:49 pm
by hailstorm
Oke, so far I get it... But what about passing strings to other routines? Since strings get included in the text section, can I be sure that the subroutines I call also assume that const char * (is this allowed?) or char * can be found in the text section / code segment?
Thanks for your answer.
Posted: Fri Sep 08, 2006 2:19 pm
by gaf
I actually assumed a flat memory model as virtually all modern operating systems use it. If you're planning to use segmention it might however indeeed by a good idea to put rodata in the regular data-section.
regards,
gaf
Posted: Fri Sep 08, 2006 3:28 pm
by hailstorm
Basically, I am not sure yet whether I use full segmentation or a flat memory model (paging only). But, since my kernel will use code segment and data segment, I need the strings to be in the data segment (just because pointers are always offsets to the dseg).
But thanks anyways, I can die happy now.
I wasn't beware of that option and you teached me.
Thnx dude!
didnt help
Posted: Fri Sep 08, 2006 7:10 pm
by dhacker14
I put in all the things i didnt have in the link.ld file, but the output was:
' }
any other ideas?
Posted: Sat Sep 09, 2006 2:56 am
by hailstorm
Well, you could try the following:
- Look at your datasegment. If you are in protected mode, make sure that the datasegment you are writing to for screen output has base 0. In real mode your code should actualy work.
- Try to put .rodata in your data section. Memory operations are always executed on ds/es. If your string is included in code section (cs), than your string can never be found in ds...
Hope this helps...