[comp.sys.ibm.pc] Problem setting YEAR in date cmd

kww@cbnews.ATT.COM (Kevin W. Wall) (07/25/89)

A question for all of you AT&T PC6300 gurus out there:

	A friend of mine has a dual floppy AT&T PC6300 (i.e.. 8086) which he
	has converted to a single floppy / hard disk system.  When he installed
	the hard disk, he had to upgrade the BIOS from revision 1.21 to 1.43
	(I think 1.43 is the correct #, but I'm not absolutely sure).  At
	the same time, he thought that he would install a DOS upgrade, so
	he purchased a vanilla DOS 3.2 from Microsoft (rather than buying the
	upgrade from AT&T). [He claims he got his 3.2 upgrade for $40, but
	that AT&T wanted about $120.  Hmmm...]

	When he boots up his new version of DOS (3.2) with the new BIOS, he
	is unable to set the year correctly on the 'date' command.  (He
	enters the date, but it apparently ends up stuffing random garbage
	in the 'year' portion of the date.  butHowever, the 'month' and 'day'
	portions of the date are okay.  Also, he has no trouble setting the
	time.)  Also, he says that if he boots the OLD DOS (version 2.11,
	which came with the PC), he is able to set the date correctly.  (Thus
	it isn't apparently a problem with weak batteries.)

What my friend would like is a utility to CORRECTLY set ALL portions of the
date under DOS 3.2 with BIOS rev. 1.43.  (Or short of a utility, if someone
could give him the addresses to 'tweak', or a small assembler script to do
this.)

Since my friend is not on the net and I do not often read this newsgroup,
please E-mail replies DIRECTLY to me and I'll pass it on to him.  If this
posting generates sufficient interest (i.e., several people claim they would
like to know how to do this as well), I'll summarize my findings to the net.

Also, if it makes any difference, the PC is no longer under warranty, which
he claims, makes the AT&T support hotline people reluctant to talk with him.

Thanks in advance to all of you who offer help.
-----

psfales@cbnewsc.ATT.COM (Peter Fales) (07/26/89)

In article <8567@cbnews.ATT.COM>, kww@cbnews.ATT.COM (Kevin W. Wall) writes:
> 
> A question for all of you AT&T PC6300 gurus out there:
> 
> 	A friend of mine has a dual floppy AT&T PC6300 (i.e.. 8086) which he
> 	has converted to a single floppy / hard disk system.  When he installed
> 	the hard disk, he had to upgrade the BIOS from revision 1.21 to 1.43
> 	(I think 1.43 is the correct #, but I'm not absolutely sure).  At
> 	the same time, he thought that he would install a DOS upgrade, so
> 	he purchased a vanilla DOS 3.2 from Microsoft (rather than buying the
> 	upgrade from AT&T). [He claims he got his 3.2 upgrade for $40, but
> 	that AT&T wanted about $120.  Hmmm...]

This is the second request I have seen like this in the past few days.  
It seems to be worth posting, both to solve this specific problem and as
an example for other people who would like to write a clock driver.

When I wanted to upgrade my 6300 to DOS 3.2, the AT&T version was not
yet available, and I ran into this same problem.  I ended up writing
my own installable clock device driver.

Since that time I have seen similar drivers on BBS systems, but if
you can't find anything better, here is mine:

Just put 

DEVICE=clk63.sys 

in your config.sys file

Peter Fales			AT&T, Room 5B-420
				2000 N. Naperville Rd.
UUCP:	...att!peter.fales	Naperville, IL 60566
Domain: peter.fales@att.com	work:	(312) 979-8031

---------------------------cut here-------------------------------------------
	title	dd
	page	58,132
;******************************************************************************
;
;		PROLOG
;
;	THIS IS AN INSTALLABLE DEVICE DRIVER FOR A CLOCK DRIVER
;	FOR THE AT&T PC-6300.  
;
;	Written by Peter Fales  att!peter.fales   04/27/87
;	2000 N Naperville Rd, 5B-420, Naperville, IL  60566
;
;	Build with:
;
;		masm clk63;
;		link clk63;
;		exe2bin clk63.exe clk63.sys
;
;******************************************************************************

CSEG	SEGMENT	PARA	PUBLIC	'CODE'

;******************************************************************************
;
;		MACROS
;
;******************************************************************************

STATUS	MACRO	STATE, ERR, RC

	IFIDN	<STATE>, <DONE>
		OR	ES:WORD PTR SRH_STA_FLD[BX], 0100H
	ENDIF

	IFIDN	<STATE>, <BUSY>
		OR	ES:WORD PTR SRH_STA_FLD[BX], 0200H
	ENDIF

	IFIDN	<ERR>, <ERROR>
		OR	ES:WORD PTR SRH_STA_FLD[BX], 8000H
	ENDIF

	IFNB	<RC>
		OR	ES:WORD PTR SRH_STA_FLD[BX], RC
	ENDIF

ENDM

;******************************************************************************
;
;	READ/WRITE
;
;******************************************************************************

SRH		EQU	0		; STATIC REQUREST HEADER START
SRH_LEN		EQU	13		; STATIC REQUREST HEADER LENGTH
SRH_LEN_FLD	EQU	SRH		; STATIC REQUREST HEADER LENGTH FIELD
SRH_UCD_FLD	EQU	SRH+1		; STATIC REQUREST HEADER UNIT CODE FIELD
SRH_CCD_FLD	EQU	SRH+2		; STATIC REQUREST HEADER COMMAND CODE FIELD
SRH_STA_FLD	EQU	SRH+3		; STATIC REQUREST HEADER STATUS FIELD
SRH_RES_FLD	EQU	SRH+5		; STATIC REQUREST HEADER RESERVED AREA FIELD
MD		EQU	SRH+SRH_LEN	; MEDIA DESCRIPTOR BYTE
MD_LEN		EQU	1		; MEDIA DESCRIPTOR BYTE LENGTH
DTA		EQU	MD+MD_LEN	; DISK TRANSFER ADDRESS
DTA_LEN		EQU	4		; DTA LENGTH
COUNT		EQU	DTA+DTA_LEN	; BYTE/SECTOR COUNT
COUNT_LEN	EQU	2		; BYTE/SECTOR COUNT LENGTH
SSN		EQU	COUNT+COUNT_LEN	; STARTING SECTOR NUMBER
SSN_LEN		EQU	2		; STARTING SECTOR NUMBER LENGTH

;******************************************************************************
;
;		INIT
;
;******************************************************************************

UNITS		EQU	SRH+SRH_LEN
UNITS_LEN	EQU	1
BR_ADDR_0	EQU	UNITS+UNITS_LEN
BR_ADDR_1	EQU	BR_ADDR_0+2
BR_ADDR_LEN	EQU	4
BPB_PTR_OFF	EQU	BR_ADDR_0+BR_ADDR_LEN
BPB_PTR_SEG	EQU	BPB_PTR_OFF+2


;******************************************************************************
;
;			BEGIN CLOCK DRIVER PROGRAM
;
;******************************************************************************

VDSK	PROC	FAR

	ASSUME	CS:CSEG, ES:CSEG, DS:CSEG

BEGIN:

START	EQU	$

;******************************************************************************
;
;		SPECIAL DEVICE HEADER
;
;******************************************************************************

NEXT_DEV	DD	-1		; POINTER TO NEXT DEVICE
ATTRIBUTE	DW	8008H		; CHARACTER(CLOCK) DEVICE
STRATEGY	DW	DEV_STRATEGY	; POINTER TO DEVICE STRATEGY
INTERRUPT	DW	DEV_INT		; POINTER TO DEVICE INTERRUPT HANDLER
DEV_NAME	DB	'CLOCK$  '
RH_OFF		DW	?		; REQUEST HEADER OFFSET
RH_SEG		DW	?		; REQUEST HEADER SEGMENT

WELCOME		DB	13,10
		DB	'Installed Clock Driver for MS-DOS on PC6300'
		DB	'    Peter Fales - 04/27/87'
		DB	13,10,'$'

;******************************************************************************
;
;		FUNCTION TABLE
;
;******************************************************************************

FUNTAB		LABEL	BYTE

		DW	INIT		; INITIALIZATION
		DW	MEDIA_CHECK	; MEDIA CHECK (BLOCK ONLY)
		DW	BUILD_BPB	; BUILD BPB
		DW	IOCTL_IN	; IOCTL INPUT
		DW	INPUT		; INPUT (READ)
		DW	MD_INPUT	; NON DESTRUCTIVE INPUT NO WAIT (CHAR ONLY)
		DW	IN_STAT		; INPUT STATUS (CHAR ONLY)
		DW	IN_FLUSH	; INPUT FLUSH (CHAR ONLY)
		DW	OUTPUT		; OUTPUT (WRITE)
		DW	OUT_VERIFY	; OUTPUT (WRITE) WITH VERIFY
		DW	OUT_STAT	; OUTPUT STATUS (CHAR ONLY)
		DW	OUT_FLUSH	; OUTPUT FLUSH  (CHAR ONLY)
		DW	IOCTL_OUT	; IOCTL OUTPUT



;******************************************************************************
;
;		DEVICE STRATEGY
;
;******************************************************************************

DEV_STRATEGY:

	MOV	CS:RH_SEG, ES		; SAVE SEGMENT OF REQUEST HEADER POINTER
	MOV	CS:RH_OFF, BX		; SAVE OFFSET OF REQUEST HEADER POINTER
	RET

;******************************************************************************
;
;		DEVICE INTERRUPT HANDLER
;
;******************************************************************************

DEV_INT:

;******************************************************************************
;
;		PRESERVE MACHINE STATE ON ENTRY
;
;******************************************************************************

	CLD
	PUSH	BX
	PUSH	DS
	PUSH	ES
	PUSH	AX
	PUSH	CX
	PUSH	DX
	PUSH	DI
	PUSH	SI

;******************************************************************************
;
;		DO THE BRANCH ACCORDING TO THE FUNCTION PASSED
;
;******************************************************************************

	PUSH	CS
	POP	DS

	MOV	AL, ES:[BX]+2		; GET FUNCTION BYTE
	ROL	AL, 1			; GET OFFSET INTO TABLE
	LEA	DI, FUNTAB		; GET ADDRESS OF FUNCTION TABLE
	XOR	AH, AH
	ADD	DI, AX
	JMP	WORD PTR[DI]

;******************************************************************************
;
;		INIT
;
;******************************************************************************

INIT:
	PUSH	CS
	POP	DX			; CURRENT CS TO DX
	LEA	AX, WORD PTR VDISK	; GET ADDRESS OF END OF DRIVER
	MOV	CL, 4
	ROR	AX, CL			; DIVIDE BY 16 (PARAGRAPH FORM)
	ADD	DX, AX			; ADD TO CURRENT CS VALUE
	MOV	AX,0
	MOV	ES:BR_ADDR_0[BX], AX	;BREAK OFFSET
	MOV	ES:BR_ADDR_1[BX], DX	; MAKE THAT THE BREAK ADDRESS SEG
	MOV	DX,OFFSET WELCOME	;Print Welcome message
	MOV	AH,9
	INT	21H

	MOV	ES, RH_SEG		; RESTORE ES:BX TO REQUEST HEADER
	MOV	BX, RH_OFF

	STATUS	DONE, NOERROR, 0	; SET STATUS WORD (DONE, NOERROR)
	JMP	EXIT

;******************************************************************************
;
;		THE FOLLOWING ENTRIES ARE NOT SUPPORTED BY THIS DEVICE
;
;******************************************************************************

MD_INPUT:
IOCTL_IN:
IOCTL_OUT:
MEDIA_CHECK:				; MEDIA CHECK (BLOCK ONLY)
BUILD_BPB:
IN_STAT:
IN_FLUSH:
OUT_STAT:
OUT_VERIFY:
OUT_FLUSH:
	STATUS	DONE, NOERROR, 0	; TURN ON THE DONE BIT
	JMP	EXIT



;******************************************************************************
;
;		CLOCK READ
;
;******************************************************************************

INPUT:
	PUSH	ES			;Save RH
	PUSH	BX
	
	MOV	AX,ES:DTA+2[BX]		;Put DTA in DS:BX
	MOV	DS,AX
	MOV	BX,ES:DTA[BX]

	PUSH	DS			;Save DTA
	PUSH	BX
	MOV	AH,0FEH			;BIOS Call to read time
	INT	1AH
	MOV	AX,BX			;Save DAY value

	POP	BX
	POP	DS			;Restore DTA

					;A Day count of zero is for 1-1-84
					;So add in 366+365*3
	ADD	AX,1461
	MOV	WORD PTR[BX],AX		;Day
	MOV	BYTE PTR[BX+2],CL	;Minutes
	MOV	BYTE PTR[BX+3],CH	;Hours
	MOV	BYTE PTR[BX+4],DL	;Hundredths of Seconds
	MOV	BYTE PTR[BX+5],DH	;Seconds

	POP	BX			;Restore RH
	POP	ES

	STATUS	DONE, NOERROR, 0	; TURN ON THE DONE BIT
	JMP	EXIT


;******************************************************************************
;
;		CLOCK WRITE
;
;******************************************************************************

OUTPUT:					; OUTPUT (WRITE)
	
	PUSH	ES
	PUSH	BX
	
	MOV	AX,ES:DTA+2[BX]		;Set DS:BX to point to DTA
	MOV	DS,AX
	MOV	BX,ES:DTA[BX]

	MOV	AX,WORD PTR[BX]		;Day (Temporary)
	SUB	AX,1461			;We store Days as offset from
					;1/1/84, DOS uses 1/1/80
	MOV	CL,BYTE PTR[BX+2] 	;Minutes
	MOV	CH,BYTE PTR[BX+3]	;Hours
	MOV	BX,AX			;Day

	MOV	AH,0FFH			;BIOS Call to set time
	INT	1AH

	POP	BX
	POP	ES

	STATUS	DONE, NOERROR, 0	; TURN ON THE DONE BIT
	JMP	EXIT

;******************************************************************************
;
;		COMMON EXIT
;
;******************************************************************************

EXIT:
	POP	SI
	POP	DI
	POP	DX
	POP	CX
	POP	AX
	POP	ES
	POP	DS
	POP	BX
	RET

;******************************************************************************

E_O_P:

;******************************************************************************
;
;		MACRO TO ALIGN THE VIRTUAL DISK ON A PARAGRAPH BOUNDARY
;
;******************************************************************************

if ($-START) MOD 16

	ORG	($-START)+16-(($-START) MOD 16)

endif

VDISK	EQU	$

VDSK	ENDP

;******************************************************************************

CSEG	ENDS

	END	BEGIN
-- 
Peter Fales			AT&T, Room 5B-420
				2000 N. Naperville Rd.
UUCP:	...att!peter.fales	Naperville, IL 60566
Domain: peter.fales@att.com	work:	(312) 979-8031