19501c948Smckusick /* 2942a3603Smckusick * Copyright (c) 1980, 1986 Regents of the University of California. 39501c948Smckusick * All rights reserved. The Berkeley software License Agreement 49501c948Smckusick * specifies the terms and conditions for redistribution. 59501c948Smckusick */ 69501c948Smckusick 7*785337c1Skarels /* "@(#)rlboot.c 7.3 (Berkeley) 02/21/87" */ 88f26171aSkarels #include <sys/disklabel.h> 9d5f12ee2Skarels 10d5f12ee2Skarels .set MAJOR,14 /* major("/dev/rl0a") */ 1186bdc93fSsam 1286bdc93fSsam /* 130e27f701Ssam * RL02 1st level boot program: loads next 7.5Kbytes from 140e27f701Ssam * boot sector of file system and sets it up to run. 1586bdc93fSsam */ 160e27f701Ssam .set BOOTSIZE,15 /* 15 ``sectors'' */ 1786bdc93fSsam .set RELOC,0x50000 1886bdc93fSsam /* UBA registers */ 1986bdc93fSsam .set UBA_CNFGR,0 /* UBA configuration register */ 2086bdc93fSsam .set UBA_CR,4 /* UBA control register offset */ 2186bdc93fSsam .set UBA_MAP,0x800 /* UBA offset to map reg's */ 2286bdc93fSsam /* RL11 registers and bits */ 2386bdc93fSsam .set HL,0174400-0160000 /* address of RL11 */ 240e27f701Ssam .set HLBPSECT,512 /* sector size in bytes (kludge) */ 2586bdc93fSsam .set HL_cs,HL+0 /* control and status */ 2686bdc93fSsam .set HL_ba,HL+2 /* bus address */ 2786bdc93fSsam .set HL_da,HL+4 /* disk address */ 280e27f701Ssam .set HL_wc,HL+6 /* word count */ 29d5f12ee2Skarels .set HL_RDY,0200 /* READY */ 3086bdc93fSsam .set HL_RCOM,014 /* read command */ 3186bdc93fSsam .set HL_SEEK,06 /* seek */ 3286bdc93fSsam .set HL_RESET,013 /* reset drive */ 330e27f701Ssam .set HL_GSTAT,04 /* get status command */ 3486bdc93fSsam .set HL_pRDY,7 /* position of ready bit */ 3586bdc93fSsam .set HL_pERR,15 /* position of error bit */ 3686bdc93fSsam 3786bdc93fSsam init: 3886bdc93fSsam /* r9 UBA address */ 39d5f12ee2Skarels /* r8 RL addr */ 4086bdc93fSsam .word 0 /* entry mask for dec monitor */ 4186bdc93fSsam nop;nop;nop;nop;nop;nop;nop;nop /* some no-ops for 750 boot to skip */ 4286bdc93fSsam nop;nop; 43*785337c1Skarels cvtbl $MAJOR,r10 /* major("/dev/xx0a") */ 44d5f12ee2Skarels extzv $18,$1,r1,r9 /* get UBA number from R1 */ 45d5f12ee2Skarels xorb2 $0x01,r9 /* complement bit */ 46d5f12ee2Skarels insv r9,$24,$8,r10 /* set UBA number */ 47d5f12ee2Skarels insv r3,$16,$8,r10 /* drive number */ 48d5f12ee2Skarels extzv $12,$4,r5,r4 /* get partition from r5 */ 49d5f12ee2Skarels bicw2 $0xf000,r5 /* remove from r5 */ 50d5f12ee2Skarels insv r4,$8,$8,r10 /* set partition */ 51d5f12ee2Skarels movl r5,r11 /* boot flags */ 52*785337c1Skarels 53*785337c1Skarels movl r2,r8 /* boot device CSR */ 548f26171aSkarels brw start0 558f26171aSkarels 568f26171aSkarels /* 578f26171aSkarels * Leave space for pack label. 588f26171aSkarels */ 598f26171aSkarels pad: 608f26171aSkarels .space LABELOFFSET - (pad - init) 618f26171aSkarels packlabel: 628f26171aSkarels .space d_end_ 638f26171aSkarels 648f26171aSkarels start0: 65d5f12ee2Skarels movl physUBA[r9],r9 /* UNIBUS adaptor address */ 66*785337c1Skarels ashl $8,r3,r7 /* unit number, shifted for HL_cs */ 67d5f12ee2Skarels 68d5f12ee2Skarels /* init rl11, and drive, don't check for any errors now */ 69d5f12ee2Skarels movw $HL_RESET,HL_da(r8) 70d5f12ee2Skarels bisw3 r7,$HL_GSTAT,HL_cs(r8) 7186bdc93fSsam /* relocate to high core */ 7286bdc93fSsam start: 7386bdc93fSsam movl $RELOC,sp 7486bdc93fSsam moval init,r6 7586bdc93fSsam movc3 $end,(r6),(sp) 7686bdc93fSsam jmp *$RELOC+start2 7786bdc93fSsam /* now running relocated */ 780e27f701Ssam /* read in the boot program */ 790e27f701Ssam .set PROGSIZE,(BOOTSIZE*HLBPSECT) 8086bdc93fSsam start2: 81d5f12ee2Skarels movw $1,HL_da(r8) /* seek to cylinder 0 */ 82d5f12ee2Skarels bisw3 r7,$HL_SEEK,HL_cs(r8) 830e27f701Ssam 1: 84d5f12ee2Skarels movw HL_cs(r8),r0 850e27f701Ssam bbc $HL_pRDY,r0,1b 860e27f701Ssam bbs $HL_pERR,r0,hlerr 87261cc7ecSsam /* Rl has 256 byte sectors */ 88d5f12ee2Skarels movw $2,HL_da(r8) /* read program */ 89d5f12ee2Skarels movw $-PROGSIZE/2,HL_wc(r8) 900e27f701Ssam clrl r0 910e27f701Ssam 1: 920e27f701Ssam bisl3 $0x80000000,r0,UBA_MAP(r9) 930e27f701Ssam addl2 $4,r9 940e27f701Ssam aobleq $BOOTSIZE,r0,1b 95d5f12ee2Skarels clrw HL_ba(r8) 96d5f12ee2Skarels bisw3 r7,$HL_RCOM,HL_cs(r8) 970e27f701Ssam 1: 98d5f12ee2Skarels movw HL_cs(r8),r0 990e27f701Ssam bbc $HL_pRDY,r0,1b 100d5f12ee2Skarels bbc $HL_pERR,r0,done 1010e27f701Ssam hlerr: 1020e27f701Ssam halt /* ungraceful */ 1030e27f701Ssam done: 1040e27f701Ssam movl $PROGSIZE,r3 10586bdc93fSsam clrcor: 10686bdc93fSsam clrq (r3) 10786bdc93fSsam acbl $RELOC,$8,r3,clrcor 10886bdc93fSsam /* run loaded program */ 10986bdc93fSsam calls $0,*$0 11086bdc93fSsam brw start2 11186bdc93fSsam physUBA: 112d5f12ee2Skarels .long 0xf30000 /* uba0 */ 113d5f12ee2Skarels .long 0xf32000 /* uba1 */ 11486bdc93fSsam end: 115