/*
 *
 * pprom  Version 0.0  28NOV83
 *
 * This is the 8540 Prom Programmer subtree.
 *
 */

/*
 * TNIX/Unix/VMS Version
 * Keyshell Version Number 1
 */

pprom
{
>
>\ksetup\e - Specify the type of Prom,
>            the starting address in 8540 program memory,
>            and the ending address in the Prom.
>\kread\e - Copy the contents of the Prom into 8540 program memory.
>
>\kprogram\e - Burn the contents of 8540 program memory into the Prom.
>
>\kcompare\e - Compare the contents of the Prom with 8540 program memory.
>
>\kstatus\e - Check the status of the Prom programmer hardware.
>
>\klistproms\e - List the Prom types supported by the current Prom programmer module.
>
>\kshow parameters\e - Shows the current values of the prom parameters.
>
>\kdone\e - Return to the previous level.
>
	msg (^Prom Programmer - Top Level.  Make sure your parameters are 'setup'.);
	f1;setup; {
		>
		>Enter the type of Prom in the Prom programmer socket.
		>
		>\klistproms\e - Find out which Prom types are supported by the Prom programmer.
		cmd (^kptype="), msg (^Enter the Prom type: %p), cmd ("), exec, next;
		f1;; hist;
		f2;; hist;
		f3;; hist;
		f4;; hist;
		f5;next; cmd, next;
		f6;listproms; call, cmd (^ptype), exec, return;
		f7;; ;
		f8;done; cmd, msg, break;
	}, {
		>
		>At which address do the data begin in 8540 program memory?
		cmd (^kpstart="), msg (^Enter the starting address in 8540 program memory: %p), cmd ("), exec, next;
		f1;; hist;
		f2;; hist;
		f3;; hist;
		f4;; hist;
		f5;next; cmd, next;
		f6;; ;
		f7;; ;
		f8;done; cmd, msg, break;
	}, {
		>
		>At which address do the data end in the Prom?
		>
		>\klistproms\e - Find out which Prom types are supported by the Prom programmer.
		>           This listing will show the ending address for each Prom type.
		cmd (^kpend="), msg (^Enter the ending address in the Prom: %p), cmd ("), exec, msg, next;
		f1;; hist;
		f2;; hist;
		f3;; hist;
		f4;; hist;
		f5;next; cmd, next;
		f6;listproms; call, cmd (^ptype), exec, return;
		f7;; ;
		f8;done; cmd, msg, break;
	}, {
		>
		>\k8 bits\e - The current emulator uses 8 bit data words.
		>
		>\k16 bits\e - The current emulator uses 16 bit data words.
		msg (^How wide are the data words?%%);
		f1;8 bits; msg, cmd (^kphalf=), exec, break;
		f2;16 bits; next;
		f3;; ;
		f4;; ;
		f5;next; cmd, msg, next (2);
		f6;; ;
		f7;manual; man (rpr);
		f8;done; cmd, msg, break;
	}, {
		>
		>Since the current emulator uses 16 bit words, and the Prom uses only
		>8 bit words, only one half of the data word can be read or programmed.
		>
		>\kupper\e - The 8 bits in each Prom byte correspond to the 8 \umost\n
		>            significant bits of the 16 bit data words in 8540 program memory.
		>
		>\klower\e - The 8 bits in each Prom byte correspond to the 8 \uleast\n
		>            significant bits of the 16 bit data words in 8540 program memory.
		msg (^Which half of the data word is used?%%), msg, break;
		f1;upper; cmd (^kphalf="-m"), exec;
		f2;lower; cmd (^kphalf="-l"), exec;
		f3;; ;
		f4;; ;
		f5;; ;
		f6;; ;
		f7;manual; man (rpr);
		f8;done; break;
	};
	f2;read; cmd (^rpr \$kphalf \$kpstart \$kptype 0 \$kpend), exec;
	f3;program; {
		>
		>\kyes\e - Checks whether the Prom is erased before programming.
		>
		>\kno\e - Does not check whether the Prom is erased.
		>            This option may be necessary when programming an EEPROM.
		cmd (^wpr ), msg (^Check whether the Prom is erased?%%);
		f1;yes; cmd (\$kphalf \$kpstart \$kptype 0 \$kpend), exec, msg, break;
		f2;no; cmd (-n \$kphalf \$kpstart \$kptype 0 \$kpend), exec, msg, break;
		f3;; ;
		f4;; ;
		f5;; ;
		f6;; ;
		f7;manual; man (wpr);
		f8;done; cmd, msg, break;
	};
	f4;compare; cmd (^cpr \$kphalf \$kpstart \$kptype 0 \$kpend), exec;
	f5;status; cmd (^8540 pstat), exec;
	f6;listproms; cmd (^ptype), exec;
	f7;show parameters;
	{
		msg(^Displaying prom programmer parameters.),
		sly(history off),
		sly(echo),
		sly(echo "Current Prom Programmer Parameters:"),
		sly(echo),
		sly(echo "Type of prom:              kptype = \$kptype"),
		sly(echo "8540 starting address:     kpstart = \$kpstart"),
		sly(echo "8540 ending address:       kpend = \$kpend"),
		sly(echo "Which half of 16 bit word: kphalf = \$kphalf"),
		sly(echo "  -m is upper, -l is lower"),
		sly(history on),
		break;
	};

	f8;done; cmd, msg, break;
}
