os-tutorial icon indicating copy to clipboard operation
os-tutorial copied to clipboard

16-video-driver can't pass string

Open ghost opened this issue 7 years ago • 10 comments

When I pass a string to kprint or kprint_at it always points to null. I have to first declare the string as an array, and then pass it. Why is this happening? I copied/pasted the code.

char msg[] = "test";
kprint_at(msg, 1, 2);

the above works but the below does not

kprint_at("test", 1, 2);

ghost avatar Jan 21 '18 21:01 ghost

I'm having a problem where no matter what string i put in the function, i get one single asterisks where the string should start. Also when I use clear_screen() I have a green box on top about 5 or 6 spaces in. Did you ever have that problem? Any ideas on how to solve it?

Vortex1134 avatar Aug 17 '18 13:08 Vortex1134

I fixed my one problem but now I have the same issue that you do. Have you ever got it fixed?

Vortex1134 avatar Aug 18 '18 07:08 Vortex1134

Check the value of dh that indicates the number of sectors to be loaded to the memory. The bytes loaded are equal to number of sectors times 512 bytes/sector. You'd better check the size of kernel image and change that value properly.

TravorLZH avatar Aug 20 '18 13:08 TravorLZH

That's probably how to fix it because its probably glitching because not enough disk was read

Menotdan avatar Nov 22 '18 02:11 Menotdan

Guys, I have the same problem on a Windows 10, does anybody knows why this happens or have a solution? Amazing tutorial anyway!!

caioaletroca avatar Dec 31 '19 01:12 caioaletroca

Dear Caio,

I guess this problem is not anything OS-specific, and I believe my previous response will help you solve it.

BTW, Happy new year!

Travor Liu


From: Caio Alexandre Troti Caetano [email protected] Sent: Tuesday, December 31, 2019 9:24:39 AM To: cfenollosa/os-tutorial [email protected] Cc: Travor Liu [email protected]; Comment [email protected] Subject: Re: [cfenollosa/os-tutorial] 16-video-driver can't pass string (#31)

Guys, I have the same problem on a Windows 10, does anybody knows why this happens or have a solution? Amazing tutorial anyway!!

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/cfenollosa/os-tutorial/issues/31?email_source=notifications&email_token=AF5X74KRYPRIJXGVDIOEBLDQ3KNNPA5CNFSM4EMX3ZKKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEH3R7RI#issuecomment-569843653, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AF5X74PLTGHJZMNLVR5DKQDQ3KNNPANCNFSM4EMX3ZKA.

TravorLZH avatar Dec 31 '19 17:12 TravorLZH

No, actually the problems doesn't was about the loaded sectors. It seems the GCC in windows (dunno if it happens in others systems) when using this environment provided by the tutorial, doesn't have ideia where to put global constants.

Using the knowledge acquired with this tutorial I followed the tutorial from os-dev to Grub Multiboot, and with a linker.ld file with .rodata section solved the problem. Link here

The .rodata section defines global constants (read-only), which we used in inline char arrays:

kprint_at("test", 1, 2);

Awesome tutorial, and Happy New Year!!! :D

caioaletroca avatar Dec 31 '19 19:12 caioaletroca

Hey guys, I had the same problem, and @caioaletroca is right. I wasn't using a cross-compiler, so my GCC was generating code for x84_64 architecture and elf64 format. So, our new operating system didn't know where was the literal string. Now, I am using a cross-compiler (i686-elf-gcc, i686-elf-ld) to generate code in elf32 format and i386 architecture, and it's working. I recommend this link: Why do I need a cross-compiler?

jorge-correia avatar Jan 03 '20 17:01 jorge-correia

Check the value of dh that indicates the number of sectors to be loaded to the memory. The bytes loaded are equal to number of sectors times 512 bytes/sector. You'd better check the size of kernel image and change that value properly.

which is the right answer , the size of 'os-image.bin' in my device is 5144bytes, change $dh in bootsect.asm from 2 to 13 will fix the problem

purplewall1206 avatar Sep 18 '20 07:09 purplewall1206

I fixed my one problem but now I have the same issue that you do. Have you ever got it fixed?

how did u fix the problem pls ?

NOcturnais avatar Nov 15 '20 18:11 NOcturnais