作者:彭东林

邮箱:pengdonglin137@163.com

开发板:tiny4412ADK+S700 4GB Flash

主机:Wind7 64位

虚拟机:Vmware+Ubuntu12_04

u-boot:U-Boot 2010.12

Linux内核版本:linux-3.0.31

Android版本:android-4.1.2

内核自解压时期的串口打印

在zImage格式的内核启动时会自解压内核,此时打印信息如下:

Uncompressing Linux...

这句话是在arch/arm/boot/compressed/misc.c中:

void decompress_kernel(unsigned long output_start, unsigned long free_mem_ptr_p, unsigned long free_mem_ptr_end_p, int arch_id)
{
……
putstr("Uncompressing Linux...");
……
}
static void putstr(const char *ptr)
{
char c; while ((c = *ptr++) != '\0') {
if (c == '\n')
putc('\r');
putc(c); // 根据APCS规则,c中的值会传给寄存器r0
} flush();
}

在arch/arm/boot/compressed/.misc.o.cmd中列出了编译misc.c需要依赖那些文件,其中

deps_arch/arm/boot/compressed/misc.o := \
...
arch/arm/mach-exynos/include/mach/uncompress.h \
...
arch/arm/plat-samsung/include/plat/uncompress.h \
...

在misc.c中有#include <mach/uncompress.h> 指的就是 arch/arm/mach-exynos/include/mach/uncompress.h

在mach/uncompress.h中有:#include <plat/uncompress.h>,指的就是:

arch/arm/plat-samsung/include/plat/uncompress.h

在arch/arm/plat-samsung/include/plat/uncompress.h中有putc的实现:

static void putc(int ch)
{
if (uart_rd(S3C2410_UFCON) & S3C2410_UFCON_FIFOMODE) {
int level; while () {
level = uart_rd(S3C2410_UFSTAT);
level &= fifo_mask; if (level < fifo_max)
break;
}
} else {
/* not using fifos */
while ((uart_rd(S3C2410_UTRSTAT) & S3C2410_UTRSTAT_TXE) != S3C2410_UTRSTAT_TXE)
barrier();
} /* write byte to transmission register */
uart_wr(S3C2410_UTXH, ch);
}

下面我们看一下uart_rd和uart_wr的实现

static __inline__ void
uart_wr(unsigned int reg, unsigned int val)
{
volatile unsigned int *ptr;
ptr = (volatile unsigned int *)(reg + uart_base);
*ptr = val;
} static __inline__ unsigned int
uart_rd(unsigned int reg)
{
volatile unsigned int *ptr;
ptr = (volatile unsigned int *)(reg + uart_base);
return *ptr;
}

可以看到,使用的是内联函数,并且直接操作的是底层的寄存器,那么到底操作的是哪个uart呢?我们知道,tiny4412有两个可以直接使用的串口,分别对应的是uart0和uart3。想知道这个问题,就需要看uart_base这个变量是什么值?

还是在这个文件中:

#define uart_base S3C_PA_UART + (S3C_UART_OFFSET * CONFIG_S3C_LOWLEVEL_UART_PORT)

其中S3C_PA_UART是uart控制器的基地址0x13800000,exynos4412一共有5个uart,每个uart占S3C_UART_OFFSET (0x10000)个字节,还有一个关键的宏CONFIG_S3C_LOWLEVEL_UART_PORT,它就指定了使用哪一个uart,这个宏可以在make menuconfig的时候配置,这里我们设置的是

CONFIG_S3C_LOWLEVEL_UART_PORT=0

tiny4412 串口驱动分析三 --- log打印的几个阶段之内核自解压的更多相关文章

  1. tiny4412 串口驱动分析七 --- log打印的几个阶段之内核启动阶段(earlyprintk)

    作者:彭东林 邮箱:pengdonglin137@163.com 开发板:tiny4412ADK+S700 4GB Flash 主机:Wind7 64位 虚拟机:Vmware+Ubuntu12_04 ...

  2. tiny4412 串口驱动分析八 --- log打印的几个阶段之内核启动阶段(printk tiny4412串口驱动的注册)

    作者:彭东林 邮箱:pengdonglin137@163.com 开发板:tiny4412ADK+S700 4GB Flash 主机:Wind7 64位 虚拟机:Vmware+Ubuntu12_04 ...

  3. tiny4412 串口驱动分析四 --- 修改默认的串口输出

    作者:彭东林 邮箱:pengdonglin137@163.com 开发板:tiny4412ADK+S700 4GB Flash 主机:Wind7 64位 虚拟机:Vmware+Ubuntu12_04 ...

  4. tiny4412 串口驱动分析一 --- u-boot中的串口驱动

    作者:彭东林 邮箱:pengdonglin137@163.com 开发板:tiny4412ADK+S700 4GB Flash 主机:Wind7 64位 虚拟机:Vmware+Ubuntu12_04 ...

  5. tiny4412 串口驱动分析二 --- printk的实现

    作者:彭东林 邮箱:pengdonglin137@163.com 开发板:tiny4412ADK+S700 4GB Flash 主机:Wind7 64位 虚拟机:Vmware+Ubuntu12_04 ...

  6. tiny4412 串口驱动分析五 --- LDD3上TTY驱动程序源码

    关于tty这部分请参考: <Linux设备驱动开发详解 第二版>第14章 Linux终端设备驱动 <精通Linux设备驱动程序开发>第6章 串行设备驱动程序 <Linux ...

  7. tiny4412 串口驱动分析六 --- TTY驱动架构

    转载: http://www.linuxidc.com/Linux/2013-11/92639.htm 参考: http://blog.csdn.net/lamdoc/article/details/ ...

  8. tiny4412 串口驱动分析九 --- shell终端

    作者:彭东林 邮箱:pengdonglin137@163.com 开发板:tiny4412ADK+S700 4GB Flash 主机:Wind7 64位 虚拟机:Vmware+Ubuntu12_04 ...

  9. linux串口驱动分析

    linux串口驱动分析 硬件资源及描写叙述 s3c2440A 通用异步接收器和发送器(UART)提供了三个独立的异步串行 I/O(SIO)port,每一个port都能够在中断模式或 DMA 模式下操作 ...

随机推荐

  1. iOS runLoop 理解

    目录 概述 run loop modes 一.概述 run loop叫事件处理循环,就是循环地接受各种各样的事件.run loop是oc用来管理线程里异步事件的工具.一个线程通过run loop可以监 ...

  2. BZOJ4001 [TJOI2015]概率论 【生成函数】

    题目链接 BZOJ4001 题解 Miskcoo 太神了,orz #include<algorithm> #include<iostream> #include<cstr ...

  3. 2016"百度之星" - 初赛(Astar Round2A)HDU 5695 拓扑排序+优先队列

    Gym Class Time Limit: 6000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total S ...

  4. github的使用简易教程

    一.安装git https://git-for-windows.github.io/ git  ->  git bash 二.配置参数 $ git config --global user.na ...

  5. POJ3207 Ikki's Story IV – Panda's Trick

    Time Limit: 1000MS   Memory Limit: 131072K Total Submissions: 9426   Accepted: 3465 Description liym ...

  6. 汕头市队赛 SRM 09 C 撕书

    C 撕书III-3 SRM 09 背景&&描述 琉璃双在撕书.     书总共有n页,每页都可以看作是一个数字.     琉璃读书喜欢来回地读.但他也因此发现了作者的灌水行为:有些连续 ...

  7. 渗透协作工具 dradis centos安装

    https://dradisframework.com/ce/documentation/install_centos.html yum install rubygems 安装的bundle在drad ...

  8. Android控件点击事件

    1. 介绍 本文介绍了Android控件的点击事件 Android控件点击(onClick)事件可以用如下三种方式来实现 2. 实现onClick方法 在layout的xml中指定onClick方法, ...

  9. how to configure team on liunx(RHEL7.x/Centos7.x)

    #install team sofeware yum install teamd -y #check team configuration nmcli con show #Next we create ...

  10. flume 使用

    基本操作: 编写配置文件: # 指定Agent的组件名称 a1.sources = r1 a1.sinks = k1 a1.channels = c1 # 指定Flume source(要监听的路径) ...