1 uClinux memory LayoutWhen uClinux is started, there is a space usage prompt: Memory Map: TEXT = export init = 0x000b1000-0x000bd23c DATA = export stack = 0x000c0000-0x000c2000 BSS = export available = 0x000f14d8-0x03500000 rootfs = export DMA zone = bytes where text represents the uClinux kernel code stored in this space; the code of the uClinux kernel is stored in init, but this space can be recycled after the kernel is started, that is, it can be re-allocated by the kernel; the data segment is the uninitialized data space of uClinux, And the BSS segment is uclin. The data space initialized by UX. Its initialization will be completed in head. S. In addition, the space starting from 0 to text will also be initialized to 0.
2. space allocation in vdspSpace Positioning in uClinux is completed by the linker and controlled by arch/Blackfin/kernel/vmlinux. LDS. S. The Space Location of the vdsp is completed by the LDF file, and the syntax of the LDF file is similar to that of vmlinux. LDS. S. All we need to do is transfer the definition in vmlinux. LDS. s to the LDF file. 1. Define the memory space used by a uClinux instance: mem_sdram_uclinux {type (RAM) Start (0x00010000) end (0x001fffff) width (8)} here, the end of the space uses a large value. In fact, in the uClinux kernel, the storage space is managed from where the code actually ends. 2. Write the uClinux kernel entry function to 0xffa00000, that is, the startup address of the core. Resolve (_ start, 0xffa00000) Keep (_ start, _ main) the default entry of vdsp is start, which is implemented in * _ basiccrt. S. After such processing, the core starts from _ start in head. S, and the B core still starts from start in * _ basiccrt. S. 3. Transplant the content of the. Text Segment. // Uclinux_text {input_section_align (4) _ stext _ = .; _ stext = .; input_sections ($ libraries_sml3_cm (. text) input_section_align (8) _ sched_text_start = .; input_sections ($ libraries_sml3_cm (. sched. text) _ sched_text_end = .; input_sections ($ libraries_sml3_cm (. text. lock) input_section_align (16) ___ start ___ ex_table = .; input_sections ($ libraries_sml3_cm (_ ex_table) ___ stop ___ ex_tab Le = .; // The content that was originally put in the l1_code defaults (4) _ core = 0; input_sections ($ objects_core_a (l1_code) $ else (l1_code) input_sections ($ objects_core_a (vdk_isr_code) $ attributes (attributes) input_sections ($ objects_core_a (cplb) $ attributes (cplb) input_sections ($ attributes (cplb_code) input_sections ($ attributes (noncache_code) $ libraries_c Ore_a (noncache_code) input_sections ($ procedure (Program) input_sections ($ objects_core_a (Program) $ libraries_core_a (Program )) // content input_section_align (4) input_sections ($ functions (outputs) input_sections ($ functions (sdram_bank0) input_sections ($ functions (data1) input_sections ($ Li) Volumes (voldata) input_sections ($ volumes (constdata) // content input_section_align (4) input_sections ($ links (sdram0) input_sections ($ links (LINKS )) input_sections ($ functions (sdram_bank1) input_sections ($ libraries_sml3_cm (Program) input_sections ($ functions (noncache_code) // uClinux code input_sections ($ response (PR) Ogram) input_sections ($ libraries_sml3_cm (. rodata) input_sections ($ libraries_sml3_cm (. rodata. *) input_sections ($ libraries_sml3_cm (_ vermagic) // kernel version magic input_sections ($ libraries_sml3_cm (. rodata1) input_sections ($ libraries_sml3_cm (. fixup) // kernel symbol table: normal symbols input_section_align (4) ___ start ___ ksymtab = .; input_sections ($ libraries_sml3_cm (_ ksymtab) ___ stop ___ K Symtab = .; // kernel symbol table: GPL-only symbols ___ start ___ ksymtab_gpl = .; input_sections ($ libraries_sml3_cm (_ ksymtab_gpl) ___ stop ___ ksymtab_gpl = .; // kernel symbol table: normal unused symbols ___ start ___ ksymtab_unused = .; input_sections ($ libraries_sml3_cm (_ ksymtab_unused) ___ stop ___ ksymtab_unused = .; // kernel symbol table: GPL-only unused symbols ___ start ___ ksymtab_unused_gpl = .; Input_sections ($ libraries_sml3_cm (_ ksymtab_unused_gpl) ___ stop ___ ksymtab_unused_gpl = .; // kernel symbol table: GPL-Future symbols ___ start ___ ksymtab_gpl_future = .; input_sections ($ libraries_sml3_cm (_ ksymtab_gpl_future) ___ stop ___ ksymtab_gpl_future = .; // kernel symbol table: normal symbols ___ start ___ kcralb = .; input_sections ($ libraries_sml3_cm (_ kcralb) ___ stop ___ kcralb = .; // Kern El symbol table: GPL-only symbols ___ start ___ kcrctab_gpl = .; input_sections ($ libraries_sml3_cm (_ kcrctab_gpl) ___ stop ___ kcrctab_gpl = .; // kernel symbol table: GPL-Future symbols ___ start ___ kcrctab_gpl_future = .; input_sections ($ libraries_sml3_cm (_ kcrctab_gpl_future) ___ stop ___ kcrctab_gpl_future = .; // kernel symbol table: strings input_sections ($ libraries_sml3_cm (_ ksymtab_strings) Input _ Section_align (4) _ etext =.;}> mem_sdram_uclinux inserts the vdsp library code in addition to the uClinux code, because we want to use the library functions provided by vdsp as much as possible. Some code and data segments are mixed in the middle, and then fine-tuned later. There is also a special symbol _ stext __, which was originally placed in the head. in S, it indicates the starting position of the first line of code in the uClinux kernel, because we write the first line of code to 0xffa00000, so in head. the symbol in S is canceled and then defined in the LDF file. 4. Port the. init segment definition. // In the initialization code section, you can recycle uclinux_init {input_section_align (4096) ___ init_begin = .; _ sinittext = .; input_sections ($ libraries_sml3_cm (. init. text) _ einittext = .; input_sections ($ libraries_sml3_cm (. init. data) input_section_align (16) ___ setup_start = .; input_sections ($ libraries_sml3_cm (. init. setup) ___ setup_end = .; ___ start ___ Param = .; input_sections ($ libraries_sml3_cm (_ PARAM) ___ stop ___ Param = .; ___ Initcall_start = .; input_sections ($ libraries_sml3_cm (. initcall1.init) input_sections ($ libraries_sml3_cm (. initcall2.init) input_sections ($ libraries_sml3_cm (. initcall3.init) input_sections ($ libraries_sml3_cm (. initcall4.init) input_sections ($ libraries_sml3_cm (. initcall5.init) input_sections ($ libraries_sml3_cm (. initcall6.init) input_sections ($ libraries_sml3_cm (. initcall7.init) ___ initcall_e ND = .; ___ con_initcall_start = .; input_sections ($ libraries_sml3_cm (. con_initcall.init) ___ con_initcall_end = .; ___ security_initcall_start = .; input_sections ($ libraries_sml3_cm (. security_initcall.init) ___ security_initcall_end = .; input_section_align (4) ___ initramfs_start = .; input_sections ($ libraries_sml3_cm (. init. ramfs) ___ initramfs_end = .; input_section_align (4) ___ init_end =. ;}> me M_sdram_uclinux5, transplanted. Text. L1, that is, the part that needs to be placed in L1. Uclinux_text_l1 {input_section_align (4) _ l1_lma_start = .; _ stext_l1 = .; input_sections ($ libraries_sml3_cm (. l1.text) input_section_align (4) _ etext_l1 =.;}> mem_a_l1_code6, port. data. l1 data segment. Uclinux_data_l1 {input_section_align (4) _ sdata_l1 = .; input_sections ($ libraries_sml3_cm (. l1.data) input_sections (Corea. DLB (data1) _ edata_l1 = .; input_section_align (4) _ sbss_l1 = .; input_sections ($ libraries_sml3_cm (. l1.bss) input_section_align (4) _ ebss_l1 =. ;}> mem_a_l1_data_a7, port. data. b. l1. Uclinux_data_ B _l1 {input_section_align (4) _ sdata_ B _l1 = .; input_sections ($ libraries_sml3_cm (. l1.data. b) _ edata_ B _l1 = .; input_section_align (4) _ sbss_ B _l1 = .; input_sections ($ libraries_sml3_cm (. l1.bss. b) input_section_align (4) _ ebss_ B _l1 =.;}> mem_a_l1_data_b8: port the data segment. // Data segment uclinux_data {input_section_align (0x2000) _ sdata = .; input_sections ($ libraries_sml3_cm (. data. init_task) input_sections ($ libraries_sml3_cm (. data) // input_section_align (4) ___ partition = 0; input_sections ($ objects_core_a (l1_data_a) $ libraries_core_a (l1_data_a )) input_sections ($ objects_core_a {dualcoremem ("Corea")} (cplb_data) $ libraries_core_a {dualcoremem ("Corea")} (CPL B _data) input_sections ($ objects_core_a (cplb_data) $ convert (cplb_data) input_sections ($ objects_core_a (voldata) $ convert (voldata) input_sections ($ aggregate (constdata) $ functions (constdata) input_sections ($ functions (data1) input_sections ($ functions (data1) input_sections ($ objects_core_a (data1) $ libraries_core_a (data1) ONS ($ objects_core_a (. EDT) $ libraries_core_a (. EDT) input_sections ($ objects_core_a (. CHT) $ libraries_core_a (. CHT) // content that was originally stored in data_ B partition (4) ___ partition = 0; input_sections ($ objects_core_a (ctor) $ libraries_core_a (ctor) input_sections ($ objects_core_a (ctorl) $ libraries_core_a (ctorl) input_sections ($ objects_core_a (vtbl) $ libraries_core_a (vtbl) input_sections ($ objects_core_a (. gdt) $ Libraries_core_a (. gdt) input_sections ($ objects_core_a (. gdtl) $ libraries_core_a (. gdtl) input_sections ($ objects_core_a (. FRT) $ libraries_core_a (. FRT) input_sections ($ objects_core_a (. rtti) $ libraries_core_a (. rtti) input_sections ($ objects_core_a (. EDT) $ libraries_core_a (. EDT) input_sections ($ objects_core_a (. CHT) $ libraries_core_a (. CHT) input_sections ($ objs_libs_internal_core_a (data1) input_sec Tions ($ attributes (data1) input_sections ($ objects_core_a (data1) $ libraries_core_a (data1) input_sections ($ objects_core_a {dualcoremem ("Corea")} (cplb_data) $ partition {dualcoremem ("Corea")} (cplb_data) input_sections ($ partition (cplb_data) input_sections ($ objects_core_a (voldata) $ partition (voldata )) input_sections ($ objects_core_a (cons Tdata) $ libraries_core_a (constdata) _ jiffies = _ jiffies_64; input_section_align (4) _ edata =. ;}> mem_sdram_uclinux inserts data segments in the vdsp library. 9. Port BSS segments. // BSS segment uclinux_bss {input_section_align (4) ___ bss_start = .; input_sections ($ libraries_sml3_cm (. BSS) input_sections ($ libraries_sml3_cm (common) input_section_align (4) ___ bss_stop = .; _ end =. ;}> mem_sdram_uclinux