📄 head.s
字号:
lea %a2@(PTR_TABLE_SIZE*PAGE_TABLE_SIZE*PAGESIZE),%a2 jra L(mmu_mapnext_030)1: /* Calculate the offset into the pointer table */ movel %a3,%d0 moveq #PTR_INDEX_SHIFT,%d1 lsrl %d1,%d0 andl #PTR_TABLE_SIZE-1,%d0 mmu_get_ptr_table_entry %a0,%d0 /* The pointer table entry must not no be busy */ tstl %a0@ jne L(mmu_map_error) /* Do the mapping and advance the pointers */ dputs "early term2" dputn %a2 dputn %a3 dputc '\n' movel %a2,%a0@ addl #PAGE_TABLE_SIZE*PAGESIZE,%a2 addl #PAGE_TABLE_SIZE*PAGESIZE,%a3L(mmu_mapnext_030): /* Ready with mapping? */ lea %a3@(-1),%a0 cmpl %a0,%a4 jhi L(mmu_map_030) jra L(mmu_map_done)L(mmu_map_error): dputs "mmu_map error:" dputn %a2 dputn %a3 dputc '\n'L(mmu_map_done):func_return mmu_map/* * mmu_fixup * * On the 040 class machines, all pages that are used for the * mmu have to be fixed up. */func_start mmu_fixup_page_mmu_cache,%d0/%a0 dputs "mmu_fixup_page_mmu_cache" dputn ARG1 /* Calculate the offset into the root table */ movel ARG1,%d0 moveq #ROOT_INDEX_SHIFT,%d1 lsrl %d1,%d0 mmu_get_root_table_entry %d0 /* Calculate the offset into the pointer table */ movel ARG1,%d0 moveq #PTR_INDEX_SHIFT,%d1 lsrl %d1,%d0 andl #PTR_TABLE_SIZE-1,%d0 mmu_get_ptr_table_entry %a0,%d0 /* Calculate the offset into the page table */ movel ARG1,%d0 moveq #PAGE_INDEX_SHIFT,%d1 lsrl %d1,%d0 andl #PAGE_TABLE_SIZE-1,%d0 mmu_get_page_table_entry %a0,%d0 movel %a0@,%d0 andil #_CACHEMASK040,%d0 orl %pc@(SYMBOL_NAME(m68k_pgtable_cachemode)),%d0 movel %d0,%a0@ dputc '\n'func_return mmu_fixup_page_mmu_cache/* * mmu_temp_map * * create a temporary mapping to enable the mmu, * this we don't need any transparation translation tricks. */func_start mmu_temp_map,%d0/%d1/%a0/%a1 dputs "mmu_temp_map" dputn ARG1 dputn ARG2 dputc '\n' lea %pc@(L(temp_mmap_mem)),%a1 /* Calculate the offset in the root table */ movel ARG2,%d0 moveq #ROOT_INDEX_SHIFT,%d1 lsrl %d1,%d0 mmu_get_root_table_entry %d0 /* Check if the table is temporary allocated, so we have to reuse it */ movel %a0@,%d0 cmpl %pc@(L(memory_start)),%d0 jcc 1f /* Temporary allocate a ptr table and insert it into the root table */ movel %a1@,%d0 addl #PTR_TABLE_SIZE*4,%a1@ orw #_PAGE_TABLE+_PAGE_ACCESSED,%d0 movel %d0,%a0@ dputs " (new)"1: dputn %d0 /* Mask the root table entry for the ptr table */ andw #-ROOT_TABLE_SIZE,%d0 movel %d0,%a0 /* Calculate the offset into the pointer table */ movel ARG2,%d0 moveq #PTR_INDEX_SHIFT,%d1 lsrl %d1,%d0 andl #PTR_TABLE_SIZE-1,%d0 lea %a0@(%d0*4),%a0 dputn %a0 /* Check if a temporary page table is already allocated */ movel %a0@,%d0 jne 1f /* Temporary allocate a page table and insert it into the ptr table */ movel %a1@,%d0 /* The 512 should be PAGE_TABLE_SIZE*4, but that violates the alignment restriction for pointer tables on the '0[46]0. */ addl #512,%a1@ orw #_PAGE_TABLE+_PAGE_ACCESSED,%d0 movel %d0,%a0@ dputs " (new)"1: dputn %d0 /* Mask the ptr table entry for the page table */ andw #-PTR_TABLE_SIZE,%d0 movel %d0,%a0 /* Calculate the offset into the page table */ movel ARG2,%d0 moveq #PAGE_INDEX_SHIFT,%d1 lsrl %d1,%d0 andl #PAGE_TABLE_SIZE-1,%d0 lea %a0@(%d0*4),%a0 dputn %a0 /* Insert the address into the page table */ movel ARG1,%d0 andw #-PAGESIZE,%d0 orw #_PAGE_PRESENT+_PAGE_ACCESSED+_PAGE_DIRTY,%d0 movel %d0,%a0@ dputn %d0 dputc '\n'func_return mmu_temp_mapfunc_start mmu_engage,%d0-%d2/%a0-%a3 moveq #ROOT_TABLE_SIZE-1,%d0 /* Temporarily use a different root table. */ lea %pc@(L(kernel_pgdir_ptr)),%a0 movel %a0@,%a2 movel %pc@(L(memory_start)),%a1 movel %a1,%a0@ movel %a2,%a01: movel %a0@+,%a1@+ dbra %d0,1b lea %pc@(L(temp_mmap_mem)),%a0 movel %a1,%a0@ movew #PAGESIZE-1,%d01: clrl %a1@+ dbra %d0,1b lea %pc@(1b),%a0 movel #1b,%a1 /* Skip temp mappings if phys == virt */ cmpl %a0,%a1 jeq 1f mmu_temp_map %a0,%a0 mmu_temp_map %a0,%a1 addw #PAGESIZE,%a0 addw #PAGESIZE,%a1 mmu_temp_map %a0,%a0 mmu_temp_map %a0,%a11: movel %pc@(L(memory_start)),%a3 movel %pc@(L(phys_kernel_start)),%d2 is_not_040_or_060(L(mmu_engage_030))L(mmu_engage_040): .chip 68040 nop cinva %bc nop pflusha nop movec %a3,%srp movel #TC_ENABLE+TC_PAGE4K,%d0 movec %d0,%tc /* enable the MMU */ jmp 1f:l1: nop movec %a2,%srp nop cinva %bc nop pflusha .chip 68k jra L(mmu_engage_cleanup)L(mmu_engage_030_temp): .space 12L(mmu_engage_030): .chip 68030 lea %pc@(L(mmu_engage_030_temp)),%a0 movel #0x80000002,%a0@ movel %a3,%a0@(4) movel #0x0808,%d0 movec %d0,%cacr pmove %a0@,%srp pflusha /* * enable,super root enable,4096 byte pages,7 bit root index, * 7 bit pointer index, 6 bit page table index. */ movel #0x82c07760,%a0@(8) pmove %a0@(8),%tc /* enable the MMU */ jmp 1f:l1: movel %a2,%a0@(4) movel #0x0808,%d0 movec %d0,%cacr pmove %a0@,%srp pflusha .chip 68kL(mmu_engage_cleanup): subl #PAGE_OFFSET,%d2 subl %d2,%a2 movel %a2,L(kernel_pgdir_ptr) subl %d2,%fp subl %d2,%sp subl %d2,ARG0func_return mmu_engagefunc_start mmu_get_root_table_entry,%d0/%a1#if 0 dputs "mmu_get_root_table_entry:" dputn ARG1 dputs " ="#endif movel %pc@(L(kernel_pgdir_ptr)),%a0 tstl %a0 jne 2f dputs "\nmmu_init:" /* Find the start of free memory, get_bi_record does this for us, * as the bootinfo structure is located directly behind the kernel * and and we simply search for the last entry. */ get_bi_record BI_LAST addw #PAGESIZE-1,%a0 movel %a0,%d0 andw #-PAGESIZE,%d0 dputn %d0 lea %pc@(L(memory_start)),%a0 movel %d0,%a0@ lea %pc@(L(kernel_end)),%a0 movel %d0,%a0@ /* we have to return the first page at _stext since the init code * in mm/init.c simply expects kernel_pg_dir there, the rest of * page is used for further ptr tables in get_ptr_table. */ lea %pc@(SYMBOL_NAME(_stext)),%a0 lea %pc@(L(mmu_cached_pointer_tables)),%a1 movel %a0,%a1@ addl #ROOT_TABLE_SIZE*4,%a1@ lea %pc@(L(mmu_num_pointer_tables)),%a1 addql #1,%a1@ /* clear the page */ movel %a0,%a1 movew #PAGESIZE/4-1,%d01: clrl %a1@+ dbra %d0,1b lea %pc@(L(kernel_pgdir_ptr)),%a1 movel %a0,%a1@ dputn %a0 dputc '\n'2: movel ARG1,%d0 lea %a0@(%d0*4),%a0#if 0 dputn %a0 dputc '\n'#endiffunc_return mmu_get_root_table_entryfunc_start mmu_get_ptr_table_entry,%d0/%a1#if 0 dputs "mmu_get_ptr_table_entry:" dputn ARG1 dputn ARG2 dputs " ="#endif movel ARG1,%a0 movel %a0@,%d0 jne 2f /* Keep track of the number of pointer tables we use */ dputs "\nmmu_get_new_ptr_table:" lea %pc@(L(mmu_num_pointer_tables)),%a0 movel %a0@,%d0 addql #1,%a0@ /* See if there is a free pointer table in our cache of pointer tables */ lea %pc@(L(mmu_cached_pointer_tables)),%a1 andw #7,%d0 jne 1f /* Get a new pointer table page from above the kernel memory */ get_new_page movel %a0,%a1@1: /* There is an unused pointer table in our cache... use it */ movel %a1@,%d0 addl #PTR_TABLE_SIZE*4,%a1@ dputn %d0 dputc '\n' /* Insert the new pointer table into the root table */ movel ARG1,%a0 orw #_PAGE_TABLE+_PAGE_ACCESSED,%d0 movel %d0,%a0@2: /* Extract the pointer table entry */ andw #-PTR_TABLE_SIZE,%d0 movel %d0,%a0 movel ARG2,%d0 lea %a0@(%d0*4),%a0#if 0 dputn %a0 dputc '\n'#endiffunc_return mmu_get_ptr_table_entryfunc_start mmu_get_page_table_entry,%d0/%a1#if 0 dputs "mmu_get_page_table_entry:" dputn ARG1 dputn ARG2 dputs " ="#endif movel ARG1,%a0 movel %a0@,%d0 jne 2f /* If the page table entry doesn't exist, we allocate a complete new * page and use it as one continues big page table which can cover * 4MB of memory, nearly almost all mappings have that alignment. */ get_new_page addw #_PAGE_TABLE+_PAGE_ACCESSED,%a0 /* align pointer table entry for a page of page tables */ movel ARG1,%d0 andw #-(PAGESIZE/PAGE_TABLE_SIZE),%d0 movel %d0,%a1 /* Insert the page tables into the pointer entries */ moveq #PAGESIZE/PAGE_TABLE_SIZE/4-1,%d01: movel %a0,%a1@+ lea %a0@(PAGE_TABLE_SIZE*4),%a0 dbra %d0,1b /* Now we can get the initialized pointer table entry */ movel ARG1,%a0 movel %a0@,%d02: /* Extract the page table entry */ andw #-PAGE_TABLE_SIZE,%d0 movel %d0,%a0 movel ARG2,%d0 lea %a0@(%d0*4),%a0#if 0 dputn %a0 dputc '\n'#endiffunc_return mmu_get_page_table_entry/* * get_new_page * * Return a new page from the memory start and clear it. */func_start get_new_page,%d0/%a1 dputs "\nget_new_page:" /* allocate the page and adjust memory_start */ lea %pc@(L(memory_start)),%a0 movel %a0@,%a1 addl #PAGESIZE,%a0@ /* clear the new page */ movel %a1,%a0 movew #PAGESIZE/4-1,%d01: clrl %a1@+ dbra %d0,1b dputn %a0 dputc '\n'func_return get_new_page/* * Debug output support * Atarians have a choice between the parallel port, the serial port * from the MFP or a serial port of the SCC */#ifdef CONFIG_MACL(scc_initable_mac): .byte 9,12 /* Reset */ .byte 4,0x44 /* x16, 1 stopbit, no parity */ .byte 3,0xc0 /* receiver: 8 bpc */ .byte 5,0xe2 /* transmitter: 8 bpc, assert dtr/rts */ .byte 9,0 /* no interrupts */ .byte 10,0 /* NRZ */ .byte 11,0x50 /* use baud rate generator */ .byte 12,10,13,0 /* 9600 baud */ .byte 14,1 /* Baud rate generator enable */ .byte 3,0xc1 /* enable receiver */ .byte 5,0xea /* enable transmitter */ .byte -1 .even#endif#ifdef CONFIG_ATARI/* #define USE_PRINTER *//* #define USE_SCC_B *//* #define USE_SCC_A */#define USE_MFP#if defined(USE_SCC_A) || defined(USE_SCC_B)#define USE_SCC/* Initialisation table for SCC */L(scc_initable): .byte 9,12 /* Reset */ .byte 4,0x44 /* x16, 1 stopbit, no parity */ .byte 3,0xc0 /* receiver: 8 bpc */ .byte 5,0xe2 /* transmitter: 8 bpc, assert dtr/rts */ .byte 9,0 /* no interrupts */ .byte 10,0 /* NRZ */ .byte 11,0x50 /* use baud rate generator */ .byte 12,24,13,0 /* 9600 baud */ .byte 14,2,14,3 /* use master clock for BRG, enable */ .byte 3,0xc1 /* enable receiver */ .byte 5,0xea /* enable transmitter */ .byte -1 .even#endif#i
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -