Re: how to direct prink output to uart in init/main.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



loody wrote:
>> I think you will need to write a small uart handling routine from scratch
>> (if this is new arch) in order to send the chars to the serial line.
>>
> Hi:
> thanks for your kind help.
> The location I want the printk works is at init/main.c and I am not
> sure the kernel serial driver is ready to use at so early time, since

You are right, kernel serial subsystem and corresponding serial
device will probably be not ready so early. The whole 'early serial
line working' employs only dumping ascii characters to the serial
TX register.

> I saw the document/serial_port.txt explains that to enable serial
> driver we need to create dev/ttySx.

No need for /dev/ttySx for your case.. Just use serial hardware to
directly output the char to he line.

Here is a quick example for cris architecture, 
linux-2.6.26/arch/cris/arch-v10/boot/compressed/misc.c, without
uneeded ifdefs for clarity:

/* decompressor info and error messages to serial console */
static int puts(const char *s)
{
        int cnt = 0;
        while (*s) {
                while (!(*R_SERIAL0_STATUS & (1 << 5))) ;
                *R_SERIAL0_TR_DATA = *s++;
                cnt++;
        }
        return cnt;
}

Here we wait for serial hardware to finish processing current
char in the TX register (if any) by chacking the R_SERIAL0_STATUS (status reg)
register. When not busy, write new char to the R_SERIAL0_TR_DATA (TX data reg)
register and repeat the sequence until no more chars need to be sent.

HTH,
Hinko
-- 
Hinko Kočevar, OSS developer
ČETRTA POT, d.o.o.
Planina 3, 4000 Kranj, SI EU
tel     ++386 (0) 4 280 66 03
e-mail  hinko.kocevar@xxxxxxxxxxxx
http    www.cetrtapot.si


--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux