$title(Bootstrap First Stage) $genonly ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ; TITLE: bs1.inc ; Bootstrap first stage code and configuration macros ; ; DATE: 6-28-80 ; ; ABSTRACT: Include file to generate bootstrap first stage. ; Generates code for setup and to call options, ; and generates device table. ; ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; stacksize equ 192 ; code segment public 'CODE' code ends boot segment public 'BOOT' second_stage label far boot ends stack segment stack 'STACK' db stacksize dup (?) stack ends data segment public 'DATA' data ends assume cs:code, ss:stack, ds:data code segment ; %SET(is_cico, 0) %*DEFINE(cico) ( %SET(is_cico, -1) ) %DEFINE(cpu_type) (8086) %*DEFINE(cpu(ctype)) ( %DEFINE(cpu_type) (%ctype) ) ; ; %' TRIM and ARG are utility macros %' %' TRIM(a) - returns the input parameter trimmed of leading and %' trailing blanks. %*DEFINE(TRIM(a)) LOCAL x y (%MATCH( x y)(%a)%x)%' %' %' ARG - gets the next comma-delimited arg from variable named TAIL, %' stripped and trimmed. Any macro that has a valid type of NONE %' uses this macro so that the other parameters are not needed. %*DEFINE(ARG) LOCAL a (%MATCH(a,tail)(%tail)%TRIM(%a))%' %' %' TITLE: iAPX_186_init %' INPUTS: RELO - a boolean for whether to put the 186 PIC into RMX mode %' and the register values for UMCS,LMCS,MPCS,MMCS,and PACS %' OUTPUTS: public variables for the chip select registers %' ABSTRACT: This macro sets up the public variables for programming %' the 5 iAPX_186 chip select registers. Assumes Relo Reg will %' not be moved. %' *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* %*DEFINE(iAPX_186_INIT(parameters))(%DEFINE(tail)(%parameters)%' %' %IF ((%NES(%cpu_type,80186)) AND (%NES(%cpu_type,80188))) THEN (%' ERROR -- CPU type is not 80186 or 80188 ) ELSE (%' ; ; This procedure sets up the chip select registers for ; the 80186/8. It must be executed before the execution leaves ; the top 1K of memory. ; ; *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* NULL EQU 0 boot_186_init segment at 0fff0h assume cs:boot_186_init,ds:boot_186_init public boot_186 boot_186 proc far cli mov bx,boot_186_init mov es,bx ; the segment value is still in bx mov bx,offset init186_table ; point to the init table init_loop: mov dx,es:[bx] ; set up the port cmp dx,NULL ; a null port will terminate the loop. je init_finished mov ax,es:[bx+2] ; get the programming value out dx,ax ; initialize the register add bx,4 ; point to the next table entry. jmp init_loop ; do the next output init_finished: jmp firststage ; enter the monitor boot_186 endp init186_table: %DEFINE(rmx_v)(%ARG)%' %IF ((%EQS(%rmx_v,Y)) OR (%EQS(%rmx_v,y)) OR (%EQS(%rmx_v,YES)) OR (%EQS(%rmx_v,yes)) ) THEN (%' DW 0fffeh DW 40ffh )FI%' %DEFINE(umcs_v)(%ARG)%' %IF ((%NES(%umcs_v,NONE)) AND (%NES(%umcs_v,none))) THEN (%' DW 0ffa0h DW %umcs_v )FI%' %DEFINE(lmcs_v)(%ARG)%' %IF ((%NES(%lmcs_v,NONE)) AND (%NES(%lmcs_v,none))) THEN (%' DW 0ffa2h DW %lmcs_v )FI%' %DEFINE(mpcs_v)(%ARG)%' %IF ((%EQS(%mpcs_v,NONE)) OR (%EQS(%mpcs_v,none))) THEN (%' %' '%SET(mpcs_v,0)%' )FI%' %DEFINE(mmcs_v)(%ARG)%' %IF ((%NES(%mmcs_v,NONE)) AND (%NES(%mmcs_v,none))) THEN (%' %' '%IF (%EQS(%mpcs_v,0)) THEN (%' ERROR -- MPCS register must be initialized to program the MMCS register %' ') ELSE (%' DW 0ffa8h DW %mpcs_v DW 0ffa6h DW %mmcs_v )FI )FI%' %DEFINE(pacs_v)(%ARG)%' %IF ((%NES(%pacs_v,NONE)) AND (%NES(%pacs_v,none))) THEN (%' %' '%IF (%EQS(%mpcs_v,0)) THEN (%' ERROR -- MPCS register must be initialized to program the PACS register %' ') ELSE (%' DW 0ffa8h DW %mpcs_v DW 0ffa4h DW %pacs_v )FI )FI )FI%' DW 0 DW 0 boot_186_init ends assume cs:code, ss:stack, ds:data %' )%' END OF THE iAPX_186_INIT MACRO. bootstrap_entry label far public bootstrap_entry pop ax ; return address pop ax pop bx pop es jmp setup_reg ; get ptr to cmd line bootstrap_begin label far public bootstrap_begin ; entry for SCT mov bx,ax mov ax,ds mov es,ax setup_reg: mov ss,cs:stackseg mov sp,stacksize mov ds,cs:dataseg jmp got_name firststage label far ; first stage starts here public firststage ; ; cli ; disable interrupts jmp short setup db 43H,6FH,70H,79H,72H,69H,67H,68H,74H,' 1980, 1981, 1982, 1983, 1984 Intel Corporation ' db 'program_version_number=V6.0program_name=iAPX 86, 88 Bootstrap Loader',0 setup: mov ss, cs: stackseg ; load stack segment mov sp, stacksize ; load stack pointer mov ds, cs: dataseg ; load data segment jmp startup %SET(is_loadfile, 0) %*DEFINE(loadfile) ( %SET(is_loadfile, -1) ) %SET(is_console, 0) %*DEFINE(console) ( %SET(is_console, -1) ) %SET(is_manual, 0) %*DEFINE(manual) ( %SET(is_manual, -1) %SET(is_console, -1) %SET(device_select, -1) ) %SET(is_auto, 0) %*DEFINE(auto) ( %SET(is_auto, -1) %SET(device_select, -1) ) %DEFINE(default_fn) ('/system/rmx86',0) %*DEFINE(defaultfile(fn)) ( %DEFINE(default_fn) (%fn, 0) ) %DEFINE(times) (0) %*DEFINE(retries(r)) ( %DEFINE(times) (%r+1) ) %SET(device_select, 0) %SET(first_device, -1) %*DEFINE(device(name, unit, device_init, device_read)) ( $include(:f1:bs1dev.inc) ) %*DEFINE(end) ( %IF (%device_select) THEN ( db 0FFH ; terminate table ) FI default_file label byte public default_file db %default_fn %IF (%is_console) THEN ( bs_echo label byte ; Echo for Delete public bs_echo ; db bs_echo_end-bs_echo-1 ; db 08H, 020H, 08H ; bs_echo_end label byte ; ; can_echo label byte ; Echo for Cancel (CNTL/X) public can_echo ; db can_echo_end-can_echo-1 ; db '#', 0DH, 0AH ; can_echo_end label byte ; ; prompt label byte ; Prompt character public prompt ; db '*' ; ) FI code ends ; a start adress of 'firststage' for 8086s or ; 'boot_186' for 80186s must be supplied with loc86 %' *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* %' INPUTS: NONE %' OUTPUTS: BDEV_INIT_LEN - number of device initialization outputs %' BDEV_INIT_STRUC_LEN - the length of the device init structure %' ABSTRACT: %' This macro declares four publics needed for device and serial %' channel init. %' *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* %IF (%is_cico) THEN ( $eject boot_dev_init segment bdev_init_len DW %dev_cnt bdev_init_struc_len DW size dev_init boot_dev_init ends ) FI end)