Chinaunix首页 | 论坛 | 博客
  • 博客访问: 406486
  • 博文数量: 380
  • 博客积分: 75
  • 博客等级: 民兵
  • 技术积分: 1925
  • 用 户 组: 普通用户
  • 注册时间: 2011-09-05 15:35
文章分类

全部博文(380)

文章存档

2014年(1)

2013年(2)

2012年(19)

2011年(358)

我的朋友

分类:

2011-09-05 18:32:11

原文地址:内核运行之前访问IO 作者:chenxibing008

Access IO before Kernel start


如果要在内核运行之前访问CPU的某些IO端口,直接使用指针方式定义寄存器进行操作即可。例如,在解压内核的时候喂狗,通过操作IO进行,可以这样操作:
在arch/arm/boot/compressed/misc.c文件:

    307     arch_decomp_setup();
    308
    309     makecrc();
    310     *((volatile unsigned long *)0x40E00054) &= (~(3<<28)); //ABING GPAF0_L
    311     *((volatile unsigned long *)0x40E0001C) = (1<<14); //ABING GPDR0
    312     *((volatile unsigned long *)0x40E00024) = (1<<14); //ABING GPCR0
    313     putstr("Uncompressing Linux...");
    314     *((volatile unsigned long *)0x40E00018) = (1<<14); //ABING GPSR0
    315     gunzip();
    316     *((volatile unsigned long *)0x40E00024) = (1<<14); //ABING GPCR0
    317     putstr(" done, booting the kernel.\n");
    318     return output_ptr;




参考include/asm-arm/arch-pxa/uncompress.h文件访问串口的代码:
#define           ((volatile unsigned long *)0x40100000)
#define           ((volatile unsigned long *)0x40200000)
#define           ((volatile unsigned long *)0x40700000)

#define             


static  void (char )
{
        while (!([5] & 0x20));
        [0] = ;
}

/*
 * This does not append a newline
 */
static void (const char *)
{
        while (*) {
                (*);
                if (* == '\n')
                        ('\r');
                ++;
        }
}


可以这样定义:
#define __raw_readl(a)    (*(volatile unsigned int *)(a))
#define __raw_writel(v,a) (*(volatile unsigned int *)(a) = (v))
#define __raw_readw(a)    (*(volatile unsigned short *)(a))
#define __raw_writew(v,a) (*(volatile unsigned short *)(a) = (v))

阅读(256) | 评论(0) | 转发(0) |
0

上一篇:ARM9低功耗

下一篇:u-boot.lds

给主人留下些什么吧!~~