How does libc (for example) print a string?
It cannot access directly to 0xB8000. Because it's executed in user mode, and it would cause a page fault. Does libc use system calls?
How to implement LibC
- AlfaOmega08
- Member
- Posts: 226
- Joined: Wed Nov 07, 2007 12:15 pm
- Location: Italy
Hi,
The printf function writes to the stdout, what normally is redirected in the parent process' stdin. When the string you want to print reaches your init process you can pass it to a screen driver. I do this over a device file. The screen driver uses a special flag for malloc() to allocate 0xB8000. So the screen driver can put your string on screen.
The printf function writes to the stdout, what normally is redirected in the parent process' stdin. When the string you want to print reaches your init process you can pass it to a screen driver. I do this over a device file. The screen driver uses a special flag for malloc() to allocate 0xB8000. So the screen driver can put your string on screen.
- piranha
- Member
- Posts: 1391
- Joined: Thu Dec 21, 2006 7:42 pm
- Location: Unknown. Momentum is pretty certain, however.
- Contact:
Well, I implemented IO channels, you can call read, write, open, close, or custom through syscalls. It then calls a handler function (in kernel mode) which does what is requested.
Channel 0 is kernel (reset, asm("hlt")), Channel 1 is Terminal (getchar, puts, clear, setXY).
-JL
Channel 0 is kernel (reset, asm("hlt")), Channel 1 is Terminal (getchar, puts, clear, setXY).
-JL
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io