快乐虾
http://blog.csdn.net/lights_joy/
lights@hb165.com
本文适用于
ADI bf561 DSP
uclinux-2008r1.5-rc3 (移植到vdsp5)
Visual DSP++ 5.0(update 5)
欢迎转载,但请保留作者信息
#ifdef CONFIG_EARLY_PRINTK
SP += -12;
call.x _init_early_exception_vectors;
SP += 12;
#endif
所调用的这个函数将设置EVT2-EVT15的中断向量。同时将所有的返回地址也指向同一个位置。
/*
* Set up a temporary Event Vector Table, so if something bad happens before
* the kernel is fully started, it doesn't vector off into somewhere we don't
* know
*/
asmlinkage void __init init_early_exception_vectors(void)
{
SSYNC();
/* cannot program in software:
* evt0 - emulation (jtag)
* evt1 - reset
*/
bfin_write_EVT2(early_trap);
bfin_write_EVT3(early_trap);
bfin_write_EVT5(early_trap);
bfin_write_EVT6(early_trap);
bfin_write_EVT7(early_trap);
bfin_write_EVT8(early_trap);
bfin_write_EVT9(early_trap);
bfin_write_EVT10(early_trap);
bfin_write_EVT11(early_trap);
bfin_write_EVT12(early_trap);
bfin_write_EVT13(early_trap);
bfin_write_EVT14(early_trap);
bfin_write_EVT15(early_trap);
CSYNC();
/* Set all the return from interrupt, exception, NMI to a known place
* so if we do a RETI, RETX or RETN by mistake - we go somewhere known
* Note - don't change RETS - we are in a subroutine, or
* RETE - since it might screw up if emulator is attached
*/
asm("\tRETI = %0; RETX = %0; RETN = %0;\n"
: : "p"(early_trap));
}
其中RETI为中断服务的返回地址,RETX为异常中断的返回地址,RETN为不可屏蔽中断的返回地址。
early_trap这一中断入口的定义在linux-2.6.x\arch\blackfin\mach-common\entry.S中:
ENTRY(_early_trap)
SAVE_ALL_SYS
trace_buffer_stop(p0,r0)
/* Turn caches off, to ensure we don't get double exceptions */
P4.L = LO(IMEM_CONTROL);
P4.H = HI(IMEM_CONTROL);
R5 = [P4]; /* Control Register*/
BITCLR(R5,ENICPLB_P);
CLI R1;
SSYNC; /* SSYNC required before writing to IMEM_CONTROL. */
.align 8;
[P4] = R5;
SSYNC;
P4.L = LO(DMEM_CONTROL);
P4.H = HI(DMEM_CONTROL);
R5 = [P4];
BITCLR(R5,ENDCPLB_P);
SSYNC; /* SSYNC required before writing to DMEM_CONTROL. */
.align 8;
[P4] = R5;
SSYNC;
STI R1;
r0 = sp; /* stack frame pt_regs pointer argument ==> r0 */
r1 = RETX;
SP += -12;
call.x _early_trap_c;
SP += 12;
ENDPROC(_early_trap)
这段代码功能比较简单,将寄存器入栈,关闭cache,然后调用c的函数early_trap_c,由于early_trap_c直接就panic,一旦进入这个中断入口就不会再退出,所有在这个中断服务中没有返回的指令。这里比较有意思的是调用early_trap_c时的参数传递。
early_trap_c的函数原型为:
asmlinkage void __init early_trap_c(struct pt_regs *fp, void *retaddr)
它将接受一个结构体的指针和一个返回地址作为参数。在参数传递过程中,对于少于三个参数的函数调用,使用R0来传递第一个参数,使用R1来传递第二个参数。因此在上述汇编代码中,有
r0 = sp; /* stack frame pt_regs pointer argument ==> r0 */
r1 = RETX;
那么结构体的内容来自于哪里呢?先看看pt_regs的定义:
/* this struct defines the way the registers are stored on the
stack during a system call. */
struct pt_regs {
long orig_pc;
long ipend;
long seqstat;
long rete;
long retn;
long retx;
long pc; /* PC == RETI */
long rets;
long reserved; /* Used as scratch during system calls */
long astat;
long lb1;
long lb0;
long lt1;
long lt0;
long lc1;
long lc0;
long a1w;
long a1x;
long a0w;
long a0x;
long b3;
long b2;
long b1;
long b0;
long l3;
long l2;
long l1;
long l0;
long m3;
long m2;
long m1;
long m0;
long i3;
long i2;
long i1;
long i0;
long usp;
long fp;
long p5;
long p4;
long p3;
long p2;
long p1;
long p0;
long r7;
long r6;
long r5;
long r4;
long r3;
long r2;
long r1;
long r0;
long orig_r0;
long orig_p0;
long syscfg;
};
再看看SAVE_ALL_SYS的定义:
#define SAVE_ALL_SYS save_context_no_interrupts
#define save_context_no_interrupts \
[--sp] = SYSCFG; \
[--sp] = P0; /* orig_p0 */ \
[--sp] = R0; /* orig_r0 */ \
[--sp] = ( R7:0, P5:0 ); \
[--sp] = fp; \
[--sp] = usp; \
\
[--sp] = i0; \
[--sp] = i1; \
[--sp] = i2; \
[--sp] = i3; \
\
[--sp] = m0; \
[--sp] = m1; \
[--sp] = m2; \
[--sp] = m3; \
\
[--sp] = l0; \
[--sp] = l1; \
[--sp] = l2; \
[--sp] = l3; \
\
[--sp] = b0; \
[--sp] = b1; \
[--sp] = b2; \
[--sp] = b3; \
[--sp] = a0.x; \
[--sp] = a0.w; \
[--sp] = a1.x; \
[--sp] = a1.w; \
\
[--sp] = LC0; \
[--sp] = LC1; \
[--sp] = LT0; \
[--sp] = LT1; \
[--sp] = LB0; \
[--sp] = LB1; \
\
[--sp] = ASTAT; \
\
[--sp] = r0; /* Skip reserved */ \
[--sp] = RETS; \
r0 = RETI; \
[--sp] = r0; \
[--sp] = RETX; \
[--sp] = RETN; \
[--sp] = RETE; \
[--sp] = SEQSTAT; \
[--sp] = r0; /* Skip IPEND as well. */ \
[--sp] = r0; /*orig_pc*/ \
/* Clear all L registers. */ \
r0 = 0 (x); \
l0 = r0; \
l1 = r0; \
l2 = r0; \
l3 = r0; \
//.endm
入栈顺序刚好和pt_regs结构体的成员次序相反,由于入栈操作时SP指针是向下增长的,而结构体成员的排列则是向上增长的,因此入栈操作即相当于对结构体的成员一一赋值。
最后看看early_trap_c的实现:
asmlinkage void __init early_trap_c(struct pt_regs *fp, void *retaddr)
{
/* This can happen before the uart is initialized, so initialize
* the UART now
*/
if (likely(early_console == NULL))
setup_early_printk(DEFAULT_EARLY_PORT);
dump_bfin_mem(fp);
show_regs(fp);
dump_bfin_trace_buffer();
panic("Died early");
}
输出寄存器的内容,然后panic!
head.s分析(1):保存u-boot传递过来的指针(2009-1-19)
head.s分析(2):SYSCFG配置(2009-1-19)
head.s分析(3):数据及指针寄存器清0(2009-1-19)
head.s分析(4):关闭CACHE(2009-01-19)
head.s分析(5):关闭串口(2009-01-19)
head.s分析(6):栈指针初始化(2009-01-19)
分享到:
相关推荐
MATLAB课件:ch2_vectors_and_matrices.pdf
信息安全_数据安全_Attack_Vectors_in_Orbit:The_Need_for_I 安全审计 APT 常规渗透 信息安全 安全审计
之前在网上很难找到这个包,找到后挂上来了,需要者自取
g711官网下载,我也不知道是什么东西,新手试试看。
基于TMS320C5509的串口通信实验,源代码。
en-vectors-web-lg安装,这个资源在网上不太好找,免费给个链接
code for implementation of matlab hoefdding phi squere code to partition of row and column vectors using phi
ATMEGE128 uc/os 模板 编译器为ICCAVR
Word Vectors are often used as a fundamental component for downstream NLP tasks, e.g. question answering, text generation, translation, etc., so it is important to build some intuitions as to their ...
KeyedVectors.load_word2vec_format('GoogleNews-vectors-negative300.bin', binary=True)
tf maintains the relationship between coordinate frames in a tree structure buffered in time, and lets the user transform points, vectors, etc between any two coordinate frames at any desired point ...
> def __init__ ( self ): > super (). __init__ ( size = 32 ) > > power = BitField ( 0 , 1 ) # offset and size > spin = BitField ( 1 , 1 ) > speed = BitField ( 2 , 4 ) > sense = BitField
与model配套的资源,否则模型无法使用,因为一次只能上次一个文件所以分开
feature_vectors_convert_arff_format-Drebin feature_vectors_convert_arff_format-Drebin
dk_apps\src\plf\refip\src\arch\boot\rvds目录与system_ARMM0.c及boot_vectors.s在同一目录内。 3、将附件中的scatterfile_common.sct_38K.sct文件,Copy到: dk_apps\scatterfiles目录,与scatterfile_common.sct...
python库。 资源全名:cryptography_vectors-1.3-py2.py3-none-any.whl
4.1 Pointers and the Computer’s Memory . . . 4.1.1 Addresses . . . . . . . . . . . . . 4.1.2 Pointer Variables . . . . . . . . . . 4.1.3 Example Use of Pointers . . . . . 4.1.4 Warnings on the Use of...
启动代码划分为4个文件:Vectors.c、Init.s、Target.c、 Target.h。Vectors.c包含异常向量表、堆栈初始化及中断服务程序与C程序的接口。Init.s包含统初始化代码,并跳转到ADS提供的初始化代码。Target.c和 Target.h...