在setup_arch函數的末尾,有這樣的語句:
/* Copy atomic sequences to their fixed location, and sanity check that
these locations are the ones that we advertise to userspace. */
memcpy((void *)FIXED_CODE_START, &fixed_code_start,
FIXED_CODE_END - FIXED_CODE_START);
BUG_ON((char *)&sigreturn_stub - (char *)&fixed_code_start
!= SIGRETURN_STUB - FIXED_CODE_START);
BUG_ON((char *)&atomic_xchg32 - (char *)&fixed_code_start
!= ATOMIC_XCHG32 - FIXED_CODE_START);
BUG_ON((char *)&atomic_cas32 - (char *)&fixed_code_start
!= ATOMIC_CAS32 - FIXED_CODE_START);
BUG_ON((char *)&atomic_add32 - (char *)&fixed_code_start
!= ATOMIC_ADD32 - FIXED_CODE_START);
BUG_ON((char *)&atomic_sub32 - (char *)&fixed_code_start
!= ATOMIC_SUB32 - FIXED_CODE_START);
BUG_ON((char *)&atomic_ior32 - (char *)&fixed_code_start
!= ATOMIC_IOR32 - FIXED_CODE_START);
BUG_ON((char *)&atomic_and32 - (char *)&fixed_code_start
!= ATOMIC_AND32 - FIXED_CODE_START);
BUG_ON((char *)&atomic_xor32 - (char *)&fixed_code_start
!= ATOMIC_XOR32 - FIXED_CODE_START);
BUG_ON((char *)&safe_user_instruction - (char *)&fixed_code_start
!= SAFE_USER_INSTRUCTION - FIXED_CODE_START);
在這裡,FIXED_CODE_START等幾個定義都在include/asm/fixed_code.h中:
///* This file defines the fixed addresses where userspace programs can find
// atomic code sequences. */
//
#define FIXED_CODE_START 0x400
//
#define SIGRETURN_STUB 0x400
//
#define ATOMIC_SEQS_START 0x410
//
#define ATOMIC_XCHG32 0x410
#define ATOMIC_CAS32 0x420
#define ATOMIC_ADD32 0x430
#define ATOMIC_SUB32 0x440
#define ATOMIC_IOR32 0x450
#define ATOMIC_AND32 0x460
#define ATOMIC_XOR32 0x470
//
#define ATOMIC_SEQS_END 0x480
//
#define SAFE_USER_INSTRUCTION 0x480
//
#define FIXED_CODE_END 0x490
//
而fixed_code_start則是arch/ blackfin/ kernel/fixed_code.s中定義的一個符號。在fixed_code.s中有一段說明:
/*
* This file contains sequences of code that will be copied to a
* fixed location, defined in <asm/atomic_seq.h>. The interrupt
* handlers ensure that these sequences appear to be atomic when
* executed from userspace.
* These are aligned to 16 bytes, so that we have some space to replace
* these sequences with something else (e.g. kernel traps if we ever do
* BF561 SMP).
*/
但是實在不明白為什麼要將這些代碼復制到這個固定的位置??
這段代碼會引發一些符號鏈接錯誤,主要是__ebss_l1這樣的符號,這些符號的定義在vmlinux.lds中,因此相應地在LDF文件中進行修改:
L1_data_a
{
INPUT_SECTION_ALIGN(4)
___l1_data_cache_a = 0;
__sdata_l1 = .;
INPUT_SECTIONS($LIBRARIES_CORE_A(.l1.data))
__edata_l1 = .;
INPUT_SECTION_ALIGN(4)
__sbss_l1 = .;
INPUT_SECTIONS($LIBRARIES_CORE_A(.l1.bss))
INPUT_SECTION_ALIGN(32)
INPUT_SECTIONS($LIBRARIES_CORE_A(.data_l1.cacheline_aligned))
INPUT_SECTION_ALIGN(4)
__ebss_l1 = .;
INPUT_SECTIONS($OBJECTS_CORE_A(L1_data_a) $LIBRARIES_CORE_A(L1_data_a))
RESERVE(heaps_and_stack_in_L1_data_a, heaps_and_stack_in_L1_data_a_length = 2K,4)
INPUT_SECTIONS($OBJECTS_CORE_A{DualCoreMem("CoreA")}(cplb_data) $LIBRARIES_CORE_A{DualCoreMem("CoreA")}(cplb_data))
INPUT_SECTIONS($OBJECTS_CORE_A(cplb_data) $LIBRARIES_CORE_A(cplb_data))
} > MEM_A_L1_DATA_A
在這裡仍然保留了VDSP向導對heap的定義,因為不知道要引用的VDSP庫中是否要使用malloc這樣的函數來分配內存。
uclinux-2008R1-RC8(bf561)到VDSP5的移植(62)
uclinux-2008R1-RC8(bf561)到VDSP5的移植(60):current_text_addr
uclinux-2008R1-RC8(bf561)到VDSP5的移植(58)
uclinux-2008R1-RC8(bf561)到VDSP5的移植(57)
uclinux-2008R1-RC8(bf561)到VDSP5的移植(56):__grab_cache_page
uclinux-2008R1-RC8(bf561)到VDSP5的移植(46):raw_rwlock_t