#if defined(R4000) // && defined(DUO) /*++ Copyright (c) 1993 Microsoft Corporation Module Name: duoreset.s Abstract: This module is the start-up code for the Base prom code. This code will be the first run upon reset. This module contains the BEV exception vectors. On a hard reset the minimal initialization to be able to read the keyboard is done. If a key is being pressed, the scsi floppy drive is looked up and the setup program loaded. If it's a soft reset or NMI Map The FLASH_PROM in the TLB and jump to the FLASH PROM Reset vector. Author: Lluis Abello (lluis) 8-Apr-93 Environment: Executes in kernal mode. Notes: ***** IMPORTANT ***** This module must be linked such that it resides in the first page of the rom. Revision History: --*/ // // include header file // #include #ifdef DUO #include #else #include #define EEPROM_VIRTUAL_BASE PROM_VIRTUAL_BASE #define FLASH_PROM_TLB_INDEX 0 #endif #include "duoreset.h" #include "dmaregs.h" #include "led.h" #include "kbdmouse.h" #define TLB_HI 0 #define TLB_LO0 4 #define TLB_LO1 8 #define TLB_MASK 12 //TEMPTEMP #define COPY_ENTRY 6 .text .set noreorder .set noat ALTERNATE_ENTRY(ResetVector) ori zero,zero,0xffff // this is a dummy instruction to // fix a bug where the first byte // fetched from the PROM is wrong b ResetException nop // // This is the jump table for rom routines that other // programs can call. They are placed here so that they // will be unlikely to move. // // // This becomes PROM_ENTRY(2) as defined in ntmips.h // .align 4 nop // // Entries 4 to 7 are used for the ROM Version and they // must be zero in this file. // // // This becomes PROM_ENTRYS(8,9...) // .align 6 nop // entry 8 nop nop // entry 9 nop b TlbInit // entry 10 nop nop // entry 11 nop nop // entry 12 nop nop // entry 13 nop b PutLedDisplay // entry 14 nop nop // entry 15 nop nop // entry 16 nop // // This table contains the default values for the remote speed regs. // RomRemoteSpeedValues: .byte REMSPEED1 // ethernet .byte REMSPEED2 // SCSI .byte REMSPEED3 // Floppy / SCSI (DUO) .byte REMSPEED4 // RTC .byte REMSPEED5 // Kbd/Mouse .byte REMSPEED6 // Serial port 1 .byte REMSPEED7 // Serial port 2 .byte REMSPEED8 // Parallel .byte REMSPEED9 // NVRAM .byte REMSPEED10 // Int src reg .byte REMSPEED11 // PROM .byte REMSPEED12 // Sound / New Dev (DUO) .byte REMSPEED13 // New dev .byte REMSPEED14 // External Eisa latch / LED (DUO) // // New TLB Entries can be added to the following table // The format of the table is: // entryhi; entrylo0; entrylo1; pagemask // .align 4 TlbEntryTable: // // 256KB Base PROM // 256KB Flash PROM // .word ((PROM_VIRTUAL_BASE >> 13) << ENTRYHI_VPN2) .word ((PROM_PHYSICAL_BASE >> 12) << ENTRYLO_PFN) + (1 << ENTRYLO_G) + \ (1 << ENTRYLO_V) + (2 << ENTRYLO_C) + (1 << ENTRYLO_D) .word (((PROM_PHYSICAL_BASE+0x40000) >> 12) << ENTRYLO_PFN) + (1 << ENTRYLO_G) + \ (1 << ENTRYLO_V) + (2 << ENTRYLO_C) + (1 << ENTRYLO_D) .word (PAGEMASK_256KB << PAGEMASK_PAGEMASK) // // I/O Device space non-cached, valid, dirty // .word ((DEVICE_VIRTUAL_BASE >> 13) << ENTRYHI_VPN2) .word ((DEVICE_PHYSICAL_BASE >> 12) << ENTRYLO_PFN) + (1 << ENTRYLO_G) + \ (1 << ENTRYLO_V) + (1 << ENTRYLO_D) + (2 << ENTRYLO_C) .word (1 << ENTRYLO_G) // set global bit even if page not used .word (PAGEMASK_64KB << PAGEMASK_PAGEMASK) #ifndef DUO // // Interrupt source register space // non-cached - read/write // .word ((INTERRUPT_VIRTUAL_BASE >> 13) << ENTRYHI_VPN2) .word ((INTERRUPT_PHYSICAL_BASE >> 12) << ENTRYLO_PFN) + (1 << ENTRYLO_G) + \ (1 << ENTRYLO_D) + (1 << ENTRYLO_V) + (2 << ENTRYLO_C) .word (1 << ENTRYLO_G) // set global bit even if page not used .word (PAGEMASK_4KB << PAGEMASK_PAGEMASK) #endif // // video control 2MB non-cached read/write. // .word ((VIDEO_CONTROL_VIRTUAL_BASE >> 13) << ENTRYHI_VPN2) .word ((VIDEO_CONTROL_PHYSICAL_BASE >> 12) << ENTRYLO_PFN) + (1 << ENTRYLO_G) + \ (1 << ENTRYLO_V) + (1 << ENTRYLO_D) + (2 << ENTRYLO_C) .word (((VIDEO_CONTROL_PHYSICAL_BASE+0x100000) >> 12) << ENTRYLO_PFN) + (1 << ENTRYLO_G) + \ (1 << ENTRYLO_V) + (1 << ENTRYLO_D) + (2 << ENTRYLO_C) .word (PAGEMASK_1MB << PAGEMASK_PAGEMASK) // // extended video control 2MB non-cached read/write. // .word ((EXTENDED_VIDEO_CONTROL_VIRTUAL_BASE >> 13) << ENTRYHI_VPN2) .word ((EXTENDED_VIDEO_CONTROL_PHYSICAL_BASE >> 12) << ENTRYLO_PFN) + (1 << ENTRYLO_G) + \ (1 << ENTRYLO_V) + (1 << ENTRYLO_D) + (2 << ENTRYLO_C) .word (((EXTENDED_VIDEO_CONTROL_PHYSICAL_BASE+0x100000) >> 12) << ENTRYLO_PFN) + (1 << ENTRYLO_G) + \ (1 << ENTRYLO_V) + (1 << ENTRYLO_D) + (2 << ENTRYLO_C) .word (PAGEMASK_1MB << PAGEMASK_PAGEMASK) // // video memory space 8Mb non-cached read/write // .word ((VIDEO_MEMORY_VIRTUAL_BASE >> 13) << ENTRYHI_VPN2) .word ((VIDEO_MEMORY_PHYSICAL_BASE >> 12) << ENTRYLO_PFN) + (1 << ENTRYLO_G) + \ (1 << ENTRYLO_V) + (1 << ENTRYLO_D) + (2 << ENTRYLO_C) .word (((VIDEO_MEMORY_PHYSICAL_BASE+0x400000) >> 12) << ENTRYLO_PFN) + (1 << ENTRYLO_G) + \ (1 << ENTRYLO_V) + (1 << ENTRYLO_D) + (2 << ENTRYLO_C) .word (PAGEMASK_4MB << PAGEMASK_PAGEMASK) // // EISA I/O 16Mb non-cached read/write // EISA MEM 16Mb non-cached read/write // .word ((EISA_IO_VIRTUAL_BASE >> 13) << ENTRYHI_VPN2) .word ((EISA_IO_PHYSICAL_BASE >> 12) << ENTRYLO_PFN) + (1 << ENTRYLO_G) + \ (1 << ENTRYLO_V) + (1 << ENTRYLO_D) + (2 << ENTRYLO_C) .word ((EISA_MEMORY_PHYSICAL_BASE_PAGE) << ENTRYLO_PFN) + (1 << ENTRYLO_G) + \ (1 << ENTRYLO_V) + (1 << ENTRYLO_D) + (2 << ENTRYLO_C) .word (PAGEMASK_16MB << PAGEMASK_PAGEMASK) // // EISA I/O page 0 non-cached read/write // EISA I/O page 1 non-cached read/write // .word ((EISA_EXTERNAL_IO_VIRTUAL_BASE >> 13) << ENTRYHI_VPN2) .word ((0 >> 12) << ENTRYLO_PFN) + (1 << ENTRYLO_G) + \ (1 << ENTRYLO_V) + (1 << ENTRYLO_D) + (2 << ENTRYLO_C) .word (((EISA_IO_PHYSICAL_BASE + 1 * PAGE_SIZE) >> 12) << ENTRYLO_PFN) + (1 << ENTRYLO_G) + \ (1 << ENTRYLO_V) + (1 << ENTRYLO_D) + (2 << ENTRYLO_C) .word (PAGEMASK_4KB << PAGEMASK_PAGEMASK) // // EISA I/O page 2 non-cached read/write // EISA I/O page 3 non-cached read/write // .word (((EISA_EXTERNAL_IO_VIRTUAL_BASE + 2 * PAGE_SIZE) >> 13) << ENTRYHI_VPN2) .word (((EISA_IO_PHYSICAL_BASE + 2 * PAGE_SIZE) >> 12) << ENTRYLO_PFN) + (1 << ENTRYLO_G) + \ (1 << ENTRYLO_V) + (1 << ENTRYLO_D) + (2 << ENTRYLO_C) .word (((EISA_IO_PHYSICAL_BASE + 3 * PAGE_SIZE) >> 12) << ENTRYLO_PFN) + (1 << ENTRYLO_G) + \ (1 << ENTRYLO_V) + (1 << ENTRYLO_D) + (2 << ENTRYLO_C) .word (PAGEMASK_4KB << PAGEMASK_PAGEMASK) // // EISA I/O page 4 non-cached read/write // EISA I/O page 5 non-cached read/write // .word (((EISA_EXTERNAL_IO_VIRTUAL_BASE + 4 * PAGE_SIZE) >> 13) << ENTRYHI_VPN2) .word (((EISA_IO_PHYSICAL_BASE + 4 * PAGE_SIZE) >> 12) << ENTRYLO_PFN) + (1 << ENTRYLO_G) + \ (1 << ENTRYLO_V) + (1 << ENTRYLO_D) + (2 << ENTRYLO_C) .word (((EISA_IO_PHYSICAL_BASE + 5 * PAGE_SIZE) >> 12) << ENTRYLO_PFN) + (1 << ENTRYLO_G) + \ (1 << ENTRYLO_V) + (1 << ENTRYLO_D) + (2 << ENTRYLO_C) .word (PAGEMASK_4KB << PAGEMASK_PAGEMASK) // // EISA I/O page 6 non-cached read/write // EISA I/O page 7 non-cached read/write // .word (((EISA_EXTERNAL_IO_VIRTUAL_BASE + 6 * PAGE_SIZE) >> 13) << ENTRYHI_VPN2) .word (((EISA_IO_PHYSICAL_BASE + 6 * PAGE_SIZE) >> 12) << ENTRYLO_PFN) + (1 << ENTRYLO_G) + \ (1 << ENTRYLO_V) + (1 << ENTRYLO_D) + (2 << ENTRYLO_C) .word (((EISA_IO_PHYSICAL_BASE + 7 * PAGE_SIZE) >> 12) << ENTRYLO_PFN) + (1 << ENTRYLO_G) + \ (1 << ENTRYLO_V) + (1 << ENTRYLO_D) + (2 << ENTRYLO_C) .word (PAGEMASK_4KB << PAGEMASK_PAGEMASK) // // EISA I/O pages 8,9,a,b non-cached read/write // EISA I/O pages c,d,e,f non-cached read/write // .word (((EISA_EXTERNAL_IO_VIRTUAL_BASE + 8 * PAGE_SIZE) >> 13) << ENTRYHI_VPN2) .word (((EISA_IO_PHYSICAL_BASE + 8 * PAGE_SIZE) >> 12) << ENTRYLO_PFN) + (1 << ENTRYLO_G) + \ (1 << ENTRYLO_V) + (1 << ENTRYLO_D) + (2 << ENTRYLO_C) .word (((EISA_IO_PHYSICAL_BASE + 12 * PAGE_SIZE) >> 12) << ENTRYLO_PFN) + (1 << ENTRYLO_G) + \ (1 << ENTRYLO_V) + (1 << ENTRYLO_D) + (2 << ENTRYLO_C) .word (PAGEMASK_16KB << PAGEMASK_PAGEMASK) // // Map 64KB of memory for the video prom code&data cached. // .word ((VIDEO_PROM_CODE_VIRTUAL_BASE >> 13) << ENTRYHI_VPN2) .word ((VIDEO_PROM_CODE_PHYSICAL_BASE >> 12) << ENTRYLO_PFN) + (1 << ENTRYLO_G) + \ (1 << ENTRYLO_V) + (1 << ENTRYLO_D) + (3 << ENTRYLO_C) .word (1 << ENTRYLO_G) // set global bit even if page not used .word (PAGEMASK_64KB << PAGEMASK_PAGEMASK) // // Map 4kb of exclusive memory and 4Kb of shared // .word ((EXCLUSIVE_PAGE_VIRTUAL_BASE >> 13) << ENTRYHI_VPN2) .word ((EXCLUSIVE_PAGE_PHYSICAL_BASE >> 12) << ENTRYLO_PFN) + (1 << ENTRYLO_G) + \ (1 << ENTRYLO_V) + (1 << ENTRYLO_D) + (4 << ENTRYLO_C) .word ((SHARED_PAGE_PHYSICAL_BASE >> 12) << ENTRYLO_PFN) + (1 << ENTRYLO_G) + \ (1 << ENTRYLO_V) + (1 << ENTRYLO_D) + (5 << ENTRYLO_C) .word (PAGEMASK_4KB << PAGEMASK_PAGEMASK) // // Map PCR for kernel debugger. // .word ((PCR_VIRTUAL_BASE >> 13) << ENTRYHI_VPN2) .word (1 << ENTRYLO_G) // set global bit even if page not used .word ((PCR_PHYSICAL_BASE >> 12) << ENTRYLO_PFN) + (1 << ENTRYLO_G) + \ (1 << ENTRYLO_V) + (1 << ENTRYLO_D) + (2 << ENTRYLO_C) .word (PAGEMASK_4KB << PAGEMASK_PAGEMASK) TlbEntryEnd: .byte 0 /*++ UserTlbMissHandler(); Routine Description: This becomes the entry point of a User TLB Miss Exception. It should be located at address BFC00200 Jump to the handler in the Flash PROM Arguments: None. Return Value: None. --*/ .align 9 LEAF_ENTRY(UserTlbMiss200) li k0,EEPROM_VIRTUAL_BASE+0x200// Load address of UTBMiss handler in flash prom j k0 // Jump to Flash PROM Handler. nop .end UserTlbMiss200 /*++ Routine Description: This routine will initialize the TLB for virtual addressing. It sets the TLB according to a table of TLB entries. All other unused TLB entries will be zeroed and therefore invalidated. N.B. This routine must be loaded in the first page of the rom and must be called using BFC00XXXX addresses. Arguments: a0 - supplies the base address of the table. a1 - supplies the end address of the table a2 - supplies the index of the first tlb entry to set the table into. Return Value: None. Revision History: --*/ LEAF_ENTRY(TlbInit) // // zero the whole TLB // mtc0 zero,entrylo0 // tag data to store mtc0 zero,entrylo1 li t0,KSEG0_BASE // set entry hi mtc0 t0,entryhi mtc0 zero,pagemask move v0,zero // tlb entry index li t0,48 << INDEX_INDEX // get last index mtc0 v0,index // entry pointer tlbzeroloop: addiu v0,v0,1<