一. Linux ARMv7啟動階段對中斷向量表的搬移
1、中斷向量表和中斷處理部分代碼的搬移
經歷過kernel的匯編階段,進入C語言start_kernel后對中斷向量表的位置進行搬移,搬移函數是early_trap_init。
early_trap_init函數的調用流程為:
start_kernel(init/main.c)--->setup_arch(arch/arm/kernel/setup.c)--->paging_init(arch/arm/mm/mmu.c)--->devicemaps_init(arch/arm/mm/mmu.c)--->early_trap_init(arch/arm/kernel/traps.c)
/*
* Set up the device mappings. Since we clear out the page tables for all
* mappings above VMALLOC_START, except early fixmap, we might remove debug
* device mappings. This means earlycon can be used to debug this function
* Any other function or debugging method which may touch any device _will_
* crash the kernel.
*/
static void __init devicemaps_init(const struct machine_desc *mdesc)
{
struct map_desc map;
unsigned long addr;
void *vectors;
/*
* Allocate the vector page early.
*分配兩個頁的內存空間,arm中每個頁的大小為4K,這兩個頁的內存空間,一個是為保存中斷向量
*表,一個是為了保存中斷的處理部分代碼,這兩部分代碼的排布可以在
*(arch/arm/kernel/vmlinux.lds和arch/arm/kernel/entry-armv.S)中可以具體分析出來
*/
vectors = early_alloc(PAGE_SIZE * 2);
early_trap_init(vectors);
/*
* Clear page table except top pmd used by early fixmaps
*/
for (addr = VMALLOC_START; addr < (FIXADDR_TOP & PMD_MASK); addr += PMD_SIZE)
pmd_clear(pmd_off_k(addr));
/*
* Map the kernel if it is XIP.
* It is always first in the modulearea.
*/
#ifdef CONFIG_XIP_KERNEL //此宏未定義
map.pfn = __phys_to_pfn(CONFIG_XIP_PHYS_ADDR & SECTION_MASK);
map.virtual = MODULES_VADDR;
map.length = ((unsigned long)_etext - map.virtual + ~SECTION_MASK) & SECTION_MASK;
map.type = MT_ROM;
create_mapping(&map);
#endif
/*
* Map the cache flushing regions.
*/
#ifdef FLUSH_BASE //此宏未定義
map.pfn = __phys_to_pfn(FLUSH_BASE_PHYS);
map.virtual = FLUSH_BASE;
map.length = SZ_1M;
map.type = MT_CACHECLEAN;
create_mapping(&map);
#endif
#ifdef FLUSH_BASE_MINICACHE //此宏未定義
map.pfn = __phys_to_pfn(FLUSH_BASE_PHYS + SZ_1M);
map.virtual = FLUSH_BASE_MINICACHE;
map.length = SZ_1M;
map.type = MT_MINICLEAN;
create_mapping(&map);
#endif
/*
* Create a mapping for the machine vectors at the high-vectors
* location (0xffff0000). If we aren't using high-vectors, also
* create a mapping at the low-vectors virtual address.
*/
/*
*創建一個頁的內存地址映射,虛擬地址為0xffff0000,此地址為中斷向量表的高端地址
*設置中斷向量表的高端地址在匯編的v7_setup中,使用的v7_crval設置了cp15的c1寄存器
*v7_crval定義在arch/arm/mm/proc-v7-2level.S。
*/
map.pfn = __phys_to_pfn(virt_to_phys(vectors));
map.virtual = 0xffff0000;
map.length = PAGE_SIZE;
#ifdef CONFIG_KUSER_HELPERS //此宏有定義
map.type = MT_HIGH_VECTORS;
#else
map.type = MT_LOW_VECTORS;
#endif
create_mapping(&map);
/*
*判斷中斷向量表的位置是否設置在高端地址,如果中斷向量表沒有設置在高端地址,
*在映射低端中斷向量表地址。
*/
if (!vectors_high()) {
map.virtual = 0;
map.length = PAGE_SIZE * 2;
map.type = MT_LOW_VECTORS;
create_mapping(&map);
}
/* Now create a kernel read-only mapping */
map.pfn += 1;
map.virtual = 0xffff0000 + PAGE_SIZE;
map.length = PAGE_SIZE;
map.type = MT_LOW_VECTORS;
create_mapping(&map);
/*
* Ask the machine support to map in the statically mapped devices.
*/
if (mdesc->map_io)
mdesc->map_io();
else
debug_ll_io_init();
fill_pmd_gaps();
/* Reserve fixed i/o space in VMALLOC region */
pci_reserve_io();
/*
* Finally flush the caches and tlb to ensure that we're in a
* consistent state wrt the writebuffer. This also ensures that
* any write-allocated cache lines in the vector page are written
* back. After this point, we can start to touch devices again.
*/
local_flush_tlb_all();
flush_cache_all();
/* Enable asynchronous aborts */
early_abt_enable();
}
/* AT
* TFR EV X F I D LR S
* .EEE ..EE PUI. .T.T 4RVI ZWRS BLDP WCAM
* rxxx rrxx xxx0 0101 xxxx xxxx x111 xxxx < forced
* 01 0 110 0011 1100 .111 1101 < we want
*/
.align 2
.type v7_crval, #object
v7_crval:
crval clear=0x2120c302, mmuset=0x10c03c7d, ucset=0x00c01c7c
early_trap_init函數的分析
void __init early_trap_init(void *vectors_base)
{
#ifndef CONFIG_CPU_V7M
unsigned long vectors = (unsigned long)vectors_base;
extern char __stubs_start[], __stubs_end[];
extern char __vectors_start[], __vectors_end[];
unsigned i;
vectors_page = vectors_base;
/*
* Poison the vectors page with an undefined instruction. This
* rly_trap_init instruction is chosen to be undefined for both ARM and Thumb
* ISAs. The Thumb version is an undefined instruction with a
* branch back to the undefined instruction.
* 將申請的4K先設置為未定義指令,防止在發生其他中斷時,沒有處理導致cpu錯誤
*/
for (i = 0; i < PAGE_SIZE / sizeof(u32); i++)
((u32 *)vectors_base)[i] = 0xe7fddef1;/*
* Copy the vectors, stubs and kuser helpers (in entry-armv.S)
* into the vector page, mapped at 0xffff0000, and ensure these
* are visible to the instruction stream.
*/
/*
*將中斷向量表和中斷處理的代碼搬移到申請的兩頁地址空間內
*/
memcpy((void *)vectors, __vectors_start, __vectors_end - __vectors_start);
memcpy((void *)vectors + 0x1000, __stubs_start, __stubs_end - __stubs_start);
kuser_init(vectors_base);
flush_icache_range(vectors, vectors + PAGE_SIZE * 2);
#else /* ifndef CONFIG_CPU_V7M */
/*
* on V7-M there is no need to copy the vector table to a dedicated
* memory area. The address is configurable and so a table in the kernel
* image can be used.
*/
#endif
}
上一篇:I2C協議->裸機程序->adapter驅動程序分析
下一篇:linux arm mmu基礎
推薦閱讀
史海拾趣
1991年,高通的CDMA技術首次被商用于美國衛星通信公司的無線電話網,標志著高通在移動通信領域的重大突破。與此同時,高通開始向智能手機芯片方向轉型,目標是利用芯片技術使手機具備更強大的計算能力。隨著技術的不斷成熟,高通推出了多款性能卓越的移動應用處理器,如Snapdragon系列,迅速占據了智能手機芯片市場的主導地位。這一轉型不僅鞏固了高通在移動通信領域的地位,也為公司的長期發展奠定了堅實基礎。
隨著公司的不斷發展,奧松電子陸續獲得了多項榮譽資質,如“國家專精特新‘小巨人’企業”、“國家高新技術企業”等。這些榮譽的獲得,不僅證明了公司在電子行業中的實力與地位,也為公司的品牌建設提供了有力的支撐。同時,這些榮譽也為公司的市場拓展和業務發展提供了更多的機遇和可能。
AND Displays公司自成立以來,一直致力于顯示技術的研發與創新。在早期階段,公司團隊就針對當時市場上顯示面板的缺陷,進行了一系列技術攻關。經過數年的努力,AND Displays成功開發出了一種新型顯示技術,該技術在色彩還原、對比度和響應速度等方面均表現出色,迅速獲得了市場的認可。此后,公司不斷推出創新產品,滿足了消費者對高質量顯示面板的日益增長的需求,逐漸在電子行業中嶄露頭角。
GradConn深知不同客戶對連接解決方案的需求各不相同,因此公司特別注重提供定制化服務。通過與客戶緊密合作,GradConn能夠深入了解其特定需求,并據此設計出符合客戶要求的定制化產品。這種服務不僅提升了客戶的滿意度,還增強了GradConn在市場上的競爭力。許多知名企業都選擇GradConn作為其連接器和電纜組件的供應商,正是看中了其強大的定制化能力。
Appointech Inc公司深知品質是企業的生命線。因此,公司建立了嚴格的質量管理體系,從原材料采購到產品出廠的每一個環節都進行嚴格把控。同時,公司還注重品牌建設,通過不斷提升產品質量和服務水平,樹立了良好的企業形象和口碑。
特種光源、彩色顯示等行業的基礎是彩色的還原與傳遞,在光學計量領域屬于光源的光度和色度計量范疇,色坐標和亮度因數是主要的參數之一。光度、色度測試系統的性能,在高清晰度數字電視的白場基準測試、高清晰度數字攝像 ...… 查看全部問答∨ |
|
本文來源于:http://www.hellodsp.com/bbs/viewthread.php?tid=574&extra=page%3D1 先從最簡單的說起,感覺多層板也沒有多么神秘 1 原理圖設計 現在的開發板、評估板資料很多,原理圖的設計不是很難的事情(這是對于DSP系統板或者 ...… 查看全部問答∨ |
|
前仿沒有問題,用Quater 2編譯也成功了,但后仿時出現網表文件錯誤…… 請高人指教…… 謝謝…… `timescale 1ns/100ps `define clk_cycle 50 module sim_all(clk,rst,rst1,wr_en,rd_en); input clk,rst,rst1,wr ...… 查看全部問答∨ |
|
也許..這個程序就不大對..是自己按照 <不完全手冊>改的 總感覺程序就不大對..這幾天也沒靜下心看AD.感覺有了庫文件..照著來就是了.幾個通道還是有點亂.高人沒沒事的時候幫我看看吧.謝謝大家啦… 查看全部問答∨ |