where is the printf source for busybox?
Kim Chan
ckim at etri.re.kr
Thu Mar 13 07:46:48 EDT 2014
Hi, Dave,
Thank you for the kind explanation and I think it will help much for me.
I searched down the uClib as you told me and could locate the kernel sys_write function.
In my case, the arch is sparc, and it is defined in fs/read_write.c as you said(in linux kernel source).
I've checked that
SYSCALL_DEFINE3(write, unsigned int, fd, const char __user *, buf, size_t, count)
is expanded to
=> asmlinkage long sys_write(unsigned int fd, const char __user * buf, size_t count)
and I was able to use prom_printf (write to uart) to print what I tried to print in busybox with printf.
Now I can see busybox printf at least through the uart port though it's not yet shown on the LCD(which I'm trying to map to tty1 and the shell).
Thank you!
Chan
________________________________
From : "Dave Hylands" <dhylands at gmail.com>
Sent : 2014-03-13 02:54:40 ( +09:00 )
To : Kim Chan <ckim at etri.re.kr>
Cc : Mohan L <l.mohanphy at gmail.com>, kernelnewbies at kernelnewbies.org <kernelnewbies at kernelnewbies.org>
Subject : Re: where is the printf source for busybox?
Hi,
On Tue, Mar 11, 2014 at 11:55 PM, Kim Chan <ckim at etri.re.kr<mailto:ckim at etri.re.kr>> wrote:
Wow, that was it. I'm happy to hear that because I thought it should end up with a system call anyway.
Then isn't there some codes making the system call? Or is it that the compiler understands that 'write' is a system call and inserts the assembly code for calling it by itself?
In uclibc, the write source code is found here:
http://git.uclibc.org/uClibc/tree/libc/sysdeps/linux/common/write.c
How the syscall is actually implemented is architecture specific, and will be in one of the directories here:
http://git.uclibc.org/uClibc/tree/libc/sysdeps/linux
For example, for ARM, with EABI, then I believe that it winds up here:
http://git.uclibc.org/uClibc/tree/libc/sysdeps/linux/arm/syscall-eabi.S
The SWI instruction transfers control to the kernel.
On the kernel side, how the syscalls get handled is also architecture specific, but it will generally wind up at a function called sys_FUNCTION, however the generation of the function name is usually hidden behind a macro.
So sys_write in the kernel winds up being declared here:
http://lxr.linux.no/#linux+v3.13.5/fs/read_write.c#L514
--
Dave Hylands
Shuswap, BC, Canada
http://www.davehylands.com<http://www.davehylands.com/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20140313/33486b99/attachment.html
More information about the Kernelnewbies
mailing list