📄 head.s
字号:
#define hasnt_leds(lab) cmpl &MACH_HP300,%pc@(m68k_machtype); \ jeq 42f; \ cmpl &MACH_APOLLO,%pc@(m68k_machtype); \ jne lab ;\ 42:\#define is_040_or_060(lab) btst &CPUTYPE_0460,%pc@(L(cputype)+3); jne lab#define is_not_040_or_060(lab) btst &CPUTYPE_0460,%pc@(L(cputype)+3); jeq lab#define is_040(lab) btst &CPUTYPE_040,%pc@(L(cputype)+3); jne lab#define is_060(lab) btst &CPUTYPE_060,%pc@(L(cputype)+3); jne lab#define is_not_060(lab) btst &CPUTYPE_060,%pc@(L(cputype)+3); jeq lab#define is_020(lab) btst &CPUTYPE_020,%pc@(L(cputype)+3); jne lab#define is_not_020(lab) btst &CPUTYPE_020,%pc@(L(cputype)+3); jeq lab/* On the HP300 we use the on-board LEDs for debug output before the console is running. Writing a 1 bit turns the corresponding LED _off_ - on the 340 bit 7 is towards the back panel of the machine. */.macro leds mask#if defined(CONFIG_HP300) || defined(CONFIG_APOLLO) hasnt_leds(.Lled\@) pea \mask func_call set_leds addql #4,%sp.Lled\@:#endif.endm.textENTRY(_stext)/* * Version numbers of the bootinfo interface * The area from _stext to _start will later be used as kernel pointer table */ bras 1f /* Jump over bootinfo version numbers */ .long BOOTINFOV_MAGIC .long MACH_AMIGA, AMIGA_BOOTI_VERSION .long MACH_ATARI, ATARI_BOOTI_VERSION .long MACH_MVME147, MVME147_BOOTI_VERSION .long MACH_MVME16x, MVME16x_BOOTI_VERSION .long MACH_BVME6000, BVME6000_BOOTI_VERSION .long MACH_MAC, MAC_BOOTI_VERSION .long MACH_Q40, Q40_BOOTI_VERSION .long 01: jra SYMBOL_NAME(__start).equ SYMBOL_NAME(kernel_pg_dir),SYMBOL_NAME(_stext).equ .,SYMBOL_NAME(_stext)+PAGESIZEENTRY(_start) jra SYMBOL_NAME(__start)__INITENTRY(__start)/* * Setup initial stack pointer */ lea %pc@(SYMBOL_NAME(_stext)),%sp/* * Record the CPU and machine type. */ get_bi_record BI_MACHTYPE lea %pc@(SYMBOL_NAME(m68k_machtype)),%a1 movel %a0@,%a1@ get_bi_record BI_FPUTYPE lea %pc@(SYMBOL_NAME(m68k_fputype)),%a1 movel %a0@,%a1@ get_bi_record BI_MMUTYPE lea %pc@(SYMBOL_NAME(m68k_mmutype)),%a1 movel %a0@,%a1@ get_bi_record BI_CPUTYPE lea %pc@(SYMBOL_NAME(m68k_cputype)),%a1 movel %a0@,%a1@#ifdef CONFIG_MAC/* * For Macintosh, we need to determine the display parameters early (at least * while debugging it). */ is_not_mac(L(test_notmac)) get_bi_record BI_MAC_VADDR lea %pc@(L(mac_videobase)),%a1 movel %a0@,%a1@ get_bi_record BI_MAC_VDEPTH lea %pc@(L(mac_videodepth)),%a1 movel %a0@,%a1@ get_bi_record BI_MAC_VDIM lea %pc@(L(mac_dimensions)),%a1 movel %a0@,%a1@ get_bi_record BI_MAC_VROW lea %pc@(L(mac_rowbytes)),%a1 movel %a0@,%a1@#ifdef MAC_SERIAL_DEBUG get_bi_record BI_MAC_SCCBASE lea %pc@(L(mac_sccbase)),%a1 movel %a0@,%a1@#endif /* MAC_SERIAL_DEBUG */#if 0 /* * Clear the screen */ lea %pc@(L(mac_videobase)),%a0 movel %a0@,%a1 lea %pc@(L(mac_dimensions)),%a0 movel %a0@,%d1 swap %d1 /* #rows is high bytes */ andl #0xFFFF,%d1 /* rows */ subl #10,%d1 lea %pc@(L(mac_rowbytes)),%a0loopy2: movel %a0@,%d0 subql #1,%d0loopx2: moveb #0x55, %a1@+ dbra %d0,loopx2 dbra %d1,loopy2#endifL(test_notmac):#endif /* CONFIG_MAC *//* * There are ultimately two pieces of information we want for all kinds of * processors CpuType and CacheBits. The CPUTYPE was passed in from booter * and is converted here from a booter type definition to a separate bit * number which allows for the standard is_0x0 macro tests. */ movel %pc@(SYMBOL_NAME(m68k_cputype)),%d0 /* * Assume it's an 030 */ clrl %d1 /* * Test the BootInfo cputype for 060 */ btst #CPUB_68060,%d0 jeq 1f bset #CPUTYPE_060,%d1 bset #CPUTYPE_0460,%d1 jra 3f1: /* * Test the BootInfo cputype for 040 */ btst #CPUB_68040,%d0 jeq 2f bset #CPUTYPE_040,%d1 bset #CPUTYPE_0460,%d1 jra 3f2: /* * Test the BootInfo cputype for 020 */ btst #CPUB_68020,%d0 jeq 3f bset #CPUTYPE_020,%d1 jra 3f3: /* * Record the cpu type */ lea %pc@(L(cputype)),%a0 movel %d1,%a0@ /* * NOTE: * * Now the macros are valid: * is_040_or_060 * is_not_040_or_060 * is_040 * is_060 * is_not_060 */ /* * Determine the cache mode for pages holding MMU tables * and for supervisor mode, unused for '020 and '030 */ clrl %d0 clrl %d1 is_not_040_or_060(L(save_cachetype)) /* * '040 or '060 * d1 := cacheable write-through * NOTE: The 68040 manual strongly recommends non-cached for MMU tables, * but we have been using write-through since at least 2.0.29 so I * guess it is OK. */#ifdef CONFIG_060_WRITETHROUGH /* * If this is a 68060 board using drivers with cache coherency * problems, then supervisor memory accesses need to be write-through * also; otherwise, we want copyback. */ is_not_060(1f) movel #_PAGE_CACHE040W,%d0 jra L(save_cachetype)#endif /* CONFIG_060_WRITETHROUGH */1: movew #_PAGE_CACHE040,%d0 movel #_PAGE_CACHE040W,%d1L(save_cachetype): /* Save cache mode for supervisor mode and page tables */ lea %pc@(SYMBOL_NAME(m68k_supervisor_cachemode)),%a0 movel %d0,%a0@ lea %pc@(SYMBOL_NAME(m68k_pgtable_cachemode)),%a0 movel %d1,%a0@/* * raise interrupt level */ movew #0x2700,%sr/* If running on an Atari, determine the I/O base of the serial port and test if we are running on a Medusa or Hades. This test is necessary here, because on the Hades the serial port is only accessible in the high I/O memory area. The test whether it is a Medusa is done by writing to the byte at phys. 0x0. This should result in a bus error on all other machines. ...should, but doesn't. The Afterburner040 for the Falcon has the same behaviour (0x0..0x7 are no ROM shadow). So we have to do another test to distinguish Medusa and AB040. This is a read attempt for 0x00ff82fe phys. that should bus error on a Falcon (+AB040), but is in the range where the Medusa always asserts DTACK. The test for the Hades is done by reading address 0xb0000000. This should give a bus error on the Medusa. */#ifdef CONFIG_ATARI is_not_atari(L(notypetest)) /* get special machine type (Medusa/Hades/AB40) */ moveq #0,%d3 /* default if tag doesn't exist */ get_bi_record BI_ATARI_MCH_TYPE tstl %d0 jbmi 1f movel %a0@,%d3 lea %pc@(SYMBOL_NAME(atari_mch_type)),%a0 movel %d3,%a0@1: /* On the Hades, the iobase must be set up before opening the * serial port. There are no I/O regs at 0x00ffxxxx at all. */ moveq #0,%d0 cmpl #ATARI_MACH_HADES,%d3 jbne 1f movel #0xff000000,%d0 /* Hades I/O base addr: 0xff000000 */1: lea %pc@(L(iobase)),%a0 movel %d0,%a0@L(notypetest):#endif#ifdef CONFIG_VME is_mvme147(L(getvmetype)) is_bvme6000(L(getvmetype)) is_not_mvme16x(L(gvtdone)) /* See if the loader has specified the BI_VME_TYPE tag. Recent * versions of VMELILO and TFTPLILO do this. We have to do this * early so we know how to handle console output. If the tag * doesn't exist then we use the Bug for output on MVME16x. */L(getvmetype): get_bi_record BI_VME_TYPE tstl %d0 jbmi 1f movel %a0@,%d3 lea %pc@(SYMBOL_NAME(vme_brdtype)),%a0 movel %d3,%a0@1:#ifdef CONFIG_MVME16x is_not_mvme16x(L(gvtdone)) /* Need to get the BRD_ID info to diferentiate between 162, 167, * etc. This is available as a BI_VME_BRDINFO tag with later * versions of VMELILO and TFTPLILO, otherwise we call the Bug. */ get_bi_record BI_VME_BRDINFO tstl %d0 jpl 1f /* Get pointer to board ID data from Bug */ movel %d2,%sp@- trap #15 .word 0x70 /* trap 0x70 - .BRD_ID */ movel %sp@+,%a01: lea %pc@(SYMBOL_NAME(mvme_bdid)),%a1 /* Structure is 32 bytes long */ movel %a0@+,%a1@+ movel %a0@+,%a1@+ movel %a0@+,%a1@+ movel %a0@+,%a1@+ movel %a0@+,%a1@+ movel %a0@+,%a1@+ movel %a0@+,%a1@+ movel %a0@+,%a1@+#endifL(gvtdone):#endif/* * Initialize serial port */ jbsr L(serial_init)/* * Initialize console */#ifdef CONFIG_MAC is_not_mac(L(nocon))#ifdef CONSOLE jbsr L(console_init)#ifdef CONSOLE_PENGUIN jbsr L(console_put_penguin)#endif /* CONSOLE_PENGUIN */ jbsr L(console_put_stats)#endif /* CONSOLE */L(nocon):#endif /* CONFIG_MAC */ putc '\n' putc 'A' dputn %pc@(L(cputype)) dputn %pc@(SYMBOL_NAME(m68k_supervisor_cachemode)) dputn %pc@(SYMBOL_NAME(m68k_pgtable_cachemode)) dputc '\n'/* * Save physical start address of kernel */ lea %pc@(L(phys_kernel_start)),%a0 lea %pc@(SYMBOL_NAME(_stext)),%a1 subl #SYMBOL_NAME(_stext),%a1 addl #PAGE_OFFSET,%a1 movel %a1,%a0@ putc 'B' leds 0x4/* * mmu_init * * This block of code does what's necessary to map in the various kinds * of machines for execution of Linux. * First map the first 4 MB of kernel code & data */ mmu_map #PAGE_OFFSET,%pc@(L(phys_kernel_start)),#4*1024*1024,\ %pc@(SYMBOL_NAME(m68k_supervisor_cachemode)) putc 'C'#ifdef CONFIG_AMIGAL(mmu_init_amiga): is_not_amiga(L(mmu_init_not_amiga))/* * mmu_init_amiga */ putc 'D' is_not_040_or_060(1f) /* * 040: Map the 16Meg range physical 0x0 upto logical 0x8000.0000 */ mmu_map #0x80000000,#0,#0x01000000,#_PAGE_NOCACHE_S /* * Map the Zorro III I/O space with transparent translation * for frame buffer memory etc. */ mmu_map_tt #1,#0x40000000,#0x20000000,#_PAGE_NOCACHE_S jbra L(mmu_init_done)1: /* * 030: Map the 32Meg range physical 0x0 upto logical 0x8000.0000 */ mmu_map #0x80000000,#0,#0x02000000,#_PAGE_NOCACHE030 mmu_map_tt #1,#0x40000000,#0x20000000,#_PAGE_NOCACHE030 jbra L(mmu_init_done)L(mmu_init_not_amiga):#endif#ifdef CONFIG_ATARIL(mmu_init_atari): is_not_atari(L(mmu_init_not_atari)) putc 'E'/* On the Atari, we map the I/O region (phys. 0x00ffxxxx) by mapping the last 16 MB of virtual address space to the first 16 MB (i.e. 0xffxxxxxx -> 0x00xxxxxx). For this, an additional pointer table is needed. I/O ranges are marked non-cachable. For the Medusa it is better to map the I/O region transparently (i.e. 0xffxxxxxx -> 0xffxxxxxx), because some I/O registers are accessible only in the high area. On the Hades all I/O registers are only accessible in the high area.*/ /* I/O base addr for non-Medusa, non-Hades: 0x00000000 */ moveq #0,%d0 movel %pc@(SYMBOL_NAME(atari_mch_type)),%d3 cmpl #ATARI_MACH_MEDUSA,%d3 jbeq 2f cmpl #ATARI_MACH_HADES,%d3 jbne 1f2: movel #0xff000000,%d0 /* Medusa/Hades base addr: 0xff000000 */1: movel %d0,%d3 is_040_or_060(L(spata68040)) /* Map everything non-cacheable, though not all parts really * need to disable caches (crucial only for 0xff8000..0xffffff * (standard I/O) and 0xf00000..0xf3ffff (IDE)). The remainder * isn't really used, except for sometimes peeking into the * ROMs (mirror at phys. 0x0), so caching isn't necessary for * this. */ mmu_map #0xff000000,%d3,#0x01000000,#_PAGE_NOCACHE030 jbra L(mmu_init_done)L(spata68040): mmu_map #0xff000000,%d3,#0x01000000,#_PAGE_NOCACHE_S jbra L(mmu_init_done)L(mmu_init_not_atari):#endif#ifdef CONFIG_Q40 is_not_q40(L(notq40)) /* * add transparent mapping for 0xff00 0000 - 0xffff ffff * non-cached serialized etc.. * this includes master chip, DAC, RTC and ISA ports * 0xfe000000-0xfeffffff is for screen and ROM */ putc 'Q' mmu_map_tt #0,#0xfe000000,#0x01000000,#_PAGE_CACHE040W mmu_map_tt #1,#0xff000000,#0x01000000,#_PAGE_NOCACHE_S jbra L(mmu_init_done) L(notq40): #endif #ifdef CONFIG_HP300 is_not_hp300(L(nothp300))/* On the HP300, we map the ROM, INTIO and DIO regions (phys. 0x00xxxxxx) by mapping 32MB from 0xf0xxxxxx -> 0x00xxxxxx) using an 030 early termination page descriptor. The ROM mapping is needed because the LEDs are mapped there too. */ mmu_map #0xf0000000,#0,#0x02000000,#_PAGE_NOCACHE030L(nothp300):#endif#ifdef CONFIG_MVME147 is_not_mvme147(L(not147)) /* * On MVME147 we have already created kernel page tables for * 4MB of RAM at address 0, so now need to do a transparent * mapping of the top of memory space. Make it 0.5GByte for now, * so we can access on-board i/o areas. */ mmu_map_tt #1,#0xe0000000,#0x20000000,#_PAGE_NOCACHE030 jbra L(mmu_init_done)L(not147):#endif /* CONFIG_MVME147 */#ifdef CONFIG_MVME16x is_not_mvme16x(L(not16x)) /* * On MVME16x we have already created kernel page tables for * 4MB of RAM at address 0, so now need to do a transparent * mapping of the top of memory space. Make it 0.5GByte for now. * Supervisor only access, so transparent mapping doesn't * clash with User code virtual address space. * this covers IO devices, PROM and SRAM. The PROM and SRAM * mapping is needed to allow 167Bug to run. * IO is in the range 0xfff00000 to 0xfffeffff. * PROM is 0xff800000->0xffbfffff and SRAM is * 0xffe00000->0xffe1ffff. */ mmu_map_tt #1,#0xe0000000,#0x20000000,#_PAGE_NOCACHE_S
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -