1*81bfa949Smckusick /* 2*81bfa949Smckusick * Copyright (c) 1980 Regents of the University of California. 3*81bfa949Smckusick * All rights reserved. The Berkeley software License Agreement 4*81bfa949Smckusick * specifies the terms and conditions for redistribution. 5*81bfa949Smckusick */ 6*81bfa949Smckusick 7*81bfa949Smckusick #ifndef lint 8*81bfa949Smckusick _sccsid:.asciz "@(#)hkboot.c 6.2 (Berkeley) 06/08/85" 9*81bfa949Smckusick #endif not lint 10*81bfa949Smckusick 114b71a845Ssam 124b71a845Ssam /* 134b71a845Ssam * RK07 1st level boot program: loads next 7.5Kbytes from 144b71a845Ssam * boot sector of file system and sets it up to run. 154b71a845Ssam * Always reads from drive 0. 164b71a845Ssam */ 174b71a845Ssam .set RELOC,0x50000 184b71a845Ssam .set BOOTSIZE,15 /* size of boot in sectors */ 194b71a845Ssam .set SID,62 /* system ID register */ 204b71a845Ssam /* UBA registers */ 214b71a845Ssam .set UBA_CNFGR,0 /* UBA configuration register */ 224b71a845Ssam .set UBA_CR,4 /* UBA control register offset */ 234b71a845Ssam .set UBA_MAP,0x800 /* UBA offset to map reg's */ 244b71a845Ssam .set UBAinit,1 /* UBA init bit in UBA control reg */ 254b71a845Ssam .set pUBIC,16 /* Unibus init complete */ 264b71a845Ssam /* RK611 registers and bits */ 274b71a845Ssam .set HK,0177440-0160000 /* address of RK611 */ 284b71a845Ssam .set HK_cs1,HK+0 /* control and status */ 294b71a845Ssam .set HK_wc,HK+2 /* word count */ 304b71a845Ssam .set HK_ba,HK+4 /* bus address */ 314b71a845Ssam .set HK_da,HK+6 /* disk address */ 324b71a845Ssam .set HK_dc,HK+020 /* desired cylinder */ 334b71a845Ssam .set HKBPSECT,512 /* bytes per sector */ 344b71a845Ssam .set HK_GO,1 /* go bit */ 354b71a845Ssam .set HK_PACK,2 /* pack acknowledge */ 364b71a845Ssam .set HK_RCOM,020 /* read command */ 374b71a845Ssam .set HK_SEL7,02000 /* select RK07 disk */ 384b71a845Ssam .set HK_pRDY,7 /* position of ready bit */ 394b71a845Ssam .set HK_pERR,15 /* position of error bit */ 404b71a845Ssam 414b71a845Ssam init: 424b71a845Ssam /* r9 UBA address */ 434b71a845Ssam /* r10 umem addr */ 444b71a845Ssam .word 0 /* entry mask for dec monitor */ 454b71a845Ssam nop;nop;nop;nop;nop;nop;nop;nop /* some no-ops for 750 boot to skip */ 464b71a845Ssam nop;nop; 474b71a845Ssam /* get cpu type and find the first uba */ 484b71a845Ssam mfpr $SID,r0 494b71a845Ssam extzv $24,$8,r0,r0 /* get cpu type */ 504b71a845Ssam ashl $2,r0,r1 514b71a845Ssam movab physUBA,r2 /* get physUBA[cpu] */ 524b71a845Ssam addl2 r1,r2 534b71a845Ssam movl (r2),r9 544b71a845Ssam movab physUMEM,r2 /* get physUMEM[cpu] */ 554b71a845Ssam addl2 r1,r2 564b71a845Ssam movl (r2),r10 574b71a845Ssam /* if 780, init uba */ 584b71a845Ssam cmpl r0,$1 594b71a845Ssam bneq 2f 604b71a845Ssam movl $UBAinit,UBA_CR(r9) 614b71a845Ssam 1: 624b71a845Ssam bbc $pUBIC,UBA_CNFGR(r9),1b 634b71a845Ssam 2: 644b71a845Ssam /* init rk611, set vv in drive 0; if any errors, give up */ 654b71a845Ssam movw $HK_SEL7+HK_GO,HK_cs1(r10) 664b71a845Ssam 1: 674b71a845Ssam movw HK_cs1(r10),r0 684b71a845Ssam bbc $HK_pRDY,r0,1b 694b71a845Ssam bbs $HK_pERR,r0,9f 704b71a845Ssam movw $HK_SEL7+HK_PACK+HK_GO,HK_cs1(r10) 714b71a845Ssam 1: 724b71a845Ssam movw HK_cs1(r10),r0 734b71a845Ssam bbc $HK_pRDY,r0,1b 744b71a845Ssam bbc $HK_pERR,r0,start 754b71a845Ssam 9: 764b71a845Ssam halt 774b71a845Ssam /* relocate to high core */ 784b71a845Ssam start: 794b71a845Ssam movl r5,r11 /* boot flags */ 804b71a845Ssam movl $RELOC,sp 814b71a845Ssam moval init,r6 824b71a845Ssam movc3 $end,(r6),(sp) 834b71a845Ssam jmp *$RELOC+start2 844b71a845Ssam /* now running relocated */ 854b71a845Ssam /* bring in the boot program */ 864b71a845Ssam .set PROGSIZE,(BOOTSIZE*HKBPSECT) 874b71a845Ssam start2: 884b71a845Ssam movw $0,HK_dc(r10) 894b71a845Ssam movw $1,HK_da(r10) 904b71a845Ssam movw $-PROGSIZE/2,HK_wc(r10) 914b71a845Ssam clrl r0 924b71a845Ssam 1: 934b71a845Ssam bisl3 $0x80000000,r0,UBA_MAP(r9) 944b71a845Ssam addl2 $4,r9 954b71a845Ssam aobleq $BOOTSIZE,r0,1b 964b71a845Ssam clrw HK_ba(r10) 974b71a845Ssam movw $HK_SEL7+HK_RCOM+HK_GO,HK_cs1(r10) 984b71a845Ssam hkrdy: 994b71a845Ssam movw HK_cs1(r10),r0 1004b71a845Ssam bbc $HK_pRDY,r0,hkrdy 1014b71a845Ssam bbs $HK_pERR,r0,hkerr 1024b71a845Ssam brw done 1034b71a845Ssam hkerr: 1044b71a845Ssam halt /* ungraceful */ 1054b71a845Ssam done: 1064b71a845Ssam movl $PROGSIZE,r3 1074b71a845Ssam clrcor: 1084b71a845Ssam clrq (r3) 1094b71a845Ssam acbl $RELOC,$8,r3,clrcor 1104b71a845Ssam /* start loaded program */ 1114b71a845Ssam movl $3,r10 /* major("/dev/hk0a") */ 1124b71a845Ssam calls $0,*$0 1134b71a845Ssam brw start2 1144b71a845Ssam physUBA: 1154b71a845Ssam .long 0 1164b71a845Ssam .long 0x20006000 /* 11/780 */ 1174b71a845Ssam .long 0xf30000 /* 11/750 */ 1184b71a845Ssam .long 0xf26000 /* 11/730 */ 1194b71a845Ssam physUMEM: 1204b71a845Ssam .long 0 1214b71a845Ssam .long 0x2013e000 /* 11/780 */ 1224b71a845Ssam .long 0xffe000 /* 11/750 */ 1234b71a845Ssam .long 0xffe000 /* 11/730 */ 1244b71a845Ssam end: 125