See history.txt for changes. Bug fixes and HMA support are the main ones.

git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@167 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
Bart Oldeman 2001-03-21 02:56:26 +00:00
parent 513094d9fe
commit f2184025da
50 changed files with 2394 additions and 1109 deletions

View File

@ -1,3 +1,28 @@
2001 Mar 21 - Build 2022
-------- Bart Oldeman (bart.oldeman@bristol.ac.uk)
+ Clean A lot of space savings by Tom Ehlert, merely because Turbo C 2.01 does not
do it. And several more complicated situations as well, like coding some
string functions in assembly (asmsupt.asm).
+ Add Tom Ehlert: support for DOS=HIGH. Now most of the kernel can be loaded into
the HMA. This required a lot of segmentation changes. Let's hope the best
of it. Support for device drivers with multiple devices.
+ Fixes From Tom Ehlert:
task.c bug fix (image_size is in bytes)
dosfns.c change dir to E:\FREEDOS\*.PRJ fix
fcbfns.c fixes.
break.c Ctrl-C Ctrl-C -> crash temporary fix.
+ Fixes From Bart:
Let UMBs work again after HMA changes.
Be able to compile sys.com again. Is now really a .exe file but still masks
as .com in the hope that we can make it a real .com again.
DeviceHigh loads low if there are not enough UMB's available.
Fixed another redirector problem.
+ Update Optimized asmsupt.asm a bit with help of the glibc 2.2 source.
+ Fixes Tom Ehlert and Brian Reifsnyder: fix partition detection in dsk.c +
other bug fixes (also: floppy.asm).
+ Update Tom Ehlert optimized blockio.c.
+ Fixes a few small ones from Tom I forgot.
2001 Mar 08 - Build 2022
-------- Bart Oldeman (bart.oldeman@bristol.ac.uk)
+ Fixes MCB chain corruption fix (thanks Tom Ehlert and Martin Stromberg)

View File

@ -30,6 +30,9 @@
; $Header$
;
; $Log$
; Revision 1.4 2001/03/21 02:56:25 bartoldeman
; See history.txt for changes. Bug fixes and HMA support are the main ones.
;
; Revision 1.3 2000/05/25 20:56:19 jimtabor
; Fixed project history
;
@ -66,20 +69,20 @@
;Initial revision.
;
group TGROUP _TEXT
group DGROUP _DATA
%include "..\kernel\segs.inc"
segment _DATA align=2 class=DATA
extern last:wrt DGROUP
extern __bssend:wrt DGROUP
segment _TEXT class=CODE
segment HMA_TEXT
global _device_end
_device_end:
push bp
mov bp,sp
mov ax,last
mov ax,__bssend
mov dx,DGROUP
pop bp
ret

View File

@ -30,6 +30,9 @@
; $Id$
;
; $Log$
; Revision 1.4 2001/03/21 02:56:25 bartoldeman
; See history.txt for changes. Bug fixes and HMA support are the main ones.
;
; Revision 1.3 2000/05/25 20:56:19 jimtabor
; Fixed project history
;
@ -77,9 +80,9 @@
;Initial revision.
;
group TGROUP _TEXT
%include "..\kernel\segs.inc"
segment _TEXT class=CODE
segment HMA_TEXT
;
;
@ -211,37 +214,6 @@ _fl_rd_status:
;
; Returns 0 if successful, error code otherwise.
;
global _fl_read
_fl_read:
push bp ; C entry
mov bp,sp
mov dl,[bp+4] ; get the drive (if or'ed 80h its
; hard drive.
mov dh,[bp+6] ; get the head number
mov ch,[bp+8] ; cylinder number (lo only if hard)
mov al,[bp+9h] ; get the top of cylinder
xor ah,ah
mov cl,6 ; form top of cylinder for sector
shl ax,cl
mov cl,[bp+0Ah] ; sector number
and cl,03fh ; mask to sector field bits 5-0
or cl,al ; or in bits 7-6
mov al,[bp+0Ch]
les bx,[bp+0Eh] ; Load 32 bit buffer ptr
mov ah,2
int 13h ; read sectors to memory es:bx
mov al,ah
jc fl_rd1 ; error, return error code
xor al,al ; Zero transfer count
fl_rd1:
xor ah,ah ; force into < 255 count
pop bp
ret
;
; Write Sectors
;
@ -251,60 +223,59 @@ fl_rd1:
;
; Returns 0 if successful, error code otherwise.
;
global _fl_read
_fl_read:
mov ah,2 ; cmd READ
jmp short fl_common
global _fl_verify
_fl_verify:
mov ah,4 ; cmd verify
jmp short fl_common
global _fl_write
_fl_write:
mov ah,3 ; cmd WRITE
fl_common:
push bp ; C entry
mov bp,sp
mov dl,[bp+4] ; get the drive (if or'ed 80h its
; hard drive.
mov dh,[bp+6] ; get the head number
mov ch,[bp+8] ; cylinder number (lo only if hard)
mov al,[bp+9h] ; get the top of cylinder
xor ah,ah
mov cl,6 ; form top of cylinder for sector
shl ax,cl
mov bx,[bp+8] ; cylinder number (lo only if hard)
mov al,1 ; this should be an error code
cmp bx,3ffh ; this code can't write above 3ff=1023
ja fl_error
mov ch,bl ; low 8 bits of cyl number
xor bl,bl ; extract bits 8+9 to cl
shr bx,1
shr bx,1
mov cl,[bp+0Ah] ; sector number
and cl,03fh ; mask to sector field bits 5-0
or cl,al ; or in bits 7-6
mov al,[bp+0Ch]
or cl,bl ; or in bits 7-6
mov al,[bp+0Ch] ; count to read/write
les bx,[bp+0Eh] ; Load 32 bit buffer ptr
mov ah,3
int 13h ; write sectors from mem es:bx
mov al,ah
jc fl_wr1 ; error, return error code
xor al,al ; Zero transfer count
fl_wr1:
fl_error:
xor ah,ah ; force into < 255 count
pop bp
ret
;
; SUBROUTINE
;
global _fl_verify
_fl_verify:
push bp
mov bp,sp
mov dl,[bp+4]
mov dh,[bp+6]
mov ch,[bp+8]
mov cl,[bp+0Ah]
mov al,[bp+0Ch]
mov ah,4
int 13h ; Disk dl=drive a: ah=func 04h
; verify sectors with mem es:bx
mov al,ah
jc fl_ver1 ; Jump if carry Set
xor al,al ; Zero register
fl_ver1:
xor ah,ah ; Zero register
pop bp
ret
global _fl_format

View File

@ -30,6 +30,9 @@
; $Header$
;
; $Log$
; Revision 1.4 2001/03/21 02:56:25 bartoldeman
; See history.txt for changes. Bug fixes and HMA support are the main ones.
;
; Revision 1.3 2000/05/25 20:56:19 jimtabor
; Fixed project history
;
@ -66,9 +69,9 @@
;Initial revision.
;
group TGROUP _TEXT
%include "..\kernel\segs.inc"
segment _TEXT class=CODE
segment HMA_TEXT
global _getvec
_getvec:

View File

@ -30,6 +30,9 @@
; $Header$
;
; $Log$
; Revision 1.4 2001/03/21 02:56:25 bartoldeman
; See history.txt for changes. Bug fixes and HMA support are the main ones.
;
; Revision 1.3 2000/05/25 20:56:19 jimtabor
; Fixed project history
;
@ -69,9 +72,10 @@
;Initial revision.
;
group TGROUP _TEXT
%include "..\kernel\segs.inc"
segment _TEXT class=CODE
segment HMA_TEXT
;
; BOOL ReadPCClock(Ticks)

View File

@ -30,6 +30,9 @@
; $Header$
;
; $Log$
; Revision 1.4 2001/03/21 02:56:25 bartoldeman
; See history.txt for changes. Bug fixes and HMA support are the main ones.
;
; Revision 1.3 2000/05/25 20:56:19 jimtabor
; Fixed project history
;
@ -66,10 +69,9 @@
;Initial revision.
;
group TGROUP _TEXT
group DGROUP _BSS
%include "..\kernel\segs.inc"
segment _TEXT class=CODE
segment HMA_TEXT
;
; void tmark()

View File

@ -30,6 +30,9 @@
; $Header$
;
; $Log$
; Revision 1.4 2001/03/21 02:56:25 bartoldeman
; See history.txt for changes. Bug fixes and HMA support are the main ones.
;
; Revision 1.3 2000/05/25 20:56:19 jimtabor
; Fixed project history
;
@ -66,9 +69,9 @@
;Initial revision.
;
group TGROUP _TEXT
%include "..\kernel\segs.inc"
segment _TEXT class=CODE
segment HMA_TEXT
;
; VOID WriteATClock(bcdDays, bcdHours, bcdMinutes, bcdSeconds)

View File

@ -30,6 +30,9 @@
; $Header$
;
; $Log$
; Revision 1.4 2001/03/21 02:56:25 bartoldeman
; See history.txt for changes. Bug fixes and HMA support are the main ones.
;
; Revision 1.3 2000/05/25 20:56:19 jimtabor
; Fixed project history
;
@ -65,10 +68,10 @@
; Rev 1.0 02 Jul 1995 8:01:30 patv
;Initial revision.
;
%include "..\kernel\segs.inc"
group TGROUP _TEXT
segment HMA_TEXT
segment _TEXT class=CODE
;
; VOID WritePCClock(Ticks)

View File

@ -36,8 +36,8 @@ static char *portab_hRcsId = "$Id$";
/*
* $Log$
* Revision 1.6 2001/03/19 05:08:53 bartoldeman
* New macros from Tom Ehlert to save even more bytes.
* Revision 1.7 2001/03/21 02:56:25 bartoldeman
* See history.txt for changes. Bug fixes and HMA support are the main ones.
*
* Revision 1.5 2001/03/08 21:15:00 bartoldeman
* Fixes for MK_FP and friends from Tom Ehlert; reduces kernel by 1.5k.

View File

@ -32,9 +32,9 @@ static BYTE *date_hRcsId = "$Id$";
#endif
#endif
/* This Kernel is at a min Dos Ver. 4.00 */
/* This Kernel is at a min Dos Ver. 5.00 */
#define MAJOR_RELEASE 4
#define MAJOR_RELEASE 5
#define MINOR_RELEASE 00
#define REV_NUMBER 0

View File

@ -27,6 +27,9 @@
; $Id$
;
; $Log$
; Revision 1.4 2001/03/21 02:56:25 bartoldeman
; See history.txt for changes. Bug fixes and HMA support are the main ones.
;
; Revision 1.3 2000/05/25 20:56:21 jimtabor
; Fixed project history
;
@ -79,7 +82,7 @@
extern _usr_sp:wrt DGROUP ; user stacks
extern _usr_ss:wrt DGROUP
segment _TEXT
segment HMA_TEXT
global _set_stack
;
; void far set_stack(void) -

View File

@ -24,9 +24,19 @@
; write to the Free Software Foundation, 675 Mass Ave,
; Cambridge, MA 02139, USA.
;
; version 1.4 by tom.ehlert@ginko.de
; added some more functions
; changed bcopy, scopy, sncopy,...
; to memcpy, strcpy, strncpy
; Bart Oldeman: optimized a bit: see /usr/include/bits/string.h from
; glibc 2.2
;
; $Id$
;
; $Log$
; Revision 1.4 2001/03/21 02:56:25 bartoldeman
; See history.txt for changes. Bug fixes and HMA support are the main ones.
;
; Revision 1.3 2000/05/25 20:56:21 jimtabor
; Fixed project history
;
@ -77,126 +87,443 @@
%include "segs.inc"
segment _TEXT
segment HMA_TEXT
;*********************************************************************
; this implements some of the common string handling functions
;
; VOID bcopy(s, d, n)
; REG BYTE *s, *d;
; REG COUNT n;
; every function has 2 entries
;
; NEAR FUNC()
; FAR init_call_FUNC()
;
global _bcopy
_bcopy:
; currently done:
;
; memcpy(void *dest, void *src, int count)
; fmemcpy(void FAR *dest, void FAR *src, int count)
; _fmemcpy(void FAR *dest, void FAR *src, int count)
; fmemset(void FAR *dest, int ch, int count);
; fstrncpy(void FAR*dest, void FAR *src, int count);
; strcpy (void *dest, void *src);
; fstrcpy (void FAR*dest, void FAR *src, int count);
; strlen (void *dest);
; fstrlen (void FAR*dest);
; strchr (BYTE *src , BYTE ch);
; fstrcmp (BYTE FAR *s1 , BYTE FAR *s2);
; strcmp (BYTE *s1 , BYTE *s2);
; fstrncmp(BYTE FAR *s1 , BYTE FAR *s2, int count);
; strncmp(BYTE *s1 , BYTE *s2, int count);
;***********************************************
; common_setup - set up the standard calling frame for C-functions
; and save registers needed later
; also preload the args for the near functions
; di=arg1
; si=arg2
; cx=arg3
;
common_setup:
pop bx ; get return address
push bp ; Standard C entry
mov bp,sp
push si
push di
push ds
push es
; Get the repitition count, n
mov cx,[bp+8]
jcxz bcopy_exit
push ds
; Set both ds and es to same segment (for near copy)
mov ax,ds
mov es,ax
pop es
push ds
; Get the source pointer, ss
mov si,[bp+4]
; and the destination pointer, d
mov di,[bp+6]
?doIt:
; Set direction to autoincrement
cld
; to conserve even some more bytes,
; the registers for the near routines
; are preloaded here
; the destination pointer, d = arg1
mov di,[bp+6]
; Get the source pointer, s = arg2
mov si,[bp+8]
; Get the repitition count, n = arg3
mov cx,[bp+10]
jmp bx
;***********************************************
;
; VOID memcpy(REG BYTE *s, REG BYTE *d, REG COUNT n);
;
global _memcpy
global _init_call_memcpy
_memcpy:
pop ax
push cs
push ax
_init_call_memcpy:
call common_setup
domemcpy:
; And do the built-in byte copy, but do a 16-bit transfer
; whenever possible.
mov al, cl
and al,1 ; test for odd count
jz b_even
movsb
b_even: shr cx,1
shr cx,1
rep movsw
jnc common_return
movsb
; Finally do a C exit to return
fbcopy_exit:
bcopy_exit: pop es
;
; common_return - pop saved registers and do return
;
common_return:
pop ds
pop es
pop di
pop si
pop bp
ret
retf
;************************************************************
;
; VOID fbcopy(s, d, n)
; VOID fmemcpy(REG BYTE FAR *d, REG BYTE FAR *s,REG COUNT n);
;
; REG VOID FAR *s, FAR *d;
; REG COUNT n;
global _fbcopy
_fbcopy:
push bp ; Standard C entry
mov bp,sp
push si
push di
; Save ds, since we won't necessarily be within our
; small/tiny environment
push ds
push es
; Get the repititon count, n
mov cx,[bp+12]
jcxz fbcopy_exit
global __fmemcpy
global _fmemcpy
global _init_call_fmemcpy
_fmemcpy:
__fmemcpy:
pop ax
push cs
push ax
_init_call_fmemcpy:
call common_setup
; Get the far source pointer, s
lds si,[bp+4]
lds si,[bp+10]
; Get the far destination pointer d
les di,[bp+8]
les di,[bp+6]
jmp short ?doIt
; Get the repetition count, n
mov cx,[bp+14]
jmp short domemcpy
;***************************************************************
;
; VOID fmemset(s, ch, n)
; VOID fmemset(REG VOID FAR *d, REG BYTE ch, REG COUNT n);
;
; REG VOID FAR *s
; REG int ch
; REG COUNT n;
global _fmemset
global _init_call_fmemset
_fmemset:
push bp ; Standard C entry
mov bp,sp
push di
pop ax
push cs
push ax
_init_call_fmemset:
; Save ds, since we won't necessarily be within our
; small/tiny environment
push es
call common_setup
; Get the repititon count, n
mov cx,[bp+10]
jcxz fmemset_exit
; Get the repetition count, n
mov cx,[bp+12]
; Get the far source pointer, s
les di,[bp+4]
; Test if odd or even
mov al, cl
and al, 1
les di,[bp+6]
; Get the far destination pointer ch
mov al,[bp+8]
mov al,[bp+10]
domemset:
mov ah, al
jz m_even
stosb
m_even: shr cx,1
shr cx,1
rep stosw
jnc common_return
stosb
jmp short common_return
;***************************************************************
;
; VOID memset(REG VOID *d, REG BYTE ch, REG COUNT n);
;
global _memset
global _init_call_memset
_memset:
pop ax
push cs
push ax
_init_call_memset:
call common_setup
; Get the far source pointer, s
; mov di,[bp+6]
; Get the char ch
mov ax,si ; mov al, [bp+8]
; Get the repititon count, n
; mov cx,[bp+10]
jmp short domemset
;***************************************************************
global _fstrncpy
global _init_call_fstrncpy
_fstrncpy:
pop ax
push cs
push ax
_init_call_fstrncpy:
call common_setup
; Get the source pointer, ss
lds si,[bp+10]
; and the destination pointer, d
les di,[bp+6]
mov cx,[bp+14]
jcxz common_return
;; dec cx
; jcxz store_one_byte
strncpy_loop: lodsb
stosb
test al,al
loopnz strncpy_loop
store_one_byte: xor al,al
; the spec for strncpy() would require
; rep stosb
; to fill remaining part of buffer
stosb
jmp short common_return
;*****************************************************************
fmemset_exit: pop es
pop di
pop bp
ret
global _fstrcpy
global _init_call_fstrcpy
_fstrcpy:
pop ax
push cs
push ax
_init_call_fstrcpy:
call common_setup
; Get the source pointer, ss
lds si,[bp+10]
; and the destination pointer, d
les di,[bp+6]
jmp short dostrcpy
;******
global _strcpy
global _init_call_strcpy
_strcpy:
pop ax
push cs
push ax
_init_call_strcpy:
call common_setup
; Get the source pointer, ss
;mov si,[bp+8]
; and the destination pointer, d
;mov di,[bp+6]
dostrcpy:
strcpy_loop:
lodsb
stosb
test al,al
jne strcpy_loop
jmp short common_return
;******************************************************************
global _fstrlen
global _init_call_fstrlen
_fstrlen:
pop ax
push cs
push ax
_init_call_fstrlen:
call common_setup
; Get the source pointer, ss
les di,[bp+6]
jmp short dostrlen
;**********************************************
global _strlen
global _init_call_strlen
_strlen:
pop ax
push cs
push ax
_init_call_strlen:
call common_setup
; The source pointer, ss, arg1 was loaded as di
dostrlen:
mov al,0
mov cx,0xffff
repne scasb
mov ax,cx
not ax
dec ax
jmp common_return
;************************************************************
global _strchr
global _init_call_strchr
_strchr:
pop ax
push cs
push ax
_init_call_strchr:
call common_setup
; Get the source pointer, ss
; mov si,[bp+6]
; mov bx,[bp+8]
mov bx,si
mov si,di
strchr_loop:
lodsb
cmp al,bl
je strchr_found
test al,al
jne strchr_loop
mov si,1 ; return NULL if not found
strchr_found:
mov ax,si
dec ax
jmp common_return
;**********************************************************************
global _fstrcmp
global _init_call_fstrcmp
_fstrcmp:
pop ax
push cs
push ax
_init_call_fstrcmp:
call common_setup
; Get the source pointer, ss
lds si,[bp+6]
; and the destination pointer, d
les di,[bp+10]
jmp dostrcmp
;******
global _strcmp
global _init_call_strcmp
_strcmp:
pop ax
push cs
push ax
_init_call_strcmp:
call common_setup
; Get the source pointer, ss
; mov si,[bp+6]
; and the destination pointer, d
; mov di,[bp+8]
xchg si,di
dostrcmp:
; replace strncmp(s1,s2)-->
; strncmp(s1,s2,0xffff)
mov cx,0xffff
jmp short dostrncmp
;**********************************************************************
global _fstrncmp
global _init_call_fstrncmp
_fstrncmp:
pop ax
push cs
push ax
_init_call_fstrncmp:
call common_setup
; Get the source pointer, ss
lds si,[bp+6]
; and the destination pointer, d
les di,[bp+10]
mov cx,[bp+12]
jmp short dostrncmp
;******
global _strncmp
global _init_call_strncmp
_strncmp:
pop ax
push cs
push ax
_init_call_strncmp:
call common_setup
; Get the source pointer, ss
;mov si,[bp+6]
; and the destination pointer, d
;mov di,[bp+8]
;mov cx,[bp+10]
xchg si,di
dostrncmp:
jcxz strncmp_retzero
strncmp_loop:
lodsb
scasb
jne strncmp_done
test al,al
loopne strncmp_loop
strncmp_retzero:
xor ax, ax
jmp short strncmp_done2
strncmp_done:
sbb ax,ax
or al,1
strncmp_done2: jmp common_return

View File

@ -37,6 +37,9 @@ static BYTE *blockioRcsId = "$Id$";
/*
* $Log$
* Revision 1.7 2001/03/21 02:56:25 bartoldeman
* See history.txt for changes. Bug fixes and HMA support are the main ones.
*
* Revision 1.6 2000/10/30 00:32:08 jimtabor
* Minor Fixes
*
@ -152,34 +155,43 @@ static BYTE *blockioRcsId = "$Id$";
/* block cache routines */
/* */
/************************************************************************/
/* #define DISPLAY_GETBLOCK */
/* */
/* Initialize the buffer structure */
/* */
/* XXX: This should go into `INIT_TEXT'. -- ror4 */
VOID FAR init_buffers(void)
/* this code moved to CONFIG.C
VOID FAR reloc_call_init_buffers(void)
{
REG WORD i;
REG WORD count;
printf("init_buffers %d buffers at %p\n",Config.cfgBuffers, (void FAR*)&buffers[0]);
for (i = 0; i < Config.cfgBuffers; ++i)
{
buffers[i].b_unit = 0;
buffers[i].b_flag = 0;
buffers[i].b_blkno = 0;
buffers[i].b_copies = 0;
buffers[i].b_offset_lo = 0;
buffers[i].b_offset_hi = 0;
struct buffer FAR *pbuffer = &buffers[i];
pbuffer->b_unit = 0;
pbuffer->b_flag = 0;
pbuffer->b_blkno = 0;
pbuffer->b_copies = 0;
pbuffer->b_offset_lo = 0;
pbuffer->b_offset_hi = 0;
if (i < (Config.cfgBuffers - 1))
buffers[i].b_next = &buffers[i + 1];
pbuffer->b_next = pbuffer + 1;
else
buffers[i].b_next = NULL;
pbuffer->b_next = NULL;
}
firstbuf = &buffers[0];
lastbuf = &buffers[Config.cfgBuffers - 1];
}
*/
/* Extract the block number from a buffer structure. */
#if 0 /*TE*/
ULONG getblkno(struct buffer FAR * bp)
{
if (bp->b_blkno == 0xffffu)
@ -187,9 +199,13 @@ ULONG getblkno(struct buffer FAR * bp)
else
return bp->b_blkno;
}
#else
#define getblkno(bp) (bp)->b_blkno
#endif
/* Set the block number of a buffer structure. (The caller should */
/* set the unit number before calling this function.) */
#if 0 /*TE*/
VOID setblkno(struct buffer FAR * bp, ULONG blkno)
{
if (blkno >= 0xffffu)
@ -206,6 +222,90 @@ VOID setblkno(struct buffer FAR * bp, ULONG blkno)
}
}
#else
#define setblkno(bp, blkno) (bp)->b_blkno = (blkno)
#endif
/*
this searches the buffer list for the given disk/block.
if found, the buffer is returned.
if not found, NULL is returned, and *pReplacebp
contains a buffer to throw out.
*/
struct buffer FAR *searchblock(ULONG blkno, COUNT dsk,
struct buffer FAR ** pReplacebp)
{
int fat_count = 0;
struct buffer FAR *bp;
struct buffer FAR *lbp = NULL;
struct buffer FAR *lastNonFat = NULL;
#ifdef DISPLAY_GETBLOCK
printf("[searchblock %d, blk %ld, buf ", dsk, blkno);
#endif
/* Search through buffers to see if the required block */
/* is already in a buffer */
for (bp = firstbuf; bp != NULL;lbp = bp, bp = bp->b_next)
{
if ((getblkno(bp) == blkno) &&
(bp->b_flag & BFR_VALID) && (bp->b_unit == dsk))
{
/* found it -- rearrange LRU links */
if (lbp != NULL)
{
lbp->b_next = bp->b_next;
bp->b_next = firstbuf;
firstbuf = bp;
}
#ifdef DISPLAY_GETBLOCK
printf("HIT %04x:%04x]\n", FP_SEG(bp), FP_OFF(bp));
#endif
return (bp);
}
if (bp->b_flag & BFR_FAT)
fat_count++;
else
lastNonFat = bp;
}
/*
now take either the last buffer in chain (not used recently)
or, if we are low on FAT buffers, the last non FAT buffer
*/
if (lbp ->b_flag & BFR_FAT && fat_count < 3 && lastNonFat)
{
lbp = lastNonFat;
}
*pReplacebp = lbp;
#ifdef DISPLAY_GETBLOCK
printf("MISS, replace %04x:%04x]\n", FP_SEG(lbp), FP_OFF(lbp));
#endif
if (lbp != firstbuf) /* move to front */
{
for (bp = firstbuf; bp->b_next != lbp; bp = bp->b_next)
;
bp->b_next = bp->b_next->b_next;
lbp->b_next = firstbuf;
firstbuf = lbp;
}
return NULL;
}
/* */
/* Return the address of a buffer structure containing the */
@ -218,106 +318,34 @@ VOID setblkno(struct buffer FAR * bp, ULONG blkno)
/* */
struct buffer FAR *getblock(ULONG blkno, COUNT dsk)
{
REG struct buffer FAR *bp;
REG struct buffer FAR *lbp;
REG struct buffer FAR *mbp;
REG BYTE fat_count = 0;
struct buffer FAR *bp;
struct buffer FAR *Replacebp;
/* Search through buffers to see if the required block */
/* is already in a buffer */
#ifdef DISPLAY_GETBLOCK
printf("[getblock %d, blk %ld, buf ", dsk, blkno);
#endif
bp = firstbuf;
lbp = NULL;
mbp = NULL;
while (bp != NULL)
{
if ((bp->b_flag & BFR_VALID) && (bp->b_unit == dsk)
&& (getblkno(bp) == blkno))
bp = searchblock(blkno, dsk, &Replacebp);
if (bp)
{
/* found it -- rearrange LRU links */
if (lbp != NULL)
{
lbp->b_next = bp->b_next;
bp->b_next = firstbuf;
firstbuf = bp;
}
#ifdef DISPLAY_GETBLOCK
printf("HIT]\n");
#endif
return (bp);
}
else
{
if (bp->b_flag & BFR_FAT)
fat_count++;
mbp = lbp; /* move along to next buffer */
lbp = bp;
bp = bp->b_next;
}
}
/* The block we need is not in a buffer, we must make a buffer */
/* available, and fill it with the desired block */
/* detach lru buffer */
#ifdef DISPLAY_GETBLOCK
printf("MISS]\n");
#endif
/* make sure we keep at least 3 buffers for the FAT. If this is not a */
/* FAT buffer, or there are at least 3 already, then we can use this */
/* buffer. */
/* otherwise, search again, and find the last non-FAT buffer. */
if ((lbp->b_flag & BFR_FAT) && (fat_count < 3))
/* take the buffer that lbp points to and flush it, then read new block. */
if (flush1(Replacebp) && fill(Replacebp, blkno, dsk)) /* success */
{
bp = firstbuf;
lbp = NULL;
mbp = NULL;
while ((bp != NULL) && (bp->b_flag & BFR_FAT))
{
/* if this is a FAT buffer, then move to the next one, else we found */
/* the one we want. */
mbp = lbp; /* move along to next buffer */
lbp = bp;
bp = bp->b_next;
}
/* if we get to the end of the list here, then we must only have 3 */
/* buffers, which is not suppose to happen, but if it does, then we */
/* end up using the last buffer (even though it is FAT). */
if (bp == NULL)
{
/* put lbp at the top of the chain. */
if (mbp != NULL)
mbp->b_next = NULL;
lbp->b_next = firstbuf;
firstbuf = bp = lbp;
}
else if (lbp != NULL)
{
lbp->b_next = bp->b_next;
bp->b_next = firstbuf;
firstbuf = bp;
}
lbp = bp;
return Replacebp;
}
else
{
/* put lbp at the top of the chain. */
if (mbp != NULL)
mbp->b_next = NULL;
lbp->b_next = firstbuf;
firstbuf = lbp;
return NULL;
}
/* take the buffer than lbp points to and flush it, then read new block. */
if (flush1(lbp) && fill(lbp, blkno, dsk)) /* success */
mbp = lbp;
else
mbp = NULL; /* failure */
return (mbp);
}
/*
@ -333,107 +361,30 @@ struct buffer FAR *getblock(ULONG blkno, COUNT dsk)
*/
BOOL getbuf(struct buffer FAR ** pbp, ULONG blkno, COUNT dsk)
{
REG struct buffer FAR *bp;
REG struct buffer FAR *lbp;
REG struct buffer FAR *mbp;
REG BYTE fat_count = 0;
struct buffer FAR *bp;
struct buffer FAR *Replacebp;
/* Search through buffers to see if the required block */
/* is already in a buffer */
#ifdef DISPLAY_GETBLOCK
printf("[getbuf %d, blk %ld, buf ", dsk, blkno);
#endif
bp = firstbuf;
lbp = NULL;
mbp = NULL;
while (bp != NULL)
{
if ((bp->b_flag & BFR_VALID) && (bp->b_unit == dsk)
&& (getblkno(bp) == blkno))
bp = searchblock(blkno, dsk, &Replacebp);
if (bp)
{
/* found it -- rearrange LRU links */
if (lbp != NULL)
{
lbp->b_next = bp->b_next;
bp->b_next = firstbuf;
firstbuf = bp;
}
*pbp = bp;
#ifdef DISPLAY_GETBLOCK
printf("HIT]\n");
#endif
return TRUE;
}
else
{
if (bp->b_flag & BFR_FAT)
fat_count++;
mbp = lbp; /* move along to next buffer */
lbp = bp;
bp = bp->b_next;
}
}
}
/* The block we need is not in a buffer, we must make a buffer */
/* available. */
#ifdef DISPLAY_GETBLOCK
printf("MISS]\n");
#endif
/* make sure we keep at least 3 buffers for the FAT. If this is not a */
/* FAT buffer, or there are at least 3 already, then we can use this */
/* buffer. */
/* otherwise, search again, and find the last non-FAT buffer. */
if ((lbp->b_flag & BFR_FAT) && (fat_count < 3))
{
bp = firstbuf;
lbp = NULL;
mbp = NULL;
while ((bp != NULL) && (bp->b_flag & BFR_FAT))
{
/* if this is a FAT buffer, then move to the next one, else we found */
/* the one we want. */
mbp = lbp; /* move along to next buffer */
lbp = bp;
bp = bp->b_next;
}
/* if we get to the end of the list here, then we must only have 3 */
/* buffers, which is not suppose to happen, but if it does, then we */
/* end up using the last buffer (even though it is FAT). */
if (bp == NULL)
{
/* put lbp at the top of the chain. */
if (mbp != NULL)
mbp->b_next = NULL;
lbp->b_next = firstbuf;
firstbuf = bp = lbp;
}
else if (lbp != NULL)
{
lbp->b_next = bp->b_next;
bp->b_next = firstbuf;
firstbuf = bp;
}
lbp = bp;
}
else
{
/* put lbp at the top of the chain. */
if (mbp != NULL)
mbp->b_next = NULL;
lbp->b_next = firstbuf;
firstbuf = lbp;
}
/* take the buffer than lbp points to and flush it, then make it available. */
if (flush1(lbp)) /* success */
if (flush1(Replacebp)) /* success */
{
lbp->b_flag = 0;
lbp->b_unit = dsk;
setblkno(lbp, blkno);
*pbp = lbp;
Replacebp->b_flag = 0;
Replacebp->b_unit = dsk;
setblkno(Replacebp, blkno);
*pbp = Replacebp;
return TRUE;
}
else
@ -443,7 +394,6 @@ BOOL getbuf(struct buffer FAR ** pbp, ULONG blkno, COUNT dsk)
return FALSE;
}
}
/* */
/* Mark all buffers for a disk as not valid */
/* */

View File

@ -30,7 +30,7 @@
#include "portab.h"
#include "globals.h"
extern void spawn_int23(void);
extern void FAR init_call_spawn_int23(void);
#ifdef VERSION_STRINGS
static BYTE *RcsId = "$Id$";
@ -38,6 +38,9 @@ static BYTE *RcsId = "$Id$";
/*
* $Log$
* Revision 1.4 2001/03/21 02:56:25 bartoldeman
* See history.txt for changes. Bug fixes and HMA support are the main ones.
*
* Revision 1.3 2000/05/25 20:56:21 jimtabor
* Fixed project history
*
@ -86,6 +89,26 @@ void handle_break(void)
if (!ErrorMode) /* within int21_handler, InDOS is not incremented */
if (InDOS)
--InDOS; /* fail-safe */
{
/*TE PATCH
CtrlC at DosInput (like C:>DATE does)
Nukes the Kernel.
it looks like ENTRY.ASM+PROCSUPT.ASM
got out of sync.
spawn_int() assumes a stack layout at
usr_ss:usr:sp. but usr:ss currently contains 0
this patch helps FreeDos to survive CtrlC,
but should clearly be done somehow else.
*/
extern ULONG lpUserStack;
usr_ss = FP_SEG(lpUserStack);
usr_sp = FP_OFF(lpUserStack);
}
spawn_int23(); /* invoke user INT-23 and never come back */
init_call_spawn_int23(); /* invoke user INT-23 and never come back */
}

View File

@ -27,6 +27,7 @@
/* Cambridge, MA 02139, USA. */
/****************************************************************/
#include "init-mod.h"
#include "portab.h"
@ -39,8 +40,8 @@ static BYTE *RcsId = "$Id$";
/*
* $Log$
* Revision 1.9 2001/03/19 04:50:56 bartoldeman
* See history.txt for overview: put kernel 2022beo1 into CVS
* Revision 1.10 2001/03/21 02:56:25 bartoldeman
* See history.txt for changes. Bug fixes and HMA support are the main ones.
*
* Revision 1.9 2001/03/08 21:15:00 bartoldeman
* Fixed handling of "DOS=UMB", use toupper instead of tolower consistently.
@ -148,9 +149,11 @@ static BYTE *RcsId = "$Id$";
*/
#ifdef __TURBOC__
void __int__(int); /* TC 2.01 requires this. :( -- ror4 */
void __int__(int); /* TC 2.01 requires this. :( -- ror4 */
#define int3() __int__(3);
#endif
#ifdef KDB
#include <alloc.h>
@ -163,7 +166,7 @@ static BYTE FAR *lpOldLast;
static BYTE FAR *upOldLast;
static COUNT nCfgLine;
static COUNT nPass;
static COUNT UmbState;
COUNT UmbState;
static BYTE szLine[256];
static BYTE szBuf[256];
@ -172,7 +175,7 @@ int singleStep = 0;
INIT VOID zumcb_init(mcb FAR * mcbp, UWORD size);
INIT VOID mumcb_init(mcb FAR * mcbp, UWORD size);
INIT VOID Buffers(BYTE * pLine);
INIT VOID Config_Buffers(BYTE * pLine);
INIT VOID sysScreenMode(BYTE * pLine);
INIT VOID sysVersion(BYTE * pLine);
INIT VOID Break(BYTE * pLine);
@ -181,18 +184,29 @@ INIT VOID DeviceHigh(BYTE * pLine);
INIT VOID Files(BYTE * pLine);
INIT VOID Fcbs(BYTE * pLine);
INIT VOID Lastdrive(BYTE * pLine);
INIT VOID LoadDevice(BYTE * pLine, COUNT top, COUNT mode);
INIT BOOL LoadDevice(BYTE * pLine, COUNT top, COUNT mode);
INIT VOID Dosmem(BYTE * pLine);
INIT VOID Country(BYTE * pLine);
INIT VOID InitPgm(BYTE * pLine);
INIT VOID Switchar(BYTE * pLine);
INIT VOID CfgFailure(BYTE * pLine);
INIT VOID Stacks(BYTE * pLine);
INIT VOID SetAnyDos(BYTE * pLine);
INIT BYTE *GetNumArg(BYTE * pLine, COUNT * pnArg);
INIT BYTE *GetStringArg(BYTE * pLine, BYTE * pszString);
INIT struct dhdr FAR *linkdev(struct dhdr FAR * dhp);
INIT UWORD initdev(struct dhdr FAR * dhp, BYTE FAR * cmdTail);
INIT int SkipLine(char *pLine);
INIT char *stristr(char *s1, char *s2);
INIT BYTE FAR *KernelAlloc(WORD nBytes);
extern void HMAconfig(int finalize);
VOID config_init_buffers(COUNT anzBuffers); /* from BLOCKIO.C */
extern fmemcmp(BYTE far *s1, BYTE FAR *s2, unsigned len);
INIT static VOID FAR *AlignParagraph(VOID FAR * lpPtr);
#ifndef I86
@ -213,12 +227,12 @@ struct table
static struct table commands[] =
{
{"BREAK", 1, Break},
{"BUFFERS", 1, Buffers},
{"BUFFERS", 1, Config_Buffers},
{"COMMAND", 1, InitPgm},
{"COUNTRY", 1, Country},
{"DEVICE", 2, Device},
{"DEVICEHIGH", 2, DeviceHigh},
{"DOS", 2, Dosmem},
{"DOS", 1, Dosmem},
{"FCBS", 1, Fcbs},
{"FILES", 1, Files},
{"LASTDRIVE", 1, Lastdrive},
@ -229,6 +243,7 @@ static struct table commands[] =
{"SWITCHAR", 1, Switchar},
{"SCREEN", 1, sysScreenMode}, /* JPP */
{"VERSION", 1, sysVersion}, /* JPP */
{"ANYDOS", 1, SetAnyDos}, /* JPP */
/* default action */
{"", -1, CfgFailure}
};
@ -240,6 +255,21 @@ INIT BYTE FAR *KernelAllocDma(WORD);
BYTE *pLineStart;
BYTE HMATextIsAvailable = 0;
void FAR * ConfigAlloc(COUNT bytes)
{
VOID FAR *p;
p = HMAalloc(bytes);
if (p == NULL) p = KernelAlloc(bytes);
/* printf("ConfigAllog %d at %p\n", bytes, p);*/
return p;
}
/* Do first time initialization. Store last so that we can reset it */
/* later. */
INIT void PreConfig(void)
@ -247,26 +277,34 @@ INIT void PreConfig(void)
/* Set pass number */
nPass = 0;
VgaSet = 0;
UmbState = 0;
UmbState = 0;
/* Initialize the base memory pointers */
lpOldLast = lpBase = AlignParagraph((BYTE FAR *) & last);
if ( HMATextIsAvailable )
lpOldLast = lpBase = AlignParagraph((BYTE FAR *) & _HMATextAvailable);
else
lpOldLast = lpBase = AlignParagraph((BYTE FAR *) & _InitTextStart);
#ifdef DEBUG
printf("SDA located at 0x%04x:0x%04x\n",
FP_SEG(internal_data), FP_OFF(internal_data));
printf("SDA located at 0x%p\n", internal_data);
#endif
/* Begin by initializing our system buffers */
dma_scratch = (BYTE FAR *) KernelAllocDma(BUFFERSIZE);
/* the dms_scratch buffer is statically allocated
in the DSK module */
/* dma_scratch = (BYTE FAR *) KernelAllocDma(BUFFERSIZE); */
#ifdef DEBUG
printf("Preliminary DMA scratchpad allocated at 0x%04x:0x%04x\n",
FP_SEG(dma_scratch), FP_OFF(dma_scratch));
/* printf("Preliminary DMA scratchpad allocated at 0x%p\n",dma_scratch);*/
#endif
buffers = (struct buffer FAR *)
KernelAlloc(Config.cfgBuffers * sizeof(struct buffer));
config_init_buffers( Config.cfgBuffers );
/* buffers = (struct buffer FAR *)
KernelAlloc(Config.cfgBuffers * sizeof(struct buffer)); */
#ifdef DEBUG
printf("Preliminary %d buffers allocated at 0x%04x:0x%04x\n", Config.cfgBuffers,
FP_SEG(buffers), FP_OFF(buffers));
/* printf("Preliminary %d buffers allocated at 0x%p\n", Config.cfgBuffers, buffers);*/
#endif
/* Initialize the file table */
@ -285,22 +323,16 @@ INIT void PreConfig(void)
KernelAlloc(0x58 * (lastdrive));
#ifdef DEBUG
printf("Preliminary f_node allocated at 0x%04x:0x%04x\n",
FP_SEG(f_nodes), FP_OFF(f_nodes));
printf("Preliminary FCB table allocated at 0x%04x:0x%04x\n",
FP_SEG(FCBp), FP_OFF(FCBp));
printf("Preliminary sft table allocated at 0x%04x:0x%04x\n",
FP_SEG(sfthead), FP_OFF(sfthead));
printf("Preliminary CDS table allocated at 0x%04x:0x%04x\n",
FP_SEG(CDSp), FP_OFF(CDSp));
printf("Preliminary f_node allocated at at 0x%p\n",f_nodes);
printf("Preliminary FCB table allocated at 0x%p\n",FCBp);
printf("Preliminary sft table allocated at 0x%p\n",sfthead);
printf("Preliminary CDS table allocated at 0x%p\n",CDSp);
#endif
/* Done. Now initialize the MCB structure */
/* This next line is 8086 and 80x86 real mode specific */
#ifdef DEBUG
printf("Preliminary allocation completed: top at 0x%04x:0x%04x\n",
FP_SEG(lpBase), FP_OFF(lpBase));
printf("Preliminary allocation completed: top at 0x%p\n",lpBase);
#endif
#ifdef KDB
@ -327,20 +359,29 @@ INIT void PostConfig(void)
if (lastdrive < nblkdev )
lastdrive = nblkdev ;
/* Initialize the base memory pointers from last time. */
lpBase = AlignParagraph(lpOldLast);
if ( HMATextIsAvailable )
lpOldLast = lpBase = AlignParagraph((BYTE FAR *) & _HMATextStart);
else
lpOldLast = lpBase = AlignParagraph((BYTE FAR *) & _InitTextStart);
/* Begin by initializing our system buffers */
dma_scratch = (BYTE FAR *) KernelAllocDma(BUFFERSIZE);
/* dma_scratch = (BYTE FAR *) KernelAllocDma(BUFFERSIZE); */
#ifdef DEBUG
printf("DMA scratchpad allocated at 0x%04x:0x%04x\n", FP_SEG(dma_scratch),
FP_OFF(dma_scratch));
/* printf("DMA scratchpad allocated at 0x%p\n", dma_scratch); */
#endif
buffers = (struct buffer FAR *)
KernelAlloc(Config.cfgBuffers * sizeof(struct buffer));
config_init_buffers( Config.cfgBuffers );
/* buffers = (struct buffer FAR *)
KernelAlloc(Config.cfgBuffers * sizeof(struct buffer)); */
#ifdef DEBUG
printf("%d buffers allocated at 0x%04x:0x%04x\n", Config.cfgBuffers,
FP_SEG(buffers), FP_OFF(buffers));
/* printf("%d buffers allocated at 0x%p\n", Config.cfgBuffers,buffers); */
#endif
/* Initialize the file table */
@ -360,14 +401,10 @@ INIT void PostConfig(void)
#ifdef DEBUG
printf("f_node allocated at 0x%04x:0x%04x\n",
FP_SEG(f_nodes), FP_OFF(f_nodes));
printf("FCB table allocated at 0x%04x:0x%04x\n",
FP_SEG(FCBp), FP_OFF(FCBp));
printf("sft table allocated at 0x%04x:0x%04x\n",
FP_SEG(sfthead), FP_OFF(sfthead));
printf("CDS table allocated at 0x%04x:0x%04x\n",
FP_SEG(CDSp), FP_OFF(CDSp));
printf("f_node allocated at 0x%p\n",f_nodes);
printf("FCB table allocated at 0x%p\n",FCBp);
printf("sft table allocated at 0x%p\n",sfthead);
printf("CDS table allocated at 0x%p\n",CDSp);
#endif
if (Config.cfgStacks)
{
@ -375,13 +412,11 @@ INIT void PostConfig(void)
init_stacks(stackBase, Config.cfgStacks, Config.cfgStackSize);
#ifdef DEBUG
printf("Stacks allocated at %04x:%04x\n",
FP_SEG(stackBase), FP_OFF(stackBase));
printf("Stacks allocated at %p\n",stackBase);
#endif
}
#ifdef DEBUG
printf("Allocation completed: top at 0x%04x:0x%04x\n",
FP_SEG(lpBase), FP_OFF(lpBase));
printf("Allocation completed: top at 0x%p\n",lpBase);
#endif
@ -391,6 +426,10 @@ INIT void PostConfig(void)
INIT VOID configDone(VOID)
{
COUNT i;
HMAconfig(TRUE); /* final HMA processing */
if (lastdrive < nblkdev) {
#ifdef DEBUG
@ -426,8 +465,7 @@ INIT VOID configDone(VOID)
}
#ifdef DEBUG
printf("UMB Allocation completed: top at 0x%04x:0x%04x\n",
FP_SEG(upBase), FP_OFF(upBase));
printf("UMB Allocation completed: top at 0x%p\n",upBase);
#endif
/* The standard handles should be reopened here, because
@ -509,6 +547,9 @@ INIT VOID DoConfig(VOID)
/*
Do it here in the loop.
*/
/* shouldn't this go also AFTER the last line has been read?
might be the UMB driver */
if(UmbState == 2){
if(!Umb_Test()){
UmbState = 1;
@ -624,7 +665,7 @@ INIT BYTE *GetStringArg(BYTE * pLine, BYTE * pszString)
return scan(pLine, pszString);
}
INIT static VOID Buffers(BYTE * pLine)
INIT void Config_Buffers(BYTE * pLine)
{
COUNT nBuffers;
@ -719,17 +760,49 @@ INIT static VOID Lastdrive(BYTE * pLine)
UmbState of confidence, 1 is sure, 2 maybe, 4 unknown and 0 no way.
*/
#ifdef __TURBOC__
void __int__(int); /* TC 2.01 requires this. :( -- ror4 */
#endif
#define int3() __int__(3);
INIT static VOID Dosmem(BYTE * pLine)
{
BYTE *pTmp;
if(UmbState == 0){
uppermem_link = 0;
uppermem_root = 0;
GetStringArg(pLine, szBuf);
BYTE UMBwanted = FALSE, HMAwanted = FALSE;
pLine = GetStringArg(pLine, szBuf);
for (pTmp = szBuf; *pTmp != '\0'; pTmp++)
*pTmp = toupper(*pTmp);
UmbState = strcmp(szBuf, "UMB") ? 0 : 2;
printf("DOS called with %s\n", szBuf);
int3();
for (pTmp = szBuf ; ; )
{
if (fmemcmp(pTmp, "UMB" ,3) == 0) { UMBwanted = TRUE; pTmp += 3; }
if (fmemcmp(pTmp, "HIGH",4) == 0) { HMAwanted = TRUE; pTmp += 4; }
pTmp = skipwh(pTmp);
if (*pTmp != ',')
break;
pTmp++;
}
if(UmbState == 0){
uppermem_link = 0;
uppermem_root = 0;
UmbState = UMBwanted ? 2 : 0;
}
if (HMAwanted)
{
int MoveKernelToHMA();
HMATextIsAvailable = MoveKernelToHMA();
}
}
@ -771,10 +844,15 @@ INIT static VOID Fcbs(BYTE * pLine)
* Returns TRUE if successful, FALSE if not.
*/
static INIT BOOL LoadCountryInfo(char *filename, UWORD ctryCode, UWORD codePage)
INIT BOOL LoadCountryInfo(char *filename, UWORD ctryCode, UWORD codePage)
{
/* printf("cntry: %u, CP%u, file=\"%s\"\n", ctryCode, codePage, filename); */
printf("Sorry, the COUNTRY= statement has been temporarily disabled\n");
UNREFERENCED_PARAMETER(codePage);
UNREFERENCED_PARAMETER(ctryCode);
UNREFERENCED_PARAMETER(filename);
return FALSE;
}
@ -867,7 +945,11 @@ INIT static VOID DeviceHigh(BYTE * pLine)
{
if(UmbState == 1)
{
LoadDevice(pLine, UMB_top, TRUE);
if (LoadDevice(pLine, UMB_top, TRUE) == DE_NOMEM)
{
printf("Not enough free memory in UMB's: loading low\n");
LoadDevice(pLine, ram_top, FALSE);
}
}
else
{
@ -876,12 +958,12 @@ INIT static VOID DeviceHigh(BYTE * pLine)
}
}
INIT static VOID Device(BYTE * pLine)
INIT void Device(BYTE * pLine)
{
LoadDevice(pLine, ram_top, FALSE);
}
INIT static VOID LoadDevice(BYTE * pLine, COUNT top, COUNT mode)
INIT BOOL LoadDevice(BYTE * pLine, COUNT top, COUNT mode)
{
VOID FAR *driver_ptr;
BYTE *pTmp;
@ -889,6 +971,7 @@ INIT static VOID LoadDevice(BYTE * pLine, COUNT top, COUNT mode)
struct dhdr FAR *dhp;
struct dhdr FAR *next_dhp;
UWORD dev_seg;
BOOL result;
if(mode)
dev_seg = (((ULONG) FP_SEG(upBase) << 4) + FP_OFF(upBase) + 0xf) >> 4;
@ -908,18 +991,74 @@ INIT static VOID LoadDevice(BYTE * pLine, COUNT top, COUNT mode)
szBuf, dev_seg);
#endif
int3();
if (DosExec(3, &eb, szBuf) == SUCCESS)
{
/* Link in device driver and save nul_dev pointer to next */
next_dhp = dhp->dh_next = nul_dev.dh_next;
nul_dev.dh_next = dhp;
/* TE this fixes the loading of devices drivers with
multiple devices in it. NUMEGA's SoftIce is such a beast
*/
for ( ; ; )
{
struct dhdr FAR *previous_nul_dhp;
previous_nul_dhp = nul_dev.dh_next;
next_dhp = dhp->dh_next;
/* Link in device driver and save nul_dev pointer to next */
dhp->dh_next = nul_dev.dh_next;
nul_dev.dh_next = dhp;
/* that's a nice hack >:-)
although we don't want HIMEM.SYS,(it's not free), other people
might load HIMEM.SYS to see if they are compatible to it.
if it's HIMEM.SYS, we won't survive TESTMEM:ON
so simply add TESTMEM:OFF to the commandline
*/
pTmp = pLine;
int3();
if (DosLoadedInHMA)
if (stristr(szBuf, "HIMEM.SYS") != NULL)
{
if (stristr(pLine, "/TESTMEM:OFF") == NULL)
{
pTmp = szBuf;
strcpy(pTmp, pLine);
strcat(pTmp, " /TESTMEM:OFF\r\n");
}
}
/* end of HIMEM.SYS HACK */
result=init_device(dhp, pTmp, mode, top);
if(result){
nul_dev.dh_next = previous_nul_dhp; /* return orig pointer if error */
}
/* multiple devices end */
if (FP_OFF(next_dhp) == 0xffff) /* end of internal chain */
break;
FP_OFF(dhp) = FP_OFF(next_dhp);
if (FP_SEG(next_dhp) != 0xffff)
{
printf("multisegmented device driver found, next %p\n",next_dhp); /* give warning message */
dhp = next_dhp;
}
}
HMAconfig(FALSE); /* let the HMA claim HMA usage */
if(init_device(dhp, pLine, mode, top)){
nul_dev.dh_next = next_dhp; /* return orig pointer if error */
}
}
else
CfgFailure(pLine);
return result;
}
INIT static VOID CfgFailure(BYTE * pLine)
@ -934,7 +1073,7 @@ INIT static VOID CfgFailure(BYTE * pLine)
}
#ifndef KDB
INIT static BYTE FAR *KernelAlloc(WORD nBytes)
INIT BYTE FAR *KernelAlloc(WORD nBytes)
{
BYTE FAR *lpAllocated;
@ -956,7 +1095,7 @@ INIT static BYTE FAR *KernelAlloc(WORD nBytes)
#endif
#ifdef I86
INIT static BYTE FAR *KernelAllocDma(WORD bytes)
INIT BYTE FAR *KernelAllocDma(WORD bytes)
{
BYTE FAR *allocated;
@ -968,7 +1107,7 @@ INIT static BYTE FAR *KernelAllocDma(WORD bytes)
return allocated;
}
INIT static VOID FAR *AlignParagraph(VOID FAR * lpPtr)
INIT void FAR *AlignParagraph(VOID FAR * lpPtr)
{
ULONG lTemp;
UWORD uSegVal;
@ -1122,4 +1261,86 @@ INIT VOID
strcpy(d, s);
}
/* see if the second string is contained in the first one, ignoring case */
char *stristr(char *s1, char *s2)
{
int loop;
for ( ; *s1 ; s1++)
for ( loop = 0; ; loop++)
{
if (s2[loop] == 0) /* found end of string 2 -> success */
{
return s1; /* position where s2 was found */
}
if (toupper(s1[loop]) != toupper(s2[loop]) )
break;
}
return NULL;
}
/*
moved from BLOCKIO.C here.
that saves some relocation problems
*/
VOID config_init_buffers(COUNT anzBuffers)
{
REG WORD i;
struct buffer FAR *pbuffer;
int HMAcount = 0;
anzBuffers = max(anzBuffers,6);
anzBuffers = min(anzBuffers,64);
firstbuf = ConfigAlloc(sizeof (struct buffer));
pbuffer = firstbuf;
for (i = 0; ; ++i)
{
if (FP_SEG(pbuffer) == 0xffff) HMAcount++;
lastbuf = pbuffer;
pbuffer->b_unit = 0;
pbuffer->b_flag = 0;
pbuffer->b_blkno = 0;
pbuffer->b_copies = 0;
pbuffer->b_offset_lo = 0;
pbuffer->b_offset_hi = 0;
pbuffer->b_next = NULL;
/* printf("init_buffers buffer %d at %p\n",i, pbuffer);*/
if (i < (anzBuffers - 1))
pbuffer->b_next = ConfigAlloc(sizeof (struct buffer));
if (pbuffer->b_next == NULL)
break;
pbuffer = pbuffer->b_next;
}
if (HMAcount > 0)
printf("Kernel: allocated %d Diskbuffers = %u Bytes in HMA\n",
HMAcount, HMAcount*sizeof (struct buffer));
}
/*
Undocumented feature:
ANYDOS
will report to MSDOS programs just the version number
they expect. be careful with it!
*/
INIT VOID SetAnyDos(BYTE * pLine)
{
UNREFERENCED_PARAMETER(pLine);
ReturnAnyDosVersionExpected = TRUE;
}

View File

@ -28,6 +28,9 @@
; $Header$
;
; $Log$
; Revision 1.5 2001/03/21 02:56:25 bartoldeman
; See history.txt for changes. Bug fixes and HMA support are the main ones.
;
; Revision 1.4 2000/05/26 19:25:19 jimtabor
; Read History file for Change info
;
@ -90,7 +93,7 @@ ConTable db 0Ah
PRT_SCREEN equ 7200h
CTL_P equ 10h
segment _IO_TEXT
segment _TEXT
uScanCode db 0 ; Scan code for con: device

View File

@ -37,8 +37,8 @@ static BYTE *dosfnsRcsId = "$Id$";
* /// Added SHARE support. 2000/09/04 Ron Cemer
*
* $Log$
* Revision 1.10 2001/03/19 04:34:18 bartoldeman
* Update the redirector and Martin Stromberg changes to CVS.
* Revision 1.11 2001/03/21 02:56:25 bartoldeman
* See history.txt for changes. Bug fixes and HMA support are the main ones.
*
* Revision 1.10 2001/03/08 21:15:00 bartoldeman
* Redirector and DosSelectDrv() (Martin Stromberg) fixes
@ -805,6 +805,7 @@ COUNT DosCreat(BYTE FAR * fname, COUNT attrib)
if (CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) {
lpCurSft = (sfttbl FAR *)sftp;
sftp->sft_mode = attrib;
result = int2f_Remote_call(REM_CREATE, 0, 0, 0, (VOID FAR *) sftp, 0, MK_FP(0, attrib));
result = -result;
if (result == SUCCESS) {
@ -963,12 +964,13 @@ COUNT DosOpen(BYTE FAR * fname, COUNT mode)
sftp->sft_shroff = -1; /* /// Added for SHARE - Ron Cemer */
sftp->sft_mode = mode;
/* check for a device */
dhp = IsDevice(fname);
if ( dhp )
{
sftp->sft_count += 1;
sftp->sft_mode = mode;
sftp->sft_attrib = 0;
sftp->sft_flags =
((dhp->dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE | SFT_FEOF;
@ -1185,6 +1187,12 @@ COUNT DosChangeDir(BYTE FAR * s)
COUNT result;
BYTE FAR *p;
/* don't do wildcard CHDIR --TE*/
/* although this should be handled somewhere else */
for (p = s; *p; p++)
if (*p == '*' || *p == '?')
return DE_PATHNOTFND;
drive = get_verify_drive(s);
if (drive < 0 ) {
return drive;

View File

@ -31,7 +31,7 @@
PSP_USERSP equ 2eh
PSP_USERSS equ 30h
segment _TEXT
segment HMA_TEXT
global _DosIdle_int
@ -52,7 +52,7 @@ segment _TEXT
_DosIdle_int:
push ds
push ax
mov ax,DGROUP
mov ax, DGROUP
mov ds,ax
pop ax
cmp byte [_dosidle_flag],0

View File

@ -36,6 +36,9 @@ static BYTE *dosnamesRcsId = "$Id$";
/*
* $Log$
* Revision 1.7 2001/03/21 02:56:25 bartoldeman
* See history.txt for changes. Bug fixes and HMA support are the main ones.
*
* Revision 1.6 2000/06/21 18:16:46 jimtabor
* Add UMB code, patch, and code fixes
*
@ -226,8 +229,8 @@ COUNT ParseDosName(BYTE FAR * lpszFileName,
{
if ((lpszFileName - lpszLclFile) == 2) /* for tail DotDot */
nDirCnt += 2;
if (nDirCnt > PARSE_MAX)
nDirCnt = PARSE_MAX;
if (nDirCnt > PARSE_MAX-1)
nDirCnt = PARSE_MAX-1;
fbcopy(lpszLclDir, (BYTE FAR *) pszDir, nDirCnt);
if (((lpszFileName - lpszLclFile) == 2) && (nDirCnt < PARSE_MAX))
pszDir[nDirCnt++] = '\\'; /* make DosTrimPath() enjoy, for tail DotDot */
@ -272,8 +275,8 @@ COUNT ParseDosName(BYTE FAR * lpszFileName,
return DE_FILENOTFND;
/* Fix lengths to maximums allowed by MS-DOS. */
if (nDirCnt > PARSE_MAX)
nDirCnt = PARSE_MAX;
if (nDirCnt > PARSE_MAX-1)
nDirCnt = PARSE_MAX-1;
if (nFileCnt > FNAME_SIZE)
nFileCnt = FNAME_SIZE;
if (nExtCnt > FEXT_SIZE)
@ -344,9 +347,9 @@ COUNT ParseDosPath(BYTE FAR * lpszFileName,
lpszLclDir = lpszFileName;
if (!PathSep(*lpszLclDir))
{
fstrncpy(pszDir, pszCurPath, PARSE_MAX);
fstrncpy(pszDir, pszCurPath, PARSE_MAX - 1); /*TE*/
nPathCnt = fstrlen(pszCurPath);
if (!PathSep(pszDir[nPathCnt - 1]) && nPathCnt < PARSE_MAX)
if (!PathSep(pszDir[nPathCnt - 1]) && nPathCnt < PARSE_MAX - 1) /*TE*/
pszDir[nPathCnt++] = '\\';
if (nPathCnt > PARSE_MAX)
nPathCnt = PARSE_MAX;
@ -363,8 +366,8 @@ COUNT ParseDosPath(BYTE FAR * lpszFileName,
}
/* Fix lengths to maximums allowed by MS-DOS. */
if ((nDirCnt + nPathCnt) > PARSE_MAX)
nDirCnt = PARSE_MAX - nPathCnt;
if ((nDirCnt + nPathCnt) > PARSE_MAX - 1) /*TE*/
nDirCnt = PARSE_MAX - 1 - nPathCnt;
/* Finally copy whatever the user wants extracted to the user's */
/* buffers. */

View File

@ -33,9 +33,8 @@ static BYTE *dskRcsId = "$Id$";
/*
* $Log$
* Revision 1.10 2001/03/19 05:01:38 bartoldeman
* Space saving and partition detection fixes from Tom Ehlert and
* Brian Reifsnyder.
* Revision 1.11 2001/03/21 02:56:25 bartoldeman
* See history.txt for changes. Bug fixes and HMA support are the main ones.
*
* Revision 1.9 2001/03/08 21:15:00 bartoldeman
* Space saving fixes from Tom Ehlert
@ -124,7 +123,7 @@ static BYTE *dskRcsId = "$Id$";
* Initial revision.
*/
#if 0
#if defined(DEBUG)
#define PartCodePrintf(x) printf x
#else
#define PartCodePrintf(x)
@ -155,7 +154,7 @@ COUNT fl_verify();
BOOL fl_format();
#endif
#define NDEV 16 /* only one for demo */
#define NDEV 8 /* only one for demo */
#define SEC_SIZE 512 /* size of sector in bytes */
#define N_RETRY 5 /* number of retries permitted */
#define NENTRY 26 /* total size of dispatch table */
@ -164,10 +163,17 @@ extern BYTE FAR nblk_rel;
union
{
BYTE bytes[2 * SEC_SIZE];
BYTE bytes[1 * SEC_SIZE];
boot boot_sector;
}
buffer;
} buffer;
/* if the buffer above is good enough for booting
it's also good enough for DMA input */
BYTE /* scratchpad used for working around */
FAR * dma_scratch_buffer = (BYTE FAR *)&buffer; /* DMA transfers during disk I/O */
STATIC struct media_info
{
@ -229,7 +235,7 @@ STATIC struct dos_partitionS
dos_partition[NDEV - 2];
#ifdef PROTO
WORD init(rqptr),
WORD _dsk_init(rqptr),
mediachk(rqptr),
bldbpb(rqptr),
blockio(rqptr),
@ -247,7 +253,7 @@ COUNT ltop(WORD *, WORD *, WORD *, COUNT, COUNT, ULONG, byteptr);
WORD dskerr(COUNT);
COUNT processtable(int table_type,COUNT ptDrive, BYTE ptHead, UWORD ptCylinder, BYTE ptSector, LONG ptAccuOff);
#else
WORD init(),
WORD _dsk_init(),
mediachk(),
bldbpb(),
blockio(),
@ -275,7 +281,7 @@ static WORD(*dispatch[NENTRY]) (rqptr) =
static WORD(*dispatch[NENTRY]) () =
#endif
{
init, /* Initialize */
_dsk_init, /* Initialize */
mediachk, /* Media Check */
bldbpb, /* Build BPB */
blk_error, /* Ioctl In */
@ -317,9 +323,9 @@ static WORD(*dispatch[NENTRY]) () =
ULONG StartSector(WORD ptDrive, unsigned BeginHead,
ULONG StartSector(WORD ptDrive, unsigned BeginCylinder,
unsigned BeginSector,
unsigned BeginCylinder,
unsigned BeginHead,
ULONG peStartSector,
ULONG ptAccuOff)
{
@ -345,12 +351,8 @@ ULONG StartSector(WORD ptDrive, unsigned BeginHead,
startPos = ((ULONG)BeginCylinder * heads + BeginHead) * sectors + BeginSector - 1;
PartCodePrintf((" CHS %x %x %x (%d %d %d) --> %lx ( %ld)\n",
BeginHead,
BeginSector,
BeginCylinder,
BeginHead,
BeginSector,
BeginCylinder,
BeginCylinder, BeginHead, BeginSector,
BeginCylinder, BeginHead, BeginSector,
startPos, startPos));
return startPos;
@ -385,6 +387,7 @@ COUNT processtable(int table_type,COUNT ptDrive, BYTE ptHead, UWORD ptCylinder,
BYTE *p;
int partition_chain = 0;
int ret;
ULONG newStartPos;
restart: /* yes, it's a GOTO >:-) */
@ -395,8 +398,7 @@ restart: /* yes, it's a GOTO >:-) */
PartCodePrintf(("searching partition table at %x %x %x %x %lx\n",
ptDrive, ptHead, ptCylinder,
ptSector, ptAccuOff));
ptDrive, ptCylinder, ptHead, ptSector, ptAccuOff));
/* Read partition table */
for ( retry = N_RETRY; --retry >= 0; )
@ -437,110 +439,109 @@ restart: /* yes, it's a GOTO >:-) */
/* Walk through the table, add DOS partitions to global
array and process extended partitions */
for (ptemp_part = &temp_part[0];
ptemp_part < &temp_part[N_PART] && nUnits < NDEV; ptemp_part++)
{
/* when searching the EXT chain,
must skip primary partitions */
if ( ( (table_type==PRIMARY)
|| ( (table_type==EXTENDED) && (partition_chain!=0) ) ) &&
( ptemp_part->peFileSystem == FAT12 ||
ptemp_part->peFileSystem == FAT16SMALL ||
ptemp_part->peFileSystem == FAT16LARGE) )
{
struct dos_partitionS *pdos_partition;
struct media_info *pmiarray = getPMiarray(nUnits);
pmiarray->mi_offset = ptemp_part->peStartSector + ptAccuOff;
PartCodePrintf(("mioffset1 = %lx - ", pmiarray->mi_offset));
pmiarray->mi_drive = ptDrive;
pmiarray->mi_partidx = nPartitions;
{
ULONG newStartPos = StartSector(ptDrive,
ptemp_part->peBeginHead,
ptemp_part->peBeginSector,
ptemp_part->peBeginCylinder,
ptemp_part->peStartSector,
ptAccuOff);
if (newStartPos != pmiarray->mi_offset)
{
printf("PART TABLE mismatch for drive %x, CHS=%d %d %d, startsec %d, offset %ld\n",
ptemp_part->peBeginCylinder,
ptemp_part->peBeginHead,
ptemp_part->peBeginSector,
ptemp_part->peStartSector,
ptAccuOff);
printf(" old startpos = %ld, new startpos = %ld, taking new\n",
pmiarray->mi_offset, newStartPos);
pmiarray->mi_offset = newStartPos;
}
}
nUnits++;
pdos_partition = &dos_partition[nPartitions];
pdos_partition->peDrive = ptDrive;
pdos_partition->peBootable = ptemp_part->peBootable;
pdos_partition->peBeginHead = ptemp_part->peBeginHead;
pdos_partition->peBeginSector = ptemp_part->peBeginSector;
pdos_partition->peBeginCylinder=ptemp_part->peBeginCylinder;
pdos_partition->peFileSystem =ptemp_part->peFileSystem;
pdos_partition->peEndHead =ptemp_part->peEndHead;
pdos_partition->peEndSector =ptemp_part->peEndSector;
pdos_partition->peEndCylinder =ptemp_part->peEndCylinder;
pdos_partition->peStartSector =ptemp_part->peStartSector;
pdos_partition->peSectors =ptemp_part->peSectors;
pdos_partition->peAbsStart =ptemp_part->peStartSector + ptAccuOff;
PartCodePrintf(("DOS PARTITION drive %x CHS %x-%x-%x %x-%x-%x %lx %lx %lx FS %x\n",
pdos_partition->peDrive,
pdos_partition->peBeginCylinder,
pdos_partition->peBeginHead ,
pdos_partition->peBeginSector ,
pdos_partition->peEndCylinder ,
pdos_partition->peEndHead ,
pdos_partition->peEndSector ,
pdos_partition->peStartSector ,
pdos_partition->peSectors ,
pdos_partition->peAbsStart ,
pdos_partition->peFileSystem
));
nPartitions++;
}
}
for (ptemp_part = &temp_part[0];
ptemp_part < &temp_part[N_PART] && nUnits < NDEV; ptemp_part++)
if ( (table_type==PRIMARY) ||
( (table_type==EXTENDED) && (partition_chain!=0) ) )
{
if ( (table_type==EXTENDED) &&
(ptemp_part->peFileSystem == EXTENDED ||
ptemp_part->peFileSystem == EXTENDED_INT32 ) )
{
/* restart with new extended part table, don't recurs */
partition_chain++;
ptHead = ptemp_part->peBeginHead;
ptCylinder = ptemp_part->peBeginCylinder;
ptSector = ptemp_part->peBeginSector;
ptAccuOff = ptemp_part->peStartSector + ptAccuOff;
goto restart;
}
for (ptemp_part = &temp_part[0];
ptemp_part < &temp_part[N_PART] && nUnits < NDEV; ptemp_part++)
{
if ( ptemp_part->peFileSystem == FAT12 ||
ptemp_part->peFileSystem == FAT16SMALL ||
ptemp_part->peFileSystem == FAT16LARGE )
{
struct dos_partitionS *pdos_partition;
struct media_info *pmiarray = getPMiarray(nUnits);
pmiarray->mi_offset = ptemp_part->peStartSector + ptAccuOff;
PartCodePrintf(("mioffset1 = %lx - ", pmiarray->mi_offset));
pmiarray->mi_drive = ptDrive;
pmiarray->mi_partidx = nPartitions;
newStartPos = StartSector(ptDrive,
ptemp_part->peBeginCylinder,
ptemp_part->peBeginHead,
ptemp_part->peBeginSector,
ptemp_part->peStartSector,
ptAccuOff);
if (newStartPos != pmiarray->mi_offset)
{
printf("PART TABLE mismatch for drive %x, CHS=%d %d %d, startsec %d, offset %ld\n",
ptDrive,
ptemp_part->peBeginCylinder, ptemp_part->peBeginHead,ptemp_part->peBeginSector,
ptemp_part->peStartSector, ptAccuOff);
printf(" old startpos = %ld, new startpos = %ld, using new\n",
pmiarray->mi_offset, newStartPos);
pmiarray->mi_offset = newStartPos;
}
nUnits++;
pdos_partition = &dos_partition[nPartitions];
pdos_partition->peDrive = ptDrive;
pdos_partition->peBootable = ptemp_part->peBootable;
pdos_partition->peBeginHead = ptemp_part->peBeginHead;
pdos_partition->peBeginSector = ptemp_part->peBeginSector;
pdos_partition->peBeginCylinder=ptemp_part->peBeginCylinder;
pdos_partition->peFileSystem =ptemp_part->peFileSystem;
pdos_partition->peEndHead =ptemp_part->peEndHead;
pdos_partition->peEndSector =ptemp_part->peEndSector;
pdos_partition->peEndCylinder =ptemp_part->peEndCylinder;
pdos_partition->peStartSector =ptemp_part->peStartSector;
pdos_partition->peSectors =ptemp_part->peSectors;
pdos_partition->peAbsStart =ptemp_part->peStartSector + ptAccuOff;
PartCodePrintf(("DOS PARTITION drive %x CHS %x-%x-%x %x-%x-%x %lx %lx %lx FS %x\n",
pdos_partition->peDrive,
pdos_partition->peBeginCylinder,pdos_partition->peBeginHead ,pdos_partition->peBeginSector ,
pdos_partition->peEndCylinder ,pdos_partition->peEndHead ,pdos_partition->peEndSector ,
pdos_partition->peStartSector ,
pdos_partition->peSectors ,
pdos_partition->peAbsStart ,
pdos_partition->peFileSystem
));
nPartitions++;
}
}
}
/* search for EXT partitions only on 2. run */
if (table_type==EXTENDED)
{
for (ptemp_part = &temp_part[0];
ptemp_part < &temp_part[N_PART] && nUnits < NDEV; ptemp_part++)
{
if ( (ptemp_part->peFileSystem == EXTENDED ||
ptemp_part->peFileSystem == EXTENDED_INT32 ) )
{
/* restart with new extended part table, don't recurs */
partition_chain++;
ptHead = ptemp_part->peBeginHead;
ptCylinder = ptemp_part->peBeginCylinder;
ptSector = ptemp_part->peBeginSector;
ptAccuOff = ptemp_part->peStartSector + ptAccuOff;
goto restart;
}
}
}
return TRUE;
}
COUNT blk_driver(rqptr rp)
COUNT FAR init_call_blk_driver(rqptr rp)
{
if (rp->r_unit >= nUnits && rp->r_command != C_INIT)
return failure(E_UNIT);
@ -552,7 +553,7 @@ COUNT blk_driver(rqptr rp)
return ((*dispatch[rp->r_command]) (rp));
}
static WORD init(rqptr rp)
WORD _dsk_init(rqptr rp)
{
extern COUNT fl_nrdrives(VOID);
COUNT HardDrive,
@ -607,6 +608,9 @@ static WORD init(rqptr rp)
primary partitions are added/removed, but
thats the way it is (hope I got it right)
TE (with a little help from my friends) */
PartCodePrintf(("DSK init: found %d disk drives\n",nHardDisk));
for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++)
{
@ -905,7 +909,6 @@ static WORD Genblkdev(rqptr rp)
}
case 0x0866: /* get volume serial number */
{
REG COUNT i;
struct Gioc_media FAR * gioc = (struct Gioc_media FAR *) rp->r_trans;
struct FS_info FAR * fs = &fsarray[rp->r_unit];
@ -992,19 +995,23 @@ WORD blockio(rqptr rp)
}
if (count)
if (count && FP_SEG(trans) != 0xffff)
{
ret = action((WORD) miarray[rp->r_unit].mi_drive, head, track, sector,
count, trans);
}
else
{
count = 1;
/* buffer crosses DMA boundary, use scratchpad */
/* buffer crosses DMA boundary, use scratchpad */
/* use scratchpad also, if going to HIGH memory */
if (cmd != C_INPUT)
fbcopy(trans, dma_scratch, SEC_SIZE);
fbcopy(trans, dma_scratch_buffer, SEC_SIZE);
ret = action((WORD) miarray[rp->r_unit].mi_drive, head, track, sector,
1, dma_scratch);
1, dma_scratch_buffer);
if (cmd == C_INPUT)
fbcopy(dma_scratch, trans, SEC_SIZE);
fbcopy(dma_scratch_buffer, trans, SEC_SIZE);
}
if (ret != 0)
fl_reset((WORD) miarray[rp->r_unit].mi_drive);

View File

@ -28,6 +28,9 @@
; $Id$
;
; $Log$
; Revision 1.4 2001/03/21 02:56:25 bartoldeman
; See history.txt for changes. Bug fixes and HMA support are the main ones.
;
; Revision 1.3 2000/05/25 20:56:21 jimtabor
; Fixed project history
;
@ -72,12 +75,12 @@
%include "segs.inc"
%include "stacks.inc"
segment _TEXT
extern _int21_syscall:wrt TGROUP
extern _int25_handler:wrt TGROUP
extern _int26_handler:wrt TGROUP
extern _set_stack:wrt TGROUP
extern _restore_stack:wrt TGROUP
segment HMA_TEXT
extern _int21_syscall:wrt HGROUP
extern _int25_handler:wrt HGROUP
extern _int26_handler:wrt HGROUP
extern _set_stack:wrt HMA_TEXT
extern _restore_stack:wrt HGROUP
extern _error_tos:wrt DGROUP
extern _char_api_tos:wrt DGROUP
extern _disk_api_tos:wrt DGROUP
@ -100,12 +103,12 @@ segment _TEXT
extern _Int21AX:wrt DGROUP
global _cpm_entry
global _int20_handler
global _int21_handler
global _low_int25_handler
global _low_int26_handler
global _int27_handler
global reloc_call_cpm_entry
global reloc_call_int20_handler
global reloc_call_int21_handler
global reloc_call_low_int25_handler
global reloc_call_low_int26_handler
global reloc_call_int27_handler
;
@ -118,7 +121,7 @@ segment _TEXT
; function after the call. What we do is convert it to a normal call and
; fudge the stack to look like an int 21h call.
;
_cpm_entry:
reloc_call_cpm_entry:
; Stack is:
; return offset
; psp seg
@ -159,7 +162,7 @@ _cpm_entry:
cmp cl,024h
jbe cpm_error
mov ah,cl ; get the call # from cl to ah
jmp short _int21_handler ; do the system call
jmp short reloc_call_int21_handler ; do the system call
cpm_error: mov al,0
iret
@ -189,7 +192,7 @@ _RestartSysCall:
; VOID INRPT far
; int20_handler(iregs UserRegs)
;
_int20_handler:
reloc_call_int20_handler:
mov ah,0 ; terminate through int 21h
@ -199,7 +202,7 @@ _int20_handler:
; VOID INRPT far
; int21_handler(iregs UserRegs)
;
_int21_handler:
reloc_call_int21_handler:
;
; Create the stack frame for C call. This is done to
; preserve machine state and provide a C structure for
@ -347,7 +350,7 @@ dos_crit_sect:
; VOID INRPT far
; int27_handler(iregs UserRegs)
;
_int27_handler:
reloc_call_int27_handler:
;
; First convert the memory to paragraphs
;
@ -360,7 +363,7 @@ _int27_handler:
; ... then use the standard system call
;
mov ax,3100h
jmp _int21_handler ; terminate through int 21h
jmp reloc_call_int21_handler ; terminate through int 21h
;
; I really do need to get rid of this because it's the only thing stopping
@ -368,7 +371,7 @@ _int27_handler:
;
stkframe dd 0
_low_int25_handler:
reloc_call_low_int25_handler:
sti
pushf
push ax
@ -417,7 +420,7 @@ _low_int25_handler:
; flag image on the stack.
_low_int26_handler:
reloc_call_low_int26_handler:
sti
pushf
push ax
@ -478,12 +481,6 @@ PSP_USERSP equ 2eh
PSP_USERSS equ 30h
;
; Default Int 24h handler -- always returns fail
;
global _int24_handler
_int24_handler: mov al,FAIL
iret
;
; COUNT

View File

@ -30,6 +30,9 @@
; $Id$
;
; $Log$
; Revision 1.4 2001/03/21 02:56:25 bartoldeman
; See history.txt for changes. Bug fixes and HMA support are the main ones.
;
; Revision 1.3 2000/05/25 20:56:21 jimtabor
; Fixed project history
;
@ -78,7 +81,7 @@
%include "segs.inc"
segment _TEXT
segment HMA_TEXT
; _execrh
; Execute Device Request
;

View File

@ -36,8 +36,8 @@ static BYTE *fatdirRcsId = "$Id$";
/*
* $Log$
* Revision 1.10 2001/03/19 04:50:56 bartoldeman
* See history.txt for overview: put kernel 2022beo1 into CVS
* Revision 1.11 2001/03/21 02:56:25 bartoldeman
* See history.txt for changes. Bug fixes and HMA support are the main ones.
*
* Revision 1.10 2001/03/08 21:00:00 bartoldeman
* Fix handling of very long path names (Tom Ehlert)
@ -271,6 +271,9 @@ struct f_node FAR *dir_open(BYTE FAR * dirname)
/* Convert the name into an absolute name for */
/* comparison... */
/* first the file name with trailing spaces... */
memset(TempBuffer, ' ', FNAME_SIZE+FEXT_SIZE);
for (i = 0; i < FNAME_SIZE; i++)
{
if (*p != '\0' && *p != '.' && *p != '/' && *p != '\\')
@ -279,9 +282,6 @@ struct f_node FAR *dir_open(BYTE FAR * dirname)
break;
}
for (; i < FNAME_SIZE; i++)
TempBuffer[i] = ' ';
/* and the extension (don't forget to */
/* add trailing spaces)... */
if (*p == '.')
@ -293,8 +293,6 @@ struct f_node FAR *dir_open(BYTE FAR * dirname)
else
break;
}
for (; i < FEXT_SIZE; i++)
TempBuffer[i + FNAME_SIZE] = ' ';
/* Now search through the directory to */
/* find the entry... */
@ -586,12 +584,7 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name)
BYTE FAR *ptr;
static BYTE local_name[FNAME_SIZE + 1],
local_ext[FEXT_SIZE + 1],
Tname[65];
fsncopy(name, (BYTE FAR *)&Tname, sizeof(Tname));
Tname[sizeof(Tname)-1]=0;
local_ext[FEXT_SIZE + 1];
/*
printf("ff %s", Tname);
*/
@ -610,7 +603,7 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name)
dmp->dm_attr_srch = attr | D_RDONLY | D_ARCHIVE;
/* Parse out the drive, file name and file extension. */
i = ParseDosName((BYTE FAR *)&Tname, &nDrive, &LocalPath[2], local_name, local_ext, TRUE);
i = ParseDosName((BYTE FAR *)name, &nDrive, &LocalPath[2], local_name, local_ext, TRUE);
if (i != SUCCESS)
return i;
/*
@ -639,28 +632,16 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name)
/* copy the part of the pattern which belongs to the filename and is fixed */
for (p = local_name, i = 0; i < FNAME_SIZE && *p && *p != '*'; ++p, ++i)
SearchDir.dir_name[i] = *p;
if (*p == '*')
{
for (; i < FNAME_SIZE; ++i)
SearchDir.dir_name[i] = '?';
while (*++p) ;
}
else
for (; i < FNAME_SIZE; i++)
SearchDir.dir_name[i] = ' ';
for (; i < FNAME_SIZE; ++i)
SearchDir.dir_name[i] = *p == '*' ? '?' : ' ';
/* and the extension (don't forget to add trailing spaces)... */
for (p = local_ext, i = 0; i < FEXT_SIZE && *p && *p != '*'; ++p, ++i)
SearchDir.dir_ext[i] = *p;
if (*p == '*')
{
for (; i < FEXT_SIZE; ++i)
SearchDir.dir_ext[i] = '?';
while (*++p) ;
}
else
for (; i < FEXT_SIZE; i++)
SearchDir.dir_ext[i] = ' ';
for (; i < FEXT_SIZE; ++i)
SearchDir.dir_ext[i] = *p == '*' ? '?' : ' ';
/* Convert everything to uppercase. */
DosUpFMem(SearchDir.dir_name, FNAME_SIZE + FEXT_SIZE);
@ -912,9 +893,6 @@ COUNT dos_findnext(void)
static VOID pop_dmp(dmatch FAR * dmp, struct f_node FAR * fnp)
{
COUNT idx;
BYTE FAR *p;
BYTE FAR *q;
dmp->dm_attr_fnd = fnp->f_dir.dir_attrib;
dmp->dm_time = fnp->f_dir.dir_time;
@ -925,38 +903,43 @@ static VOID pop_dmp(dmatch FAR * dmp, struct f_node FAR * fnp)
dmp->dm_flags.f_ddir = fnp->f_flags.f_ddir;
dmp->dm_flags.f_dmod = fnp->f_flags.f_dmod;
dmp->dm_flags.f_dnew = fnp->f_flags.f_dnew;
p = dmp->dm_name;
if (fnp->f_dir.dir_name[0] == '.')
{
for (idx = 0, q = (BYTE FAR *) fnp->f_dir.dir_name;
idx < FNAME_SIZE; idx++)
{
if (*q == ' ')
break;
*p++ = *q++;
}
}
else
{
for (idx = 0, q = (BYTE FAR *) fnp->f_dir.dir_name;
idx < FNAME_SIZE; idx++)
{
if (*q == ' ')
break;
*p++ = *q++;
}
if (fnp->f_dir.dir_ext[0] != ' ')
{
*p++ = '.';
for (idx = 0, q = (BYTE FAR *) fnp->f_dir.dir_ext; idx < FEXT_SIZE; idx++)
{
if (*q == ' ')
break;
*p++ = *q++;
}
}
}
*p++ = NULL;
ConvertName83ToNameSZ((BYTE FAR *)dmp->dm_name, (BYTE FAR *) fnp->f_dir.dir_name);
}
#endif
/*
this receives a name in 11 char field NAME+EXT and builds
a zeroterminated string
*/
void ConvertName83ToNameSZ(BYTE FAR *destSZ, BYTE FAR *srcFCBName)
{
int loop;
int noExtension = FALSE;
if (*srcFCBName == '.')
{
noExtension = TRUE;
}
for (loop = FNAME_SIZE; --loop >= 0; srcFCBName++)
{
if (*srcFCBName != ' ')
*destSZ++ = *srcFCBName;
}
if (!noExtension) /* not for ".", ".." */
{
if (*srcFCBName != ' ')
{
*destSZ++ = '.';
for (loop = FEXT_SIZE; --loop >= 0; srcFCBName++)
{
if (*srcFCBName != ' ')
*destSZ++ = *srcFCBName;
}
}
}
*destSZ = '\0';
}

View File

@ -36,8 +36,8 @@ BYTE *RcsId = "$Id$";
/*
* $Log$
* Revision 1.9 2001/03/19 04:50:56 bartoldeman
* See history.txt for overview: put kernel 2022beo1 into CVS
* Revision 1.10 2001/03/21 02:56:25 bartoldeman
* See history.txt for changes. Bug fixes and HMA support are the main ones.
*
* Revision 1.9 2001/03/08 21:00:00 bartoldeman
* Disabled select_unit() since it's not used
@ -348,7 +348,7 @@ COUNT FAR init_call_dos_close(COUNT fd)
/* */
/* split a path into it's component directory and file name */
/* */
static struct f_node FAR *
struct f_node FAR *
split_path(BYTE FAR * path, BYTE * dname, BYTE * fname, BYTE * fext)
{
REG struct f_node FAR *fnp;
@ -1506,13 +1506,11 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err)
UWORD secsize;
UCOUNT to_xfer = count;
#ifdef DEBUG
#if defined( DEBUG ) && 0
if (bDumpRdWrParms)
{
printf("readblock:\n");
printf(" fd buffer count\n -- ------ -----\n");
printf(" %02d %04x:%04x %d\n",
fd, (COUNT) FP_SEG(buffer), (COUNT) FP_OFF(buffer), count);
printf("readblock:fd %02x buffer %04x:%04x count %x\n",
fd, FP_SEG(buffer), FP_OFF(buffer), count);
}
#endif
/* Translate the fd into an fnode pointer, since all internal */
@ -1690,9 +1688,7 @@ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err)
#ifdef DEBUG
if (bDumpRdWrParms)
{
printf("writeblock:\n");
printf(" fd buffer count\n -- ------ -----\n");
printf(" %02d %04x:%04x %d\n",
printf("writeblock: fd %02d buffer %04x:%04x count %d\n",
fd, (COUNT) FP_SEG(buffer), (COUNT) FP_OFF(buffer), count);
}
#endif

View File

@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$";
/*
* $Log$
* Revision 1.7 2001/03/21 02:56:26 bartoldeman
* See history.txt for changes. Bug fixes and HMA support are the main ones.
*
* Revision 1.6 2000/08/06 05:50:17 jimtabor
* Add new files and update cvs with patches and changes
*
@ -722,29 +725,29 @@ void FcbNameInit(fcb FAR * lpFcb, BYTE * pszBuffer, COUNT * pCurDrive)
{
BYTE FAR *lpszFcbFname,
FAR * lpszFcbFext;
COUNT nDrvIdx,
nFnameIdx,
nFextIdx;
COUNT loop;
/* Build a traditional DOS file name */
lpszFcbFname = (BYTE FAR *) lpFcb->fcb_fname;
if (lpFcb->fcb_drive != 0)
{
*pCurDrive = lpFcb->fcb_drive;
pszBuffer[0] = 'A' + lpFcb->fcb_drive - 1;
pszBuffer[1] = ':';
nDrvIdx = 2;
pszBuffer += 2;
}
else
{
*pCurDrive = default_drive + 1;
nDrvIdx = 0;
}
for (nFnameIdx = 0; nFnameIdx < FNAME_SIZE; nFnameIdx++)
ConvertName83ToNameSZ((BYTE FAR *)pszBuffer, (BYTE FAR *) lpFcb->fcb_fname);
/*
lpszFcbFname = (BYTE FAR *) lpFcb->fcb_fname;
for (loop = FNAME_SIZE; --loop >= 0; )
{
if (*lpszFcbFname != ' ')
pszBuffer[nDrvIdx + nFnameIdx] = *lpszFcbFname++;
*pszBuffer++ = *lpszFcbFname++;
else
break;
}
@ -752,19 +755,17 @@ void FcbNameInit(fcb FAR * lpFcb, BYTE * pszBuffer, COUNT * pCurDrive)
lpszFcbFext = (BYTE FAR *) lpFcb->fcb_fext;
if (*lpszFcbFext != ' ')
{
pszBuffer[nDrvIdx + nFnameIdx++] = '.';
for (nFextIdx = 0; nFextIdx < FEXT_SIZE; nFextIdx++)
*pszBuffer++ = '.';
for (loop = FEXT_SIZE; --loop >= 0; )
{
if (*lpszFcbFext != ' ')
pszBuffer[nDrvIdx + nFnameIdx + nFextIdx] =
*lpszFcbFext++;
*pszBuffer++ = *lpszFcbFext++;
else
break;
break;
}
}
else
nFextIdx = 0;
pszBuffer[nDrvIdx + nFnameIdx + nFextIdx] = '\0';
*pszBuffer = '\0';
*/
}
BOOL FcbOpen(xfcb FAR * lpXfcb)

View File

@ -36,6 +36,9 @@ static BYTE *Globals_hRcsId = "$Id$";
/*
* $Log$
* Revision 1.7 2001/03/21 02:56:26 bartoldeman
* See history.txt for changes. Bug fixes and HMA support are the main ones.
*
* Revision 1.6 2000/12/16 01:38:35 jimtabor
* Added patches from Bart Oldeman
*
@ -214,7 +217,7 @@ static BYTE *Globals_hRcsId = "$Id$";
#define PARSE_MAX 67 /* maximum # of bytes in path */
#define NFILES 16 /* number of files in table */
#define NFCBS 16 /* number of fcbs */
#define NDEVS 8 /* number of supported devices */
#define NDEVS 26 /* number of supported devices */
#define NSTACKS 8 /* number of stacks */
#define NLAST 6 /* last drive */
#define NAMEMAX PARSE_MAX /* Maximum path for CDS */
@ -295,16 +298,18 @@ struct buffer
FAR *b_next; /* form linked list for LRU */
BYTE b_unit; /* disk for this buffer */
BYTE b_flag; /* buffer flags */
UWORD b_blkno; /* block for this buffer */
ULONG b_blkno; /* block for this buffer */
/* DOS-C: 0xffff for huge block numbers */
BYTE b_copies; /* number of copies to write */
UBYTE b_offset_lo; /* span between copies (low) */
union
#if 0 /*TE*/
union
{
struct dpb FAR *_b_dpbp; /* pointer to DPB */
LONG _b_huge_blkno; /* DOS-C: actual block number if >= 0xffff */
}
_b;
#endif
UBYTE b_offset_hi; /* DOS-C: span between copies (high) */
UBYTE b_unused;
BYTE b_buffer[BUFFERSIZE]; /* 512 byte sectors for now */
@ -351,7 +356,14 @@ extern COUNT *
disk_api_tos, /* API handler stack - disk fns */
char_api_tos; /* API handler stack - char fns */
extern BYTE
FAR last; /* first available byte of ram */
FAR _InitTextStart; /* first available byte of ram */
extern BYTE
FAR _HMATextAvailable, /* first byte of available CODE area */
FAR _HMATextStart[], /* first byte of HMAable CODE area */
FAR _HMATextEnd[]; /* and the last byte of it */
extern
BYTE DosLoadedInHMA; /* if InitHMA has moved DOS up */
extern struct ClockRecord
ClkRecord;
@ -593,8 +605,8 @@ GLOBAL struct f_node FAR
* f_nodes; /* pointer to the array */
GLOBAL struct buffer
FAR *lastbuf, /* tail of ditto */
FAR * buffers; /* pointer to array of track buffers */
FAR *lastbuf; /* tail of ditto */
/* FAR * buffers; /* pointer to array of track buffers */
GLOBAL BYTE /* scratchpad used for working around */
FAR * dma_scratch; /* DMA transfers during disk I/O */
@ -675,6 +687,7 @@ VOID FAR restore_stack(VOID);
WORD execrh(request FAR *, struct dhdr FAR *);
#endif
VOID FAR init_call_execrh(request FAR *, struct dhdr FAR *);
VOID FAR reloc_call_execrh(request FAR *, struct dhdr FAR *);
VOID exit(COUNT);
/*VOID INRPT FAR handle_break(VOID); */
VOID tmark(VOID);
@ -746,11 +759,12 @@ VOID fputbyte();
#ifdef I86
#define setvec(n, isr) (void)(*(VOID (INRPT FAR * FAR *)())(4 * (n)) = (isr))
#endif
#define is_leap_year(y) ((y) & 3 ? 0 : (y) % 100 ? 1 : (y) % 400 ? 0 : 1)
/*#define is_leap_year(y) ((y) & 3 ? 0 : (y) % 100 ? 1 : (y) % 400 ? 0 : 1) */
/* ^Break handling */
void spawn_int23(void); /* procsupt.asm */
void FAR _init_call_spawn_int23(void); /* procsupt.asm */
int control_break(void); /* break.c */
void handle_break(void); /* break.c */
GLOBAL BYTE ReturnAnyDosVersionExpected;

View File

@ -10,19 +10,22 @@
* calls for the latter functions therefore need to be wrapped up with far
* entry points.
*/
#define DosExec init_call_DosExec
#define DosMemAlloc init_call_DosMemAlloc
#define dos_close init_call_dos_close
#define dos_getdate init_call_dos_getdate
#define dos_gettime init_call_dos_gettime
#define dos_open init_call_dos_open
#define dos_read init_call_dos_read
#define execrh init_call_execrh
#define fatal init_call_fatal
#define fbcopy init_call_fbcopy
#define printf init_call_printf
#define scopy init_call_scopy
#define sti init_call_sti
#define strcmp init_call_strcmp
#define strlen init_call_strlen
#define WritePCClock init_call_WritePCClock
#define DosExec reloc_call_DosExec
#define DosMemAlloc reloc_call_DosMemAlloc
#define dos_close reloc_call_dos_close
#define dos_getdate reloc_call_dos_getdate
#define dos_gettime reloc_call_dos_gettime
#define dos_open reloc_call_dos_open
#define dos_read reloc_call_dos_read
#define execrh reloc_call_execrh
#define fatal reloc_call_fatal
#define fmemcpy reloc_call_fmemcpy
#define memcpy reloc_call_memcpy
#define fmemset reloc_call_fmemset
#define printf reloc_call_printf
#define strcpy reloc_call_strcpy
#define sti reloc_call_sti
#define strcmp reloc_call_strcmp
#define strlen reloc_call_strlen
#define WritePCClock reloc_call_WritePCClock
#define DaysFromYearMonthDay reloc_call_DaysFromYearMonthDay

View File

@ -30,6 +30,9 @@
; $Id$
;
; $Log$
; Revision 1.7 2001/03/21 02:56:26 bartoldeman
; See history.txt for changes. Bug fixes and HMA support are the main ones.
;
; Revision 1.6 2000/08/06 05:50:17 jimtabor
; Add new files and update cvs with patches and changes
;
@ -88,14 +91,14 @@
%include "segs.inc"
%include "stacks.inc"
segment _TEXT
segment HMA_TEXT
extern _nul_dev:wrt DGROUP
extern _umb_start:wrt DGROUP
extern _UMB_top:wrt DGROUP
extern _syscall_MUX14:wrt _TEXT
extern _syscall_MUX14:wrt HMA_TEXT
global _int2f_handler
_int2f_handler:
global reloc_call_int2f_handler
reloc_call_int2f_handler:
sti ; Enable interrupts
cmp ah,11h ; Network interrupt?
jne Int2f3 ; No, continue
@ -336,6 +339,8 @@ int2f_call:
; B2h UMB segment number is invalid
;
;
segment INIT_TEXT
global _Umb_Test
_Umb_Test
push bp
@ -345,8 +350,8 @@ _Umb_Test
push dx
push bx
mov ax,DGROUP
mov ds,ax
mov ax, DGROUP
mov ds, ax
mov ax,4300h ; is there a xms driver installed?
int 2fh
@ -404,4 +409,4 @@ umbt_error: dec ax
pop ds
pop es
pop bp
retf ; this was called FAR.
ret ; this was called NEAR!!

View File

@ -36,8 +36,8 @@ BYTE *RcsId = "$Id$";
/*
* $Log$
* Revision 1.13 2001/03/19 04:50:56 bartoldeman
* See history.txt for overview: put kernel 2022beo1 into CVS
* Revision 1.14 2001/03/21 02:56:26 bartoldeman
* See history.txt for changes. Bug fixes and HMA support are the main ones.
*
* Revision 1.13 2001/03/08 21:00:00 bartoldeman
* MCB chain corruption and DosFindNext fix (thanks Martin Stromberg and Tom Ehlert)
@ -309,14 +309,36 @@ VOID int21_syscall(iregs FAR * irp)
}
}
static int debug_cnt;
VOID int21_service(iregs FAR * r)
{
COUNT rc = 0,
rc1;
ULONG lrc;
psp FAR *p = MK_FP(cu_psp, 0);
void FAR *FP_DS_DX = MK_FP(r->DS, r->DX); /* this is saved so often,
that this saves ~100 bytes */
#define CLEAR_CARRY_FLAG() r->FLAGS &= ~FLG_CARRY
#define SET_CARRY_FLAG() r->FLAGS |= FLG_CARRY
p->ps_stack = (BYTE FAR *) r;
switch(r->AH)
{
case 0x2a: /*DosGetDate */
case 0x2b: /*DosSetDate */
case 0x2c: /*DosGetTime */
case 0x2d: /*DosSetDate */
break;
default:
debug_cnt++; /* debuggable statement */
}
#ifdef DEBUG
if (bDumpRegs)
@ -422,21 +444,20 @@ dispatch:
case 0x09:
{
static COUNT scratch;
BYTE FAR *p = MK_FP(r->DS, r->DX),
FAR * q;
q = p;
BYTE FAR * q;
q = FP_DS_DX;
while (*q != '$')
++q;
DosWrite(STDOUT, q - p, p, (COUNT FAR *) & scratch);
DosWrite(STDOUT, q - (BYTE FAR*)FP_DS_DX, FP_DS_DX, (COUNT FAR *) & scratch);
}
r->AL = '$';
break;
/* Buffered Keyboard Input */
case 0x0a:
((keyboard FAR *) MK_FP(r->DS, r->DX))->kb_count = 0;
sti((keyboard FAR *) MK_FP(r->DS, r->DX));
((keyboard FAR *) MK_FP(r->DS, r->DX))->kb_count -= 2;
((keyboard FAR *) FP_DS_DX)->kb_count = 0;
sti((keyboard FAR *) FP_DS_DX);
((keyboard FAR *) FP_DS_DX)->kb_count -= 2;
break;
/* Check Stdin Status */
@ -477,35 +498,35 @@ dispatch:
break;
case 0x0f:
if (FcbOpen(MK_FP(r->DS, r->DX)))
if (FcbOpen(FP_DS_DX))
r->AL = 0;
else
r->AL = 0xff;
break;
case 0x10:
if (FcbClose(MK_FP(r->DS, r->DX)))
if (FcbClose(FP_DS_DX))
r->AL = 0;
else
r->AL = 0xff;
break;
case 0x11:
if (FcbFindFirst(MK_FP(r->DS, r->DX)))
if (FcbFindFirst(FP_DS_DX))
r->AL = 0;
else
r->AL = 0xff;
break;
case 0x12:
if (FcbFindNext(MK_FP(r->DS, r->DX)))
if (FcbFindNext(FP_DS_DX))
r->AL = 0;
else
r->AL = 0xff;
break;
case 0x13:
if (FcbDelete(MK_FP(r->DS, r->DX)))
if (FcbDelete(FP_DS_DX))
r->AL = 0;
else
r->AL = 0xff;
@ -513,7 +534,7 @@ dispatch:
case 0x14:
{
if (FcbRead(MK_FP(r->DS, r->DX), &CritErrCode))
if (FcbRead(FP_DS_DX, &CritErrCode))
r->AL = 0;
else
r->AL = CritErrCode;
@ -522,7 +543,7 @@ dispatch:
case 0x15:
{
if (FcbWrite(MK_FP(r->DS, r->DX), &CritErrCode))
if (FcbWrite(FP_DS_DX, &CritErrCode))
r->AL = 0;
else
r->AL = CritErrCode;
@ -530,14 +551,14 @@ dispatch:
}
case 0x16:
if (FcbCreate(MK_FP(r->DS, r->DX)))
if (FcbCreate(FP_DS_DX))
r->AL = 0;
else
r->AL = 0xff;
break;
case 0x17:
if (FcbRename(MK_FP(r->DS, r->DX)))
if (FcbRename(FP_DS_DX))
r->AL = 0;
else
r->AL = 0xff;
@ -565,7 +586,7 @@ dispatch:
{
psp FAR *p = MK_FP(cu_psp, 0);
p->ps_dta = MK_FP(r->DS, r->DX);
p->ps_dta = FP_DS_DX;
dos_setdta(p->ps_dta);
}
break;
@ -625,7 +646,7 @@ dispatch:
/* Random read using FCB */
case 0x21:
{
if (FcbRandomRead(MK_FP(r->DS, r->DX), &CritErrCode))
if (FcbRandomRead(FP_DS_DX, &CritErrCode))
r->AL = 0;
else
r->AL = CritErrCode;
@ -635,7 +656,7 @@ dispatch:
/* Random write using FCB */
case 0x22:
{
if (FcbRandomWrite(MK_FP(r->DS, r->DX), &CritErrCode))
if (FcbRandomWrite(FP_DS_DX, &CritErrCode))
r->AL = 0;
else
r->AL = CritErrCode;
@ -644,7 +665,7 @@ dispatch:
/* Get file size in records using FCB */
case 0x23:
if (FcbGetFileSize(MK_FP(r->DS, r->DX)))
if (FcbGetFileSize(FP_DS_DX))
r->AL = 0;
else
r->AL = 0xff;
@ -652,13 +673,13 @@ dispatch:
/* Set random record field in FCB */
case 0x24:
FcbSetRandom(MK_FP(r->DS, r->DX));
FcbSetRandom(FP_DS_DX);
break;
/* Set Interrupt Vector */
case 0x25:
{
VOID(INRPT FAR * p) () = MK_FP(r->DS, r->DX);
VOID(INRPT FAR * p) () = FP_DS_DX;
setvec(r->AL, p);
}
@ -676,7 +697,7 @@ dispatch:
/* Read random record(s) using FCB */
case 0x27:
{
if (FcbRandomBlockRead(MK_FP(r->DS, r->DX), r->CX, &CritErrCode))
if (FcbRandomBlockRead(FP_DS_DX, r->CX, &CritErrCode))
r->AL = 0;
else
r->AL = CritErrCode;
@ -686,7 +707,7 @@ dispatch:
/* Write random record(s) using FCB */
case 0x28:
{
if (FcbRandomBlockWrite(MK_FP(r->DS, r->DX), r->CX, &CritErrCode))
if (FcbRandomBlockWrite(FP_DS_DX, r->CX, &CritErrCode))
r->AL = 0;
else
r->AL = CritErrCode;
@ -769,6 +790,34 @@ dispatch:
r->CH = REVISION_MAJOR; /* JPP */
r->CL = REVISION_MINOR;
r->BL = REVISION_SEQ;
if (ReturnAnyDosVersionExpected)
{
/* TE for testing purpose only and NOT
to be documented:
return programs, who ask for version == XX.YY
exactly this XX.YY.
this makes most MS programs more happy.
*/
UBYTE FAR *retp = MK_FP(r->cs, r->ip);
if ( retp[0] == 0x3d && /* cmp ax, xxyy */
(retp[3] == 0x75 || retp[3] == 0x74)) /* je/jne error */
{
r->AL = retp[1];
r->AH = retp[2];
}
else if(retp[0] == 0x86 && /* xchg al,ah */
retp[1] == 0xc4 &&
retp[2] == 0x3d && /* cmp ax, xxyy */
(retp[5] == 0x75 || retp[5] == 0x74)) /* je/jne error */
{
r->AL = retp[4];
r->AH = retp[3];
}
}
break;
/* Keep Program (Terminate and stay resident) */
@ -872,65 +921,65 @@ dispatch:
goto error_invalid;
} else {
/* Get Country Information */
if((rc = DosGetCountryInformation(cntry, MK_FP(r->DS, r->DX))) < 0)
if((rc = DosGetCountryInformation(cntry, FP_DS_DX)) < 0)
goto error_invalid;
r->AX = r->BX = cntry;
}
r->FLAGS &= ~FLG_CARRY;
CLEAR_CARRY_FLAG();
}
break;
/* Dos Create Directory */
case 0x39:
rc = DosMkdir((BYTE FAR *) MK_FP(r->DS, r->DX));
rc = DosMkdir((BYTE FAR *) FP_DS_DX);
if (rc != SUCCESS)
goto error_exit;
else
{
r->FLAGS &= ~FLG_CARRY;
CLEAR_CARRY_FLAG();
}
break;
/* Dos Remove Directory */
case 0x3a:
rc = DosRmdir((BYTE FAR *) MK_FP(r->DS, r->DX));
rc = DosRmdir((BYTE FAR *) FP_DS_DX);
if (rc != SUCCESS)
goto error_exit;
else
{
r->FLAGS &= ~FLG_CARRY;
CLEAR_CARRY_FLAG();
}
break;
/* Dos Change Directory */
case 0x3b:
if ((rc = DosChangeDir((BYTE FAR *) MK_FP(r->DS, r->DX))) < 0)
if ((rc = DosChangeDir((BYTE FAR *) FP_DS_DX)) < 0)
goto error_exit;
else
{
r->FLAGS &= ~FLG_CARRY;
CLEAR_CARRY_FLAG();
}
break;
/* Dos Create File */
case 0x3c:
if ((rc = DosCreat(MK_FP(r->DS, r->DX), r->CX)) < 0)
if ((rc = DosCreat(FP_DS_DX, r->CX)) < 0)
goto error_exit;
else
{
r->AX = rc;
r->FLAGS &= ~FLG_CARRY;
CLEAR_CARRY_FLAG();
}
break;
/* Dos Open */
case 0x3d:
if ((rc = DosOpen(MK_FP(r->DS, r->DX), r->AL)) < 0)
if ((rc = DosOpen(FP_DS_DX, r->AL)) < 0)
goto error_exit;
else
{
r->AX = rc;
r->FLAGS &= ~FLG_CARRY;
CLEAR_CARRY_FLAG();
}
break;
@ -939,12 +988,12 @@ dispatch:
if ((rc = DosClose(r->BX)) < 0)
goto error_exit;
else
r->FLAGS &= ~FLG_CARRY;
CLEAR_CARRY_FLAG();
break;
/* Dos Read */
case 0x3f:
rc = DosRead(r->BX, r->CX, MK_FP(r->DS, r->DX), (COUNT FAR *) & rc1);
rc = DosRead(r->BX, r->CX, FP_DS_DX, (COUNT FAR *) & rc1);
if (rc1 != SUCCESS)
{
@ -953,14 +1002,14 @@ dispatch:
}
else
{
r->FLAGS &= ~FLG_CARRY;
CLEAR_CARRY_FLAG();
r->AX = rc;
}
break;
/* Dos Write */
case 0x40:
rc = DosWrite(r->BX, r->CX, MK_FP(r->DS, r->DX), (COUNT FAR *) & rc1);
rc = DosWrite(r->BX, r->CX, FP_DS_DX, (COUNT FAR *) & rc1);
if (rc1 != SUCCESS)
{
r->AX = -rc1;
@ -968,21 +1017,21 @@ dispatch:
}
else
{
r->FLAGS &= ~FLG_CARRY;
CLEAR_CARRY_FLAG();
r->AX = rc;
}
break;
/* Dos Delete File */
case 0x41:
rc = DosDelete((BYTE FAR *) MK_FP(r->DS, r->DX));
rc = DosDelete((BYTE FAR *) FP_DS_DX);
if (rc < 0)
{
r->AX = -rc;
goto error_out;
}
else
r->FLAGS &= ~FLG_CARRY;
CLEAR_CARRY_FLAG();
break;
/* Dos Seek */
@ -992,8 +1041,8 @@ dispatch:
else
{
r->DX = (lrc >> 16);
r->AX = lrc & 0xffff;
r->FLAGS &= ~FLG_CARRY;
r->AX = (UWORD)lrc;
CLEAR_CARRY_FLAG();
}
break;
@ -1002,21 +1051,21 @@ dispatch:
switch (r->AL)
{
case 0x00:
rc = DosGetFattr((BYTE FAR *) MK_FP(r->DS, r->DX), (UWORD FAR *) & r->CX);
rc = DosGetFattr((BYTE FAR *) FP_DS_DX, (UWORD FAR *) & r->CX);
if (rc != SUCCESS)
goto error_exit;
else
{
r->FLAGS &= ~FLG_CARRY;
CLEAR_CARRY_FLAG();
}
break;
case 0x01:
rc = DosSetFattr((BYTE FAR *) MK_FP(r->DS, r->DX), (UWORD FAR *) & r->CX);
rc = DosSetFattr((BYTE FAR *) FP_DS_DX, (UWORD FAR *) & r->CX);
if (rc != SUCCESS)
goto error_exit;
else
r->FLAGS &= ~FLG_CARRY;
CLEAR_CARRY_FLAG();
break;
default:
@ -1035,7 +1084,7 @@ dispatch:
goto error_out;
}
else{
r->FLAGS &= ~FLG_CARRY;
CLEAR_CARRY_FLAG();
}
}
break;
@ -1047,7 +1096,7 @@ dispatch:
goto error_exit;
else
{
r->FLAGS &= ~FLG_CARRY;
CLEAR_CARRY_FLAG();
r->AX = rc;
}
break;
@ -1058,7 +1107,7 @@ dispatch:
if (rc < SUCCESS)
goto error_exit;
else
r->FLAGS &= ~FLG_CARRY;
CLEAR_CARRY_FLAG();
break;
/* Get Current Directory */
@ -1067,7 +1116,7 @@ dispatch:
goto error_exit;
else
{
r->FLAGS &= ~FLG_CARRY;
CLEAR_CARRY_FLAG();
r->AX = 0x0100; /*jpp: from interrupt list */
}
break;
@ -1082,7 +1131,7 @@ dispatch:
else
{
++(r->AX); /* DosMemAlloc() returns seg of MCB rather than data */
r->FLAGS &= ~FLG_CARRY;
CLEAR_CARRY_FLAG();
}
break;
@ -1091,7 +1140,7 @@ dispatch:
if ((rc = DosMemFree((r->ES) - 1)) < 0)
goto error_exit;
else
r->FLAGS &= ~FLG_CARRY;
CLEAR_CARRY_FLAG();
break;
/* Set memory block size */
@ -1117,7 +1166,7 @@ dispatch:
goto error_exit;
}
else
r->FLAGS &= ~FLG_CARRY;
CLEAR_CARRY_FLAG();
break;
}
@ -1126,11 +1175,11 @@ dispatch:
case 0x4b:
break_flg = FALSE;
if ((rc = DosExec(r->AL, MK_FP(r->ES, r->BX), MK_FP(r->DS, r->DX)))
if ((rc = DosExec(r->AL, MK_FP(r->ES, r->BX), FP_DS_DX))
!= SUCCESS)
goto error_exit;
else
r->FLAGS &= ~FLG_CARRY;
CLEAR_CARRY_FLAG();
break;
/* Terminate Program */
@ -1179,12 +1228,12 @@ dispatch:
{
/* dta for this call is set on entry. This */
/* needs to be changed for new versions. */
if ((rc = DosFindFirst((UCOUNT) r->CX, (BYTE FAR *) MK_FP(r->DS, r->DX))) < 0)
if ((rc = DosFindFirst((UCOUNT) r->CX, (BYTE FAR *) FP_DS_DX)) < 0)
goto error_exit;
else
{
r->AX = 0;
r->FLAGS &= ~FLG_CARRY;
CLEAR_CARRY_FLAG();
}
}
break;
@ -1204,7 +1253,7 @@ dispatch:
}
else
{
r->FLAGS &= ~FLG_CARRY;
CLEAR_CARRY_FLAG();
r->AX = -SUCCESS;
}
}
@ -1235,12 +1284,12 @@ dispatch:
/* Dos Rename */
case 0x56:
rc = DosRename((BYTE FAR *) MK_FP(r->DS, r->DX), (BYTE FAR *) MK_FP(r->ES, r->DI));
rc = DosRename((BYTE FAR *) FP_DS_DX, (BYTE FAR *) MK_FP(r->ES, r->DI));
if (rc < SUCCESS)
goto error_exit;
else
{
r->FLAGS &= ~FLG_CARRY;
CLEAR_CARRY_FLAG();
}
break;
@ -1256,7 +1305,7 @@ dispatch:
if (rc < SUCCESS)
goto error_exit;
else
r->FLAGS &= ~FLG_CARRY;
CLEAR_CARRY_FLAG();
break;
case 0x01:
@ -1267,7 +1316,7 @@ dispatch:
if (rc < SUCCESS)
goto error_exit;
else
r->FLAGS &= ~FLG_CARRY;
CLEAR_CARRY_FLAG();
break;
default:
@ -1304,7 +1353,7 @@ dispatch:
goto error_invalid;
}
}
r->FLAGS &= ~FLG_CARRY;
CLEAR_CARRY_FLAG();
break;
case 0x02:
@ -1335,23 +1384,23 @@ dispatch:
r->CH = CritErrLocus;
r->BH = CritErrClass;
r->BL = CritErrAction;
r->FLAGS &= ~FLG_CARRY;
CLEAR_CARRY_FLAG();
break;
/* Create Temporary File */
case 0x5a:
if ((rc = DosMkTmp(MK_FP(r->DS, r->DX), r->CX)) < 0)
if ((rc = DosMkTmp(FP_DS_DX, r->CX)) < 0)
goto error_exit;
else
{
r->AX = rc;
r->FLAGS &= ~FLG_CARRY;
CLEAR_CARRY_FLAG();
}
break;
/* Create New File */
case 0x5b:
if ((rc = DosOpen(MK_FP(r->DS, r->DX), 0)) >= 0)
if ((rc = DosOpen(FP_DS_DX, 0)) >= 0)
{
DosClose(rc);
r->AX = 80;
@ -1359,12 +1408,12 @@ dispatch:
}
else
{
if ((rc = DosCreat(MK_FP(r->DS, r->DX), r->CX)) < 0)
if ((rc = DosCreat(FP_DS_DX, r->CX)) < 0)
goto error_exit;
else
{
r->AX = rc;
r->FLAGS &= ~FLG_CARRY;
CLEAR_CARRY_FLAG();
}
}
break;
@ -1379,7 +1428,7 @@ dispatch:
((r->AX & 0xff) != 0))) != 0)
r->FLAGS |= FLG_CARRY;
else
r->FLAGS &= ~FLG_CARRY;
CLEAR_CARRY_FLAG();
r->AX = -rc;
break;
/* /// End of additions for SHARE. - Ron Cemer */
@ -1391,7 +1440,7 @@ dispatch:
/* Remote Server Call */
case 0x00:
{
UWORD FAR *x = MK_FP(r->DS, r->DX);
UWORD FAR *x = FP_DS_DX;
r->AX = x[0];
r->BX = x[1];
r->CX = x[2];
@ -1408,7 +1457,7 @@ dispatch:
r->SI = FP_OFF(internal_data);
r->CX = swap_always - internal_data;
r->DX = swap_indos - internal_data;
r->FLAGS &= ~FLG_CARRY;
CLEAR_CARRY_FLAG();
break;
case 0x07:
@ -1421,7 +1470,7 @@ dispatch:
if (result != SUCCESS) {
goto error_out;
} else {
r->FLAGS &= ~FLG_CARRY;
CLEAR_CARRY_FLAG();
}
break;
}
@ -1434,11 +1483,11 @@ dispatch:
switch (r->AL)
{
case 0x00:
r->CX = get_machine_name(MK_FP(r->DS, r->DX));
r->CX = get_machine_name(FP_DS_DX);
break;
case 0x01:
set_machine_name(MK_FP(r->DS, r->DX), r->CX);
set_machine_name(FP_DS_DX, r->CX);
break;
default:
@ -1449,7 +1498,7 @@ dispatch:
if (result != SUCCESS) {
goto error_out;
} else {
r->FLAGS &= ~FLG_CARRY;
CLEAR_CARRY_FLAG();
}
break;
}
@ -1479,7 +1528,7 @@ dispatch:
if (result != SUCCESS) {
goto error_out;
} else {
r->FLAGS &= ~FLG_CARRY;
CLEAR_CARRY_FLAG();
}
break;
}
@ -1492,7 +1541,7 @@ dispatch:
goto error_exit;
else
{
r->FLAGS &= ~FLG_CARRY;
CLEAR_CARRY_FLAG();
}
break;
@ -1549,19 +1598,19 @@ dispatch:
r->DL = DosUpChar(r->DL);
break;
case 0x21: /* upcase memory area */
DosUpMem(MK_FP(r->DS, r->DX), r->CX);
DosUpMem(FP_DS_DX, r->CX);
break;
case 0x22: /* upcase ASCIZ */
DosUpString(MK_FP(r->DS, r->DX));
DosUpString(FP_DS_DX);
break;
case 0xA0: /* upcase single character of filenames */
r->DL = DosUpFChar(r->DL);
break;
case 0xA1: /* upcase memory area of filenames */
DosUpFMem(MK_FP(r->DS, r->DX), r->CX);
DosUpFMem(FP_DS_DX, r->CX);
break;
case 0xA2: /* upcase ASCIZ of filenames */
DosUpFString(MK_FP(r->DS, r->DX));
DosUpFString(FP_DS_DX);
break;
case 0x23: /* check Yes/No response */
r->AX = DosYesNo(r->DL);
@ -1581,7 +1630,7 @@ dispatch:
break;
}
r->FLAGS &= ~FLG_CARRY;
CLEAR_CARRY_FLAG();
break;
/* Code Page functions */
@ -1601,7 +1650,7 @@ dispatch:
}
if(rc != SUCCESS)
goto error_exit;
r->FLAGS &= ~FLG_CARRY;
CLEAR_CARRY_FLAG();
break;
}
@ -1611,13 +1660,13 @@ dispatch:
goto error_exit;
else
{
r->FLAGS &= ~FLG_CARRY;
CLEAR_CARRY_FLAG();
}
break;
/* Flush file buffer -- dummy function right now. */
case 0x68:
r->FLAGS &= ~FLG_CARRY;
CLEAR_CARRY_FLAG();
break;
/* Get/Set Serial Number */
@ -1648,7 +1697,7 @@ dispatch:
}
else
{
r->FLAGS &= ~FLG_CARRY;
CLEAR_CARRY_FLAG();
}
break;
}
@ -1675,7 +1724,7 @@ dispatch:
x += 2;
r->CX = x;
r->AX = rc;
r->FLAGS &= ~FLG_CARRY;
CLEAR_CARRY_FLAG();
}
}
break;
@ -1694,7 +1743,7 @@ dispatch:
{
r->CX = 0x02;
r->AX = rc;
r->FLAGS &= ~FLG_CARRY;
CLEAR_CARRY_FLAG();
}
}
break;
@ -1708,7 +1757,7 @@ dispatch:
{
r->CX = 0x03;
r->AX = rc;
r->FLAGS &= ~FLG_CARRY;
CLEAR_CARRY_FLAG();
}
break;
@ -1717,7 +1766,7 @@ dispatch:
{
r->CX = 0x01;
r->AX = rc;
r->FLAGS &= ~FLG_CARRY;
CLEAR_CARRY_FLAG();
}
else{
if ((rc = DosCreat(MK_FP(r->DS, r->SI), r->CX )) < 0 )
@ -1726,7 +1775,7 @@ dispatch:
{
r->CX = 0x02;
r->AX = rc;
r->FLAGS &= ~FLG_CARRY;
CLEAR_CARRY_FLAG();
}
}
break;
@ -1738,7 +1787,7 @@ dispatch:
{
r->CX = 0x01;
r->AX = rc;
r->FLAGS &= ~FLG_CARRY;
CLEAR_CARRY_FLAG();
}
break;
@ -1808,109 +1857,92 @@ struct int25regs
};
/* this function is called from an assembler wrapper function */
VOID int25_handler(struct int25regs FAR * r)
/*
I'm probably either
A) totally braindamaged
B) chasing a compiler bug, which I can't find.
LEAVE THIS CODE EXACTLY AS IS OR FDOS WON'T BOOT
*/
VOID int2526_handler(WORD mode, struct int25regs FAR * r)
{
ULONG blkno;
UWORD nblks;
BYTE FAR *buf;
UBYTE drv = r->ax & 0xFF;
InDOS++;
if (r->cx == 0xFFFF)
{
struct HugeSectorBlock FAR *lb = MK_FP(r->ds, r->bx);
blkno = lb->blkno;
nblks = lb->nblks;
buf = lb->buf;
}
else
{
nblks = r->cx;
blkno = r->dx;
buf = MK_FP(r->ds, r->bx);
}
BYTE FAR *buf;
UBYTE drv = r->ax;
if (drv >= (lastdrive - 1))
{
r->ax = 0x202;
r->flags |= FLG_CARRY;
return;
}
/* *** Changed 9/4/00 BER */
r->ax=dskxfer(drv, blkno, buf, nblks, DSKREAD);
if (r->ax > 0)
{
r->flags |= FLG_CARRY;
--InDOS;
return;
}
/* End of change */
r->ax = 0;
r->flags &= ~FLG_CARRY;
--InDOS;
}
VOID int26_handler(struct int25regs FAR * r)
{
ULONG blkno;
UWORD nblks;
BYTE FAR *buf;
UBYTE drv = r->ax & 0xFF;
nblks = r->cx;
blkno = r->dx;
buf = MK_FP(r->ds, r->bx);
if (mode == DSKREAD)
{
if (nblks == 0xFFFF)
{
/*struct HugeSectorBlock FAR *lb = MK_FP(r->ds, r->bx);*/
blkno = ((struct HugeSectorBlock FAR *)buf)->blkno;
nblks = ((struct HugeSectorBlock FAR *)buf)->nblks;
buf = ((struct HugeSectorBlock FAR *)buf)->buf;
}
else
{
buf = MK_FP(r->ds, r->bx);
}
} else {
if (nblks == 0xFFFF)
{
struct HugeSectorBlock FAR *lb = MK_FP(r->ds, r->bx);
blkno = lb->blkno;
nblks = lb->nblks;
buf = lb->buf;
}
else
{
buf = MK_FP(r->ds, r->bx);
}
}
InDOS++;
if (r->cx == 0xFFFF)
if (mode == DSKREAD)
{
struct HugeSectorBlock FAR *lb = MK_FP(r->ds, r->bx);
blkno = lb->blkno;
nblks = lb->nblks;
buf = lb->buf;
}
else
{
nblks = r->cx;
blkno = r->dx;
buf = MK_FP(r->ds, r->bx);
}
r->ax=dskxfer(drv, blkno, buf, nblks, mode);
} else {
r->ax=dskxfer(drv, blkno, buf, nblks, DSKWRITE);
if (r->ax <= 0)
setinvld(drv);
}
if (drv >= (lastdrive -1))
{
r->ax = 0x202;
r->flags |= FLG_CARRY;
return;
}
/* *** Changed 9/4/00 BER */
r->ax=dskxfer(drv, blkno, buf, nblks, DSKWRITE);
if (r->ax > 0)
{
r->flags |= FLG_CARRY;
--InDOS;
return;
}
/* End of change */
setinvld(drv);
r->ax = 0;
r->flags &= ~FLG_CARRY;
--InDOS;
}
VOID int25_handler(struct int25regs FAR * r) { int2526_handler(DSKREAD,r); }
VOID int26_handler(struct int25regs FAR * r) { int2526_handler(DSKWRITE,r); }
VOID INRPT FAR int28_handler(void)
{
}
VOID INRPT FAR int2a_handler(void)
{
}
VOID INRPT FAR empty_handler(void)
{
}
#ifdef TSC
static VOID StartTrace(VOID)

View File

@ -28,7 +28,7 @@
%include "segs.inc"
segment _TEXT
segment HMA_TEXT
;
; void intr(nr, rp)
; REG int nr
@ -90,3 +90,91 @@ intr?1:
ret
global _int3
_int3:
int 3
retf
segment INIT_TEXT
;
; void init_call_intr(nr, rp)
; REG int nr
; REG struct REGPACK *rp
;
; same stuff as above, but in INIT_SEGMENT
global _init_call_intr
_init_call_intr:
push bp ; Standard C entry
mov bp,sp
push si
push di
push ds
push es
mov ax, [bp+4] ; interrupt number
mov [CS:init_intr?1-1], al
jmp short init_intr?2 ; flush the instruction cache
init_intr?2 mov bx, [bp+6] ; regpack structure
mov ax, [bx]
mov cx, [bx+4]
mov dx, [bx+6]
mov bp, [bx+8]
mov di, [bx+10]
mov si, [bx+12]
push Word [bx+14] ; ds
mov es, [bx+16]
mov bx, [bx+2]
pop ds
int 0
init_intr?1:
pushf
push ds
push bx
mov bx, sp
mov ds, [SS:bx+8]
mov bx, [ss:bx+20] ; address of REGPACK
mov [bx], ax
pop ax
mov [bx+2], ax
mov [bx+4], cx
mov [bx+6], dx
mov [bx+8], bp
mov [bx+10], di
mov [bx+12], si
pop ax
mov [bx+14], ax
mov [bx+16], es
pop ax
mov [bx+18], ax
pop es
pop ds
pop di
pop si
pop bp
ret
;
; int init_call_XMScall( (WORD FAR * driverAddress)(), WORD AX, WORD DX)
;
; this calls HIMEM.SYS
;
global _init_call_XMScall
_init_call_XMScall:
push bp
mov bp,sp
mov ax,[bp+8]
mov dx,[bp+10]
call far [bp+4]
pop bp
ret

View File

@ -7,3 +7,4 @@ struct REGPACK {
};
extern void intr(int intrnr, struct REGPACK *rp);
extern void FAR int3();

View File

@ -28,6 +28,9 @@
; $Header$
;
; $Log$
; Revision 1.7 2001/03/21 02:56:26 bartoldeman
; See history.txt for changes. Bug fixes and HMA support are the main ones.
;
; Revision 1.6 2000/06/21 18:16:46 jimtabor
; Add UMB code, patch, and code fixes
;
@ -72,8 +75,8 @@
extern _NumFloppies:wrt DGROUP
extern blk_stk_top:wrt DGROUP
extern clk_stk_top:wrt DGROUP
extern _blk_driver:wrt TGROUP
extern _clk_driver:wrt TGROUP
extern _reloc_call_blk_driver
extern _reloc_call_clk_driver
;---------------------------------------------------
;
@ -224,12 +227,12 @@ blk_dos_seg resw 1
clk_dos_stk resw 1
clk_dos_seg resw 1
segment _IO_TEXT
segment _IO_TEXT
global _ReqPktPtr
_ReqPktPtr dd 0
uUnitNumber dw 0
;
; Name:
; GenStrategy
@ -413,8 +416,10 @@ DiskIntrEntry:
push ds
push bx
mov bp,sp
mov ax,DGROUP
mov ds,ax
push ax
mov ax,DGROUP
mov ds,ax
pop ax
cld
call word [cs:si+1]
pop cx
@ -435,10 +440,10 @@ AsmType: mov al,[bx+unit]
xchg di,ax
les di,[bx+trans]
push ax
mov ax,DGROUP
push ax
mov ax, DGROUP
mov ds,ax
pop ax
pop ax
cld
jmp word [cs:si+1]
@ -542,9 +547,9 @@ blk_entry:
push di
push ds
push es
; small model
mov ax,DGROUP ; correct for segments
mov ax,DGROUP ; correct for segments
mov ds,ax ; ax to carry segment
mov word [blk_dos_stk],sp ; use internal stack
mov word [blk_dos_seg],ss
@ -558,7 +563,7 @@ blk_entry:
mov bp,sp ; make a c frame
push word [cs:_ReqPktPtr+2]
push word [cs:_ReqPktPtr]
call _blk_driver
call far _reloc_call_blk_driver
pop cx
pop cx
les bx,[cs:_ReqPktPtr] ; now return completion code
@ -580,6 +585,8 @@ blk_entry:
;
; clock device interrupt
;
@ -597,9 +604,9 @@ clk_entry:
push di
push ds
push es
; small model
mov ax,DGROUP ; correct for segments
mov ax,DGROUP ; correct for segments
mov ds,ax ; ax to carry segment
mov word [clk_dos_stk],sp ; use internal stack
mov word [clk_dos_seg],ss
@ -613,7 +620,7 @@ clk_entry:
mov bp,sp ; make a c frame
push word [cs:_ReqPktPtr+2]
push word [cs:_ReqPktPtr]
call _clk_driver
call far _reloc_call_clk_driver
pop cx
pop cx
les bx,[cs:_ReqPktPtr] ; now return completion code

View File

@ -30,6 +30,9 @@
; $Header$
;
; $Log$
; Revision 1.4 2001/03/21 02:56:26 bartoldeman
; See history.txt for changes. Bug fixes and HMA support are the main ones.
;
; Revision 1.3 2000/05/25 20:56:21 jimtabor
; Fixed project history
;
@ -58,16 +61,7 @@
; $EndLog$
;
group TGROUP _TEXT _IO_TEXT _IO_FIXED_DATA
group DGROUP _FIXED_DATA _DATA _BSS _BSSEND
segment _TEXT class=CODE
segment _IO_TEXT class=CODE
segment _IO_FIXED_DATA class=CODE align=2
segment _FIXED_DATA class=DATA align=16
segment _DATA class=DATA align=2
segment _BSS class=BSS align=2
segment _BSSEND class=BSS
%include "segs.inc"
extern _IOExit:wrt TGROUP
extern _IOSuccess:wrt TGROUP

View File

@ -28,8 +28,8 @@
; $Id$
;
; $Log$
; Revision 1.6 2001/03/19 04:50:56 bartoldeman
; See history.txt for overview: put kernel 2022beo1 into CVS
; Revision 1.7 2001/03/21 02:56:26 bartoldeman
; See history.txt for changes. Bug fixes and HMA support are the main ones.
;
; Revision 1.6 2001/03/08 21:15:00 bartoldeman
; uppermem_root initialised to 0 (no UMBs).
@ -187,7 +187,7 @@ floppy: mov byte [_BootDrive],bl ; tell where we came from
shr al,cl
inc al
mov byte [_NumFloppies],al ; and how many
mov ax,ds
mov es,ax
jmp _main
@ -219,15 +219,6 @@ _nul_intr:
pop es
retf
extern _init_call_printf:wrt TGROUP
global _printf
_printf:
pop ax
push cs
push ax
jmp _init_call_printf
segment _FIXED_DATA
@ -551,7 +542,9 @@ _FcbSearchBuffer: ; of error stack as scratch buffer
_LocalPath:
; times 67 db 0
; stacks are made to initialize to no-ops so that high-water
; tesing can be performed
; testing can be performed
global apistk_bottom
apistk_bottom:
times STACK_SIZE dw 0 ;300 - Error Processing Stack
global _error_tos
@ -594,6 +587,14 @@ _ram_top dw 0
;
; mark front and end of bss area to clear
segment _BSSSTART
global __bssstart
__bssstart:
segment _BSSEND
global __bssend
__bssend:
segment _BSSEND
; blockdev private stack
@ -607,17 +608,42 @@ blk_stk_top:
clk_stk_top:
; interrupt stack
global intr_stk_top
times 256 dw 0
intr_stk_top:
; kernel startup stack
global tos
times 128 dw 0
tos:
global last
last: ; must always be end of stack area
global _last
_last: ; and c version
segment INIT_TEXT_START
global __InitTextStart
__InitTextStart: ; and c version
;
; start end end of HMA area
segment HMA_TEXT_START
global __HMATextAvailable
__HMATextAvailable
global __HMATextStart
__HMATextStart:
;
; the HMA area is filled with 16+22(=sizeof VDISK) = 32 byte dummy data,
; so nothing will ever be below 0xffff:25
;
segment HMA_TEXT
times 16 db 0 ; filler [ffff:0..ffff:10]
times 22 db 0 ; filler [sizeof VDISK info]
;End of HMA segment
segment HMA_TEXT_END
global __HMATextEnd
__HMATextEnd: ; and c version
; The default stack (_TEXT:0) will overwrite the data area, so I create a dummy
@ -625,3 +651,367 @@ _last: ; and c version
segment _STACK class=STACK stack
segment _TEXT
; dummy interrupt return handlers
global _int28_handler
global _int2a_handler
global _empty_handler
_int28_handler:
_int2a_handler:
_empty_handler:
iret
; to minimize relocations
global _DGROUP_
_DGROUP_:
dw DGROUP
segment _TEXT
global __HMARelocationTableStart
__HMARelocationTableStart:
extern _init_call_DosExec
global _reloc_call_DosExec
_reloc_call_DosExec: jmp far _init_call_DosExec
call near forceEnableA20
extern _init_call_DosMemAlloc
global _reloc_call_DosMemAlloc
_reloc_call_DosMemAlloc: jmp far _init_call_DosMemAlloc
call near forceEnableA20
extern _init_call_dos_close
global _reloc_call_dos_close
_reloc_call_dos_close: jmp far _init_call_dos_close
call near forceEnableA20
extern _init_call_dos_getdate
global _reloc_call_dos_getdate
_reloc_call_dos_getdate: jmp far _init_call_dos_getdate
call near forceEnableA20
extern _init_call_dos_gettime
global _reloc_call_dos_gettime
_reloc_call_dos_gettime: jmp far _init_call_dos_gettime
call near forceEnableA20
extern _init_call_dos_open
global _reloc_call_dos_open
_reloc_call_dos_open: jmp far _init_call_dos_open
call near forceEnableA20
extern _init_call_dos_read
global _reloc_call_dos_read
_reloc_call_dos_read: jmp far _init_call_dos_read
call near forceEnableA20
extern _init_call_execrh
global _reloc_call_execrh
_reloc_call_execrh: jmp far _init_call_execrh
call near forceEnableA20
extern _init_call_fatal
global _reloc_call_fatal
_reloc_call_fatal: jmp far _init_call_fatal
call near forceEnableA20
extern _init_call_fmemcpy
global _reloc_call_fmemcpy
_reloc_call_fmemcpy: jmp far _init_call_fmemcpy
call near forceEnableA20
extern _init_call_memcpy
global _reloc_call_memcpy
_reloc_call_memcpy: jmp far _init_call_memcpy
call near forceEnableA20
extern _init_call_printf
global _reloc_call_printf
_reloc_call_printf: jmp far _init_call_printf
call near forceEnableA20
extern _init_call_strcpy
global _reloc_call_strcpy
_reloc_call_strcpy: jmp far _init_call_strcpy
call near forceEnableA20
extern _init_call_sti
global _reloc_call_sti
_reloc_call_sti: jmp far _init_call_sti
call near forceEnableA20
extern _init_call_strcmp
global _reloc_call_strcmp
_reloc_call_strcmp: jmp far _init_call_strcmp
call near forceEnableA20
extern _init_call_strlen
global _reloc_call_strlen
_reloc_call_strlen: jmp far _init_call_strlen
call near forceEnableA20
extern _init_call_WritePCClock
global _reloc_call_WritePCClock
_reloc_call_WritePCClock: jmp far _init_call_WritePCClock
call near forceEnableA20
extern _init_call_DaysFromYearMonthDay
global _reloc_call_DaysFromYearMonthDay
_reloc_call_DaysFromYearMonthDay: jmp far _init_call_DaysFromYearMonthDay
call near forceEnableA20
global _CharMapSrvc
extern _reloc_call_CharMapSrvc
_CharMapSrvc: jmp far _reloc_call_CharMapSrvc
call near forceEnableA20
global _reloc_call_clk_driver
extern _init_call_clk_driver
_reloc_call_clk_driver: jmp far _init_call_clk_driver
call near forceEnableA20
global _reloc_call_fmemset
extern _init_call_fmemset
_reloc_call_fmemset: jmp far _init_call_fmemset
call near forceEnableA20
global _reloc_call_blk_driver
extern _init_call_blk_driver
_reloc_call_blk_driver: jmp far _init_call_blk_driver
call near forceEnableA20
global _int2f_handler
extern reloc_call_int2f_handler
_int2f_handler: jmp far reloc_call_int2f_handler
call near forceEnableA20
global _int20_handler
extern reloc_call_int20_handler
_int20_handler: jmp far reloc_call_int20_handler
call near forceEnableA20
global _int21_handler
extern reloc_call_int21_handler
_int21_handler: jmp far reloc_call_int21_handler
call near forceEnableA20
global _low_int25_handler
extern reloc_call_low_int25_handler
_low_int25_handler: jmp far reloc_call_low_int25_handler
call near forceEnableA20
global _low_int26_handler
extern reloc_call_low_int26_handler
_low_int26_handler: jmp far reloc_call_low_int26_handler
call near forceEnableA20
global _int27_handler
extern reloc_call_int27_handler
_int27_handler: jmp far reloc_call_int27_handler
call near forceEnableA20
global _cpm_entry
extern reloc_call_cpm_entry
_cpm_entry: jmp far reloc_call_cpm_entry
call near forceEnableA20
; global _init_call_init_buffers
; extern _reloc_call_init_buffers
;_init_call_init_buffers: jmp far _reloc_call_init_buffers
; call near forceEnableA20
global _init_call_p_0
extern _reloc_call_p_0
_init_call_p_0: jmp far _reloc_call_p_0
call near forceEnableA20
global __HMARelocationTableEnd
__HMARelocationTableEnd:
;
; if we were lucky, we found all entries from the outside to the kernel.
; if not, BUMS
;
;
; this routine makes the HMA area available. PERIOD.
; must conserve ALL registers
; will be only ever called, if HMA (DOS=HIGH) is enabled.
; for obvious reasons it should be located at the relocation table
;
global enableA20 ; to see it in the map
delay:
in al, 64h
delay_check:
and al, 2
jnz delay
ret
;void _EnableHMA()
;{
; OutportWithDelay(0x64, 0xd1);
; OutportWithDelay(0x60, 0xdf);
; OutportWithDelay(0x64, 0xff);
;}
global _XMSDriverAddress
_XMSDriverAddress:
dw 0 ; XMS driver, if detected
dw 0
global __EnableA20
__EnableA20:
cmp word [cs:_XMSDriverAddress],0
jne enableUsingXMSdriver
cmp word [cs:_XMSDriverAddress+2],0
jne enableUsingXMSdriver
; we do it ourself, without an XMS driver
mov al,0d1h
out 64h,al
call delay
mov al,0dfh
out 60h,al
call delay
mov al,0ffh
out 64h,al
call delay
retf
enableUsingXMSdriver:
mov ah,3
UsingXMSdriver:
call far [cs:_XMSDriverAddress]
retf
global __DisableA20
__DisableA20:
mov ah,4
cmp word [cs:_XMSDriverAddress],0
jne UsingXMSdriver
cmp word [cs:_XMSDriverAddress+2],0
jne UsingXMSdriver
; we do it ourself, without an XMS driver
;OutportWithDelay(0x64, 0xd1);
;OutportWithDelay(0x60, 0xdd);
;OutportWithDelay(0x64, 0xff);
mov al,0d1h
out 64h,al
call delay
mov al,0ddh
out 60h,al
call delay
mov al,0ffh
out 64h,al
call delay
retf
dslowmem dw 0
eshighmem dw 0ffffh
global forceEnableA20
forceEnableA20:
push ds
push es
push ax
forceEnableA20retry:
mov ds, [cs:dslowmem]
mov es, [cs:eshighmem]
mov ax, [ds:00000h]
cmp ax, [es:00010h]
jne forceEnableA20success
mov ax, [ds:00002h]
cmp ax, [es:00012h]
jne forceEnableA20success
mov ax, [ds:00004h]
cmp ax, [es:00014h]
jne forceEnableA20success
mov ax, [ds:00006h]
cmp ax, [es:00016h]
jne forceEnableA20success
;
; ok, we have to enable A20 )at least seems so
;
; some debug first
; push bx
; mov ah, 0eh
; mov al, 'H'
; mov bx, 0007h
; int 10h
; pop bx
call far __EnableA20
jmp short forceEnableA20retry
forceEnableA20success:
pop ax
pop es
pop ds
ret
segment _TEXT
;
; Default Int 24h handler -- always returns fail
; so we have not to relocate it (now)
;
FAIL equ 03h
global _int24_handler
_int24_handler: mov al,FAIL
iret
segment HMA_TEXT
extern _init_call_printf:wrt TGROUP
global _printf
_printf:
pop ax
push cs
push ax
jmp _init_call_printf

View File

@ -5,8 +5,8 @@
#
# $Log$
# Revision 1.5 2001/03/19 04:50:56 bartoldeman
# See history.txt for overview: put kernel 2022beo1 into CVS
# Revision 1.6 2001/03/21 02:56:26 bartoldeman
# See history.txt for changes. Bug fixes and HMA support are the main ones.
#
# Revision 1.4 2000/08/06 05:50:17 jimtabor
# Add new files and update cvs with patches and changes
@ -127,9 +127,11 @@ NASMFLAGS = -i../hdr/
LIBS =..\LIB\DEVICE.LIB ..\LIB\LIBM.LIB
#CFLAGS = -1- -O -Z -d -I..\hdr -I. \
# -D__STDC__=0;DEBUG;KERNEL;I86;PROTO;ASMSUPT
CFLAGS = -1- -O -Z -d -I..\hdr -I. \
-D__STDC__=0;KERNEL;I86;PROTO;ASMSUPT
INITCFLAGS = $(CFLAGS) -zAINIT -zCINIT_TEXT -zPIGROUP
ALLCFLAGS = -1- -O -Z -d -I..\hdr -I. \
-D__STDC__=0;KERNEL;I86;PROTO;ASMSUPT \
-g1
INITCFLAGS = $(ALLCFLAGS) -zAINIT -zCINIT_TEXT -zPIGROUP
CFLAGS = $(ALLCFLAGS) -zAHMA -zCHMA_TEXT
HDR=../hdr/
# *Implicit Rules*
@ -191,7 +193,8 @@ EXE_dependencies = \
sysclk.obj \
syspack.obj \
systime.obj \
task.obj
task.obj \
inithma.obj
# *Explicit Rules*
@ -215,7 +218,7 @@ kernel.exe: $(EXE_dependencies) $(LIBS)
$(RM) kernel.lib
$(LIBUTIL) kernel +entry +io +blockio +chario +dosfns +console
$(LIBUTIL) kernel +printer +serial +dsk +error +fatdir +fatfs
$(LIBUTIL) kernel +fattab +fcbfns +initoem +inthndlr +ioctl +nls_hc
$(LIBUTIL) kernel +fattab +fcbfns +initoem +initHMA+inthndlr +ioctl +nls_hc
$(LIBUTIL) kernel +main +config +memmgr +misc +newstuff +nls +intr
$(LIBUTIL) kernel +dosnames +prf +strings +network +sysclk +syspack
$(LIBUTIL) kernel +systime +task +int2f +irqstack +apisupt
@ -284,6 +287,14 @@ main.obj: main.c init-mod.h $(HDR)portab.h globals.h $(HDR)device.h \
$(HDR)version.h proto.h
$(CC) $(INITCFLAGS) -c main.c
initHMA.obj: initHMA.c init-mod.h $(HDR)portab.h globals.h $(HDR)device.h \
$(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \
$(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \
$(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \
$(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \
$(HDR)version.h proto.h
$(CC) $(INITCFLAGS) -c initHMA.c
# XXX: I generated these using `gcc -MM' and `sed', so they may not be
# completely correct... -- ror4
blockio.obj: blockio.c $(HDR)portab.h globals.h $(HDR)device.h \

View File

@ -36,9 +36,14 @@
#ifdef VERSION_STRINGS
static BYTE *mainRcsId = "$Id$";
#endif
GLOBAL WORD bDumpRegs = FALSE;
GLOBAL WORD bDumpRdWrParms= FALSE;
/*
* $Log$
* Revision 1.8 2001/03/21 02:56:26 bartoldeman
* See history.txt for changes. Bug fixes and HMA support are the main ones.
*
* Revision 1.7 2000/08/06 05:50:17 jimtabor
* Add new files and update cvs with patches and changes
*
@ -158,6 +163,7 @@ extern BYTE FAR * upBase;
INIT BOOL ReadATClock(BYTE *, BYTE *, BYTE *, BYTE *);
VOID FAR init_call_WritePCClock(ULONG);
VOID FAR reloc_call_WritePCClock(ULONG);
INIT VOID configDone(VOID);
INIT static void InitIO(void);
@ -169,12 +175,31 @@ INIT static VOID signon(VOID);
INIT VOID kernel(VOID);
INIT VOID FsConfig(VOID);
#ifdef __TURBOC__
void __int__(int); /* TC 2.01 requires this. :( -- ror4 */
#endif
INIT VOID main(void)
{
setvec(1, empty_handler); /* single step */
setvec(3, empty_handler); /* debug breakpoint */
#ifdef KDB
BootDrive = 1;
#endif
{ /* clear the BSS area (what normally the RTL does */
extern BYTE _bssstart[],_bssend[];
fmemset(_bssstart,0,_bssend-_bssstart);
}
init_kernel();
#ifdef DEBUG
/* Non-portable message kludge alert! */
printf("KERNEL: Boot drive = %c\n", 'A' + BootDrive - 1);
@ -183,7 +208,7 @@ INIT VOID main(void)
kernel();
}
INIT static VOID init_kernel(void)
INIT void init_kernel(void)
{
COUNT i;
os_major = MAJOR_RELEASE;
@ -193,6 +218,8 @@ INIT static VOID init_kernel(void)
maxbksize = 0x200;
switchar = '/';
dosidle_flag = 1;
/* Init oem hook - returns memory size in KB */
ram_top = init_oem();
@ -371,31 +398,33 @@ INIT VOID FsConfig(VOID)
/* Initialzie the current directory structures */
for (i = 0; i < lastdrive ; i++)
{
struct cds FAR *pcds_table = &CDSp->cds_table[i];
fbcopy((VOID FAR *) "A:\\\0",
(VOID FAR *) CDSp->cds_table[i].cdsCurrentPath, 4);
CDSp->cds_table[i].cdsCurrentPath[0] += i;
(VOID FAR *) pcds_table->cdsCurrentPath, 4);
pcds_table->cdsCurrentPath[0] += i;
if (i < nblkdev)
{
CDSp->cds_table[i].cdsDpb = &blk_devices[i];
CDSp->cds_table[i].cdsFlags = CDSPHYSDRV;
pcds_table->cdsDpb = &blk_devices[i];
pcds_table->cdsFlags = CDSPHYSDRV;
}
else
{
CDSp->cds_table[i].cdsFlags = 0;
pcds_table->cdsFlags = 0;
}
CDSp->cds_table[i].cdsStrtClst = 0xffff;
CDSp->cds_table[i].cdsParam = 0xffff;
CDSp->cds_table[i].cdsStoreUData = 0xffff;
CDSp->cds_table[i].cdsJoinOffset = 2;
pcds_table->cdsStrtClst = 0xffff;
pcds_table->cdsParam = 0xffff;
pcds_table->cdsStoreUData = 0xffff;
pcds_table->cdsJoinOffset = 2;
}
/* Initialze the disk buffer management functions */
init_buffers();
/* init_call_init_buffers(); done from CONFIG.C */
}
INIT static VOID signon()
INIT VOID signon()
{
printf("\nFreeDOS Kernel compatibility %d.%d\n%s\n",
os_major, os_minor, copyright);
@ -404,7 +433,7 @@ INIT static VOID signon()
BUILD);
}
INIT static VOID kernel()
INIT void kernel()
{
seg asize;
BYTE FAR *ep,
@ -434,7 +463,8 @@ INIT static VOID kernel()
ep += sizeof(int);
#endif
RootPsp = ~0;
p_0();
init_call_p_0();
}
/* If cmdLine is NULL, this is an internal driver */
@ -457,7 +487,9 @@ BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine, COUNT mode, COUNT r_
rq.r_bpbptr = (void FAR *)(cmdLine ? cmdLine : "\n");
rq.r_firstunit = nblkdev;
execrh((request FAR *) & rq, dhp);
/*
* Added needed Error handle
*/
@ -478,17 +510,19 @@ BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine, COUNT mode, COUNT r_
for (Index = 0; Index < rq.r_nunits; Index++)
{
struct dpb *pblk_devices = &blk_devices[nblkdev];
if (nblkdev)
blk_devices[nblkdev - 1].dpb_next = &blk_devices[nblkdev];
(pblk_devices-1)->dpb_next = pblk_devices;
blk_devices[nblkdev].dpb_next = (void FAR *)0xFFFFFFFF;
blk_devices[nblkdev].dpb_unit = nblkdev;
blk_devices[nblkdev].dpb_subunit = Index;
blk_devices[nblkdev].dpb_device = dhp;
blk_devices[nblkdev].dpb_flags = M_CHANGED;
pblk_devices->dpb_next = (void FAR *)0xFFFFFFFF;
pblk_devices->dpb_unit = nblkdev;
pblk_devices->dpb_subunit = Index;
pblk_devices->dpb_device = dhp;
pblk_devices->dpb_flags = M_CHANGED;
if ((CDSp != 0) && (nblkdev <= lastdrive))
{
CDSp->cds_table[nblkdev].cdsDpb = &blk_devices[nblkdev];
CDSp->cds_table[nblkdev].cdsDpb = pblk_devices;
CDSp->cds_table[nblkdev].cdsFlags = CDSPHYSDRV;
}
++nblkdev;
@ -508,6 +542,7 @@ INIT static void InitIO(void)
ULONG ticks;
/* Initialize driver chain */
nul_dev.dh_next = (struct dhdr FAR *)&con_dev;
setvec(0x29, int29_handler); /* Requires Fast Con Driver */
init_device((struct dhdr FAR *)&con_dev, NULL, NULL, ram_top);
@ -516,7 +551,11 @@ INIT static void InitIO(void)
/* If AT clock exists, copy AT clock time to system clock */
if (!ReadATClock(bcd_days, &bcd_hours, &bcd_minutes, &bcd_seconds))
{
DaysSinceEpoch = BcdToDay(bcd_days);
DaysSinceEpoch = DaysFromYearMonthDay(
100 * BcdToByte(bcd_days[3]) + BcdToByte(bcd_days[2]),
BcdToByte(bcd_days[1]),
BcdToByte(bcd_days[0]) );
/*
* This is a rather tricky calculation. The number of timer ticks per
* second is not exactly 18.2, but rather 0x1800b0 / 86400 = 19663 / 1080
@ -537,23 +576,3 @@ INIT static COUNT BcdToByte(COUNT x)
return ((((x) >> 4) & 0xf) * 10 + ((x) & 0xf));
}
INIT static COUNT BcdToDay(BYTE * x)
{
UWORD mon,
day,
yr;
mon = BcdToByte(x[1]) - 1;
day = BcdToByte(x[0]) - 1;
yr = 100 * BcdToByte(x[3]) + BcdToByte(x[2]);
if (yr < 1980)
return 0;
else
{
day += days[is_leap_year(yr)][mon];
while (--yr >= 1980)
day += is_leap_year(yr) ? 366 : 365;
return day;
}
}

View File

@ -35,8 +35,8 @@ static BYTE *memmgrRcsId = "$Id$";
/*
* $Log$
* Revision 1.8 2001/03/19 04:50:56 bartoldeman
* See history.txt for overview: put kernel 2022beo1 into CVS
* Revision 1.9 2001/03/21 02:56:26 bartoldeman
* See history.txt for changes. Bug fixes and HMA support are the main ones.
*
* Revision 1.8 2001/03/08 21:00:00 bartoldeman
* UMB and MCB chain corruption (thanks Martin Stromberg) fixes
@ -114,8 +114,14 @@ VOID mcb_init();
VOID mcb_print();
VOID show_chain();
#define nxtMCBsize(mcb,size) \
MK_FP(far2para((VOID FAR *) (mcb)) + (size) + 1, 0)
/*#define nxtMCBsize(mcb,size) \
MK_FP(far2para((VOID FAR *) (mcb)) + (size) + 1, 0) */
void FAR *nxtMCBsize(mcb FAR *Mcb, int size)
{
return MK_FP(far2para((VOID FAR *) (Mcb)) + (size) + 1, 0);
}
#define nxtMCB(mcb) nxtMCBsize((mcb), (mcb)->m_size)
#define mcbFree(mcb) ((mcb)->m_psp == FREE_PSP)
@ -164,6 +170,8 @@ seg long2para(LONG size)
*/
VOID FAR *add_far(VOID FAR * fp, ULONG off)
{
if (FP_SEG(fp) == 0xffff) return ((BYTE FAR *)fp) + off;
off += FP_OFF(fp);
return MK_FP(FP_SEG(fp) + (UWORD) (off >> 4), (UWORD) off & 0xf);
@ -176,6 +184,9 @@ VOID FAR *adjust_far(VOID FAR * fp)
{
/* and return an adddress adjusted to the nearest paragraph */
/* boundary. */
if (FP_SEG(fp) == 0xffff) return fp;
return MK_FP(FP_SEG(fp) + (FP_OFF(fp) >> 4), FP_OFF(fp) & 0xf);
}
@ -613,14 +624,14 @@ VOID mcb_print(mcb FAR * mcbp)
mcbp->m_psp,
mcbp->m_size);
}
/*
VOID _fmemcpy(BYTE FAR * d, BYTE FAR * s, REG COUNT n)
{
while (n--)
*d++ = *s++;
}
*/
VOID DosUmbLink(BYTE n)
{
REG mcb FAR *p;

View File

@ -34,6 +34,9 @@ static BYTE *miscRcsId = "$Id$";
/*
* $Log$
* Revision 1.4 2001/03/21 02:56:26 bartoldeman
* See history.txt for changes. Bug fixes and HMA support are the main ones.
*
* Revision 1.3 2000/05/25 20:56:21 jimtabor
* Fixed project history
*
@ -86,6 +89,7 @@ static BYTE *miscRcsId = "$Id$";
*/
#include "globals.h"
#ifndef ASMSUPT
VOID scopy(REG BYTE * s, REG BYTE * d)
{
@ -145,3 +149,4 @@ VOID FAR init_call_fmemset(REG VOID FAR * s, REG int ch, REG COUNT n)
{
fmemset(s, ch, n);
}
#endif

View File

@ -36,6 +36,9 @@ static BYTE *RcsId = "$Id$";
/*
* $Log$
* Revision 1.8 2001/03/21 02:56:26 bartoldeman
* See history.txt for changes. Bug fixes and HMA support are the main ones.
*
* Revision 1.7 2000/08/06 05:50:17 jimtabor
* Add new files and update cvs with patches and changes
*
@ -161,6 +164,7 @@ COUNT Remote_find(UWORD func, BYTE FAR * name, REG dmatch FAR * dmp )
/*
Needed Code Rep-off.;)
*/
/*
p = dmp->dm_name;
if (SDp->dir_name[0] == '.')
{
@ -189,8 +193,11 @@ COUNT Remote_find(UWORD func, BYTE FAR * name, REG dmatch FAR * dmp )
*p++ = *q++;
}
}
}
}
*p++ = NULL;
*/
ConvertName83ToNameSZ((BYTE FAR *) dmp->dm_name, (BYTE FAR *) SDp->dir_name);
return i;
}

View File

@ -44,6 +44,9 @@ static BYTE *RcsId = "$Id$";
/*
* $Log$
* Revision 1.5 2001/03/21 02:56:26 bartoldeman
* See history.txt for changes. Bug fixes and HMA support are the main ones.
*
* Revision 1.4 2000/08/06 05:50:17 jimtabor
* Add new files and update cvs with patches and changes
*
@ -348,7 +351,9 @@ log( ("NLS: nlsGetData(): Subfunction not found\n") );
}
VOID nlsCPchange(UWORD cp)
{ printf("\7\nSorry, to change the codepage is not implemented, yet.\n\
{
UNREFERENCED_PARAMETER(cp);
printf("\7\nSorry, to change the codepage is not implemented, yet.\n\
Hope it's OK to proceed ignoring this call.\n-- 2000/02/26 ska\n");
}
@ -610,6 +615,8 @@ COUNT DosSetCodepage(UWORD actCP, UWORD sysCP)
UWORD syscall_MUX14(DIRECT_IREGS)
{ struct nlsPackage FAR*nls; /* addressed NLS package */
if (flags || cs || ip || ds || es || si);
log( ("NLS: MUX14(): subfct=%x, cp=%u, cntry=%u\n",
AL, BX, DX) );

View File

@ -29,8 +29,8 @@
; $Id$
;
; $Log$
; Revision 1.5 2001/03/19 04:50:56 bartoldeman
; See history.txt for overview: put kernel 2022beo1 into CVS
; Revision 1.6 2001/03/21 02:56:26 bartoldeman
; See history.txt for changes. Bug fixes and HMA support are the main ones.
;
;
; Revision 1.5 2001/03/08 21:15:00 bartoldeman
@ -87,15 +87,15 @@
%include "segs.inc"
segment _TEXT
global _CharMapSrvc
extern _DosUpChar:wrt TGROUP
segment HMA_TEXT
global _reloc_call_CharMapSrvc
extern _DosUpChar:wrt HGROUP
;
; CharMapSrvc:
; User callable character mapping service.
; Part of Function 38h
;
_CharMapSrvc:
_reloc_call_CharMapSrvc:
push ds
push es
push bp
@ -106,8 +106,10 @@ _CharMapSrvc:
push bx
push ax ; arg of _upChar
mov ax, DGROUP
push ax
mov ax,DGROUP
mov ds, ax
pop ax
call _DosUpChar
;add sp, byte 2 // next POP retrieves orig AX

View File

@ -34,15 +34,15 @@ static BYTE *prfRcsId = "$Id$";
/*
* $Log$
* Revision 1.4 2001/03/19 04:50:56 bartoldeman
* See history.txt for overview: put kernel 2022beo1 into CVS
* Revision 1.5 2001/03/21 02:56:26 bartoldeman
* See history.txt for changes. Bug fixes and HMA support are the main ones.
*
* Revision 1.4 2001/03/07 10:00:00 tomehlert
* recoded for smaller object footprint, added main() for testing+QA
*
* $Log$
* Revision 1.4 2001/03/19 04:50:56 bartoldeman
* See history.txt for overview: put kernel 2022beo1 into CVS
* Revision 1.5 2001/03/21 02:56:26 bartoldeman
* See history.txt for changes. Bug fixes and HMA support are the main ones.
*
* Revision 1.3 2000/05/25 20:56:21 jimtabor
* Fixed project history
@ -110,13 +110,21 @@ VOID cso(COUNT);
VOID cso();
#endif
#ifdef __TURBOC__
void __int__(int); /* TC 2.01 requires this. :( -- ror4 */
#endif
/* special console output routine */
VOID
put_console(COUNT c)
{
if (c == '\n')
cso('\r');
cso(c);
put_console('\r');
_AX = 0x0e00 | c;
_BX = 0x0070;
__int__(0x10);
}
/* special handler to switch between sprintf and printf */
@ -188,7 +196,15 @@ sprintf(BYTE * buff, CONST BYTE * fmt, BYTE * args,...)
handle_char(NULL);
return ret;
}
/*
ULONG FAR retcs(int i)
{
char *p = (char*)&i;
p -= 4;
return *(ULONG *)p;
}
*/
COUNT
do_printf(CONST BYTE * fmt, BYTE ** arg)
{
@ -202,7 +218,19 @@ COUNT
fill;
int longarg;
long currentArg;
/*
long cs = retcs(1);
put_console("0123456789ABCDEF"[(cs >> 28) & 0x0f]);
put_console("0123456789ABCDEF"[(cs >> 24) & 0x0f]);
put_console("0123456789ABCDEF"[(cs >> 20) & 0x0f]);
put_console("0123456789ABCDEF"[(cs >> 16) & 0x0f]);
put_console(':');
put_console("0123456789ABCDEF"[(cs >> 12) & 0x0f]);
put_console("0123456789ABCDEF"[(cs >> 8) & 0x0f]);
put_console("0123456789ABCDEF"[(cs >> 4) & 0x0f]);
put_console("0123456789ABCDEF"[(cs >> 0) & 0x0f]);
*/
while ((c = *fmt++) != '\0')
{
if (c != '%')
@ -242,7 +270,8 @@ COUNT
}
switch (c = *fmt++)
c = *fmt++;
switch (c)
{
case '\0':
return 0;
@ -251,6 +280,15 @@ COUNT
handle_char(*(COUNT *) arg++);
continue;
case 'p':
{
WORD w[2];
w[1] = *((unsigned int*) arg)++;
w[0] = *((unsigned int*) arg)++;
do_printf("%04x:%04x",(BYTE**)&w);
continue;
}
case 's':
p = *((BYTE **) arg)++;
goto do_outputstring;
@ -299,6 +337,8 @@ do_outputstring:
continue;
default:
handle_char('?');
handle_char(c);
break;
@ -370,7 +410,8 @@ struct {
{ "2147483649", "%lu", 1,0x8000},
{ "-2147483647", "%ld", 1,0x8000},
{ "32767", "%ld", 0x7fff,0},
{ "32769", "%ld", 0x8001,0},
{ "ptr 1234:5678", "ptr %p", 0x5678,0x1234},

View File

@ -30,6 +30,9 @@
; $Id$
;
; $Log$
; Revision 1.4 2001/03/21 02:56:26 bartoldeman
; See history.txt for changes. Bug fixes and HMA support are the main ones.
;
; Revision 1.3 2000/05/25 20:56:21 jimtabor
; Fixed project history
;
@ -99,6 +102,8 @@
segment _TEXT
extern _DGROUP_:wrt TGROUP
;
; Special call for switching processes
;
@ -109,8 +114,7 @@ segment _TEXT
_exec_user:
PUSH$ALL
mov ax,DGROUP
mov ds,ax
mov ds,[_DGROUP_]
mov bp,sp
cld
cli
@ -302,6 +306,11 @@ _spawn_int23:
jmp _int21_handler
global _init_call_spawn_int23
_init_call_spawn_int23:
int 3
call _spawn_int23
retf
;
; interrupt enable and disable routines
;

View File

@ -34,6 +34,9 @@ static BYTE *Proto_hRcsId = "$Id$";
/*
* $Log$
* Revision 1.9 2001/03/21 02:56:26 bartoldeman
* See history.txt for changes. Bug fixes and HMA support are the main ones.
*
* Revision 1.8 2000/10/30 00:21:15 jimtabor
* Adding Brian Reifsnyder Fix for Int 25/26
*
@ -152,15 +155,16 @@ static BYTE *Proto_hRcsId = "$Id$";
#ifdef IN_INIT_MOD
#define __FAR_WRAPPER(ret, name, proto) \
ret FAR name proto; /* will be expanded to `init_call_<name>' */
ret FAR name proto; /* will be expanded to `init_call_<name>' */
#else
#define __FAR_WRAPPER(ret, name, proto) \
ret name proto; \
ret FAR init_call_##name proto;
ret FAR init_call_##name proto; \
ret FAR reloc_call_##name proto;
#endif
/* blockio.c */
VOID FAR init_buffers(void);
VOID FAR init_call_init_buffers(COUNT anzBuffers);
ULONG getblkno(struct buffer FAR *);
VOID setblkno(struct buffer FAR *, ULONG);
struct buffer FAR *getblock(ULONG blkno, COUNT dsk);
@ -207,7 +211,7 @@ BYTE FAR *get_root(BYTE FAR *);
BOOL fnmatch(BYTE FAR *, BYTE FAR *, COUNT, COUNT);
BOOL check_break(void);
UCOUNT GenericRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err,
BOOL force_binary);
BOOL force_binary);
COUNT SftSeek(sft FAR *sftp, LONG new_pos, COUNT mode);
UCOUNT DosRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err);
UCOUNT DosWrite(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err);
@ -243,7 +247,7 @@ COUNT ParseDosName(BYTE FAR *, COUNT *, BYTE *, BYTE *, BYTE *, BOOL);
COUNT ParseDosPath(BYTE FAR *, COUNT *, BYTE *, BYTE FAR *);
/* dsk.c */
COUNT blk_driver(rqptr rp);
COUNT FAR init_call_blk_driver(rqptr rp);
/* error.c */
VOID dump(void);
@ -345,7 +349,7 @@ BOOL FcbFindNext(xfcb FAR * lpXfcb);
UWORD init_oem(void);
/* inthndlr.c */
VOID INRPT far got_cbreak(void); /* procsupt.asm */
VOID INRPT far got_cbreak(void); /* procsupt.asm */
VOID INRPT far int20_handler(iregs UserRegs);
VOID INRPT far int21_handler(iregs UserRegs);
VOID far int21_entry(iregs UserRegs);
@ -376,7 +380,7 @@ seg long2para(LONG size);
VOID FAR *add_far(VOID FAR * fp, ULONG off);
VOID FAR *adjust_far(VOID FAR * fp);
__FAR_WRAPPER(COUNT, DosMemAlloc,
(UWORD size, COUNT mode, seg FAR * para, UWORD FAR * asize))
(UWORD size, COUNT mode, seg FAR * para, UWORD FAR * asize))
COUNT DosMemLargest(UWORD FAR * size);
COUNT DosMemFree(UWORD para);
COUNT DosMemChange(UWORD para, UWORD size, UWORD * maxSize);
@ -386,15 +390,35 @@ COUNT DosGetLargestBlock(UWORD FAR * block);
VOID show_chain(void);
VOID DosUmbLink(BYTE n);
VOID mcb_print(mcb FAR * mcbp);
VOID _fmemcpy(BYTE FAR * d, BYTE FAR * s, REG COUNT n);
/* misc.c */
/*
__FAR_WRAPPER(VOID, scopy, (REG BYTE * s, REG BYTE * d))
VOID fscopy(REG BYTE FAR * s, REG BYTE FAR * d);
VOID fsncopy(BYTE FAR * s, BYTE FAR * d, REG COUNT n);
VOID bcopy(REG BYTE * s, REG BYTE * d, REG COUNT n);
#define strcpy(d, s) scopy(s, d)
__FAR_WRAPPER(VOID, fbcopy, (REG VOID FAR * s, REG VOID FAR * d, REG COUNT n))
*/
__FAR_WRAPPER(VOID, strcpy, (REG BYTE * d, REG BYTE * s))
#define scopy(s, d) strcpy(d,s)
__FAR_WRAPPER(VOID, fmemcpy, (REG VOID FAR * d, REG VOID FAR * s, REG COUNT n))
#define fbcopy(s, d, n) fmemcpy(d,s,n)
void FAR _reloc_call_fmemcpy(REG VOID FAR * d, REG VOID FAR * s, REG COUNT n);
/*VOID fscopy(REG BYTE FAR * s, REG BYTE FAR * d);*/
VOID fstrcpy(REG BYTE FAR * d, REG BYTE FAR * s);
#define fscopy(s,d) fstrcpy(d,s)
VOID fstrcpy(REG BYTE FAR * d, REG BYTE FAR * s);
/*VOID bcopy(REG BYTE * s, REG BYTE * d, REG COUNT n);*/
void memcpy(REG BYTE * d, REG BYTE * s, REG COUNT n);
#define bcopy(s,d,n) memcpy(d,s,n)
__FAR_WRAPPER(void, fmemset,(REG VOID FAR * s, REG int ch, REG COUNT n))
__FAR_WRAPPER(void, memset ,(REG VOID * s, REG int ch, REG COUNT n))
/* nls.c */
BYTE DosYesNo(unsigned char ch);
#ifndef DosUpMem
@ -431,11 +455,17 @@ __FAR_WRAPPER(COUNT, strcmp, (REG BYTE * d, REG BYTE * s))
COUNT fstrcmp(REG BYTE FAR * d, REG BYTE FAR * s);
COUNT fstrncmp(REG BYTE FAR * d, REG BYTE FAR * s, COUNT l);
COUNT strncmp(REG BYTE * d, REG BYTE * s, COUNT l);
VOID fstrncpy(REG BYTE FAR * d, REG BYTE FAR * s, COUNT l);
/*
void fsncopy(REG BYTE FAR * s, REG BYTE FAR * d, COUNT l);
#define fstrncpy(d,s,l) fsncopy(s,d,l)
*/
void fstrncpy(REG BYTE FAR * d, REG BYTE FAR * s, COUNT l);
#define fsncopy(s,d,l) fstrncpy(d,s,l)
BYTE *strchr(BYTE * s, BYTE c);
/* sysclk.c */
WORD clk_driver(rqptr rp);
WORD FAR init_call_clk_driver(rqptr rp);
COUNT BcdToByte(COUNT x);
COUNT BcdToWord(BYTE * x, UWORD * mon, UWORD * day, UWORD * yr);
COUNT ByteToBcd(COUNT x);
@ -456,6 +486,11 @@ COUNT DosSetTime(BYTE FAR * hp, BYTE FAR * mp, BYTE FAR * sp, BYTE FAR * hdp);
VOID DosGetDate(BYTE FAR * wdp, BYTE FAR * mp, BYTE FAR * mdp, COUNT FAR * yp);
COUNT DosSetDate(BYTE FAR * mp, BYTE FAR * mdp, COUNT FAR * yp);
WORD *is_leap_year_monthdays(int year);
__FAR_WRAPPER(WORD,DaysFromYearMonthDay,(WORD Year, WORD Month, WORD DayOfMonth))
/* task.c */
COUNT ChildEnv(exec_blk FAR * exp, UWORD * pChildEnvSeg, char far * pathname);
VOID new_psp(psp FAR * p, int psize);
@ -463,7 +498,7 @@ VOID return_user(void);
__FAR_WRAPPER(COUNT, DosExec, (COUNT mode, exec_blk FAR * ep, BYTE FAR * lp))
__FAR_WRAPPER(VOID, InitPSP, (VOID))
VOID FAR p_0(void);
VOID FAR init_call_p_0(VOID);
/* irqstack.asm */
VOID init_stacks(VOID FAR * stack_base, COUNT nStacks, WORD stackSize);
@ -478,7 +513,7 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t);
COUNT int2f_Remote_call(UWORD func, UWORD b, UCOUNT n, UWORD d, VOID FAR * s, UWORD i, VOID FAR * data);
COUNT QRemote_Fn(char FAR * s, char FAR * d);
COUNT FAR Umb_Test(void);
COUNT Umb_Test(void);
UWORD get_machine_name(BYTE FAR * netname);
VOID set_machine_name(BYTE FAR * netname, UWORD name_num);
@ -487,9 +522,24 @@ COUNT Remote_find(UWORD func, BYTE FAR * name, REG dmatch FAR * dmp);
/* procsupt.asm */
VOID INRPT FAR exec_user(iregs FAR * irp);
#define strcpy(d, s) scopy(s, d)
/* detect.c */
unsigned long FAR is_dosemu(void);
/* new by TE */
/*
assert at compile time, that something is true.
use like
ASSERT_CONST( SECSIZE == 512)
ASSERT_CONST( (BYTE FAR *)x->fcb_ext - (BYTE FAR *)x->fcbname == 8)
*/
#define ASSERT_CONST(x) { typedef struct { char x[2 * (x) - 1]; } xx ; }
void ConvertName83ToNameSZ(BYTE FAR *destSZ, BYTE FAR *srcFCBName);
VOID FAR *HMAalloc(COUNT bytesToAllocate);

View File

@ -29,6 +29,9 @@
; $Header$
;
; $Log$
; Revision 1.4 2001/03/21 02:56:26 bartoldeman
; See history.txt for changes. Bug fixes and HMA support are the main ones.
;
; Revision 1.3 2000/05/25 20:56:21 jimtabor
; Fixed project history
;
@ -54,8 +57,9 @@
; $EndLog
;
group TGROUP _TEXT _IO_TEXT _IO_FIXED_DATA
group TGROUP _TEXT _IO_TEXT _IO_FIXED_DATA
group DGROUP _FIXED_DATA _DATA _BSS _BSSEND
group HGROUP HMA_TEXT_START HMA_TEXT HMA_TEXT_END
group IGROUP INIT_TEXT_START INIT_TEXT INIT_TEXT_END
segment _TEXT class=CODE
@ -63,8 +67,13 @@ segment _IO_TEXT class=CODE
segment _IO_FIXED_DATA class=CODE align=2
segment _FIXED_DATA class=DATA align=16
segment _DATA class=DATA align=2
segment _BSSSTART class=BSS align=2
segment _BSS class=BSS align=2
segment _BSSEND class=BSS
segment HMA_TEXT_START class=HMA
segment HMA_TEXT class=HMA
segment HMA_TEXT_END class=HMA
segment INIT_TEXT_START class=INIT align=16
segment INIT_TEXT class=INIT
segment INIT_TEXT_END class=INIT

View File

@ -34,6 +34,9 @@ static BYTE *stringsRcsId = "$Id$";
/*
* $Log$
* Revision 1.4 2001/03/21 02:56:26 bartoldeman
* See history.txt for changes. Bug fixes and HMA support are the main ones.
*
* Revision 1.3 2000/05/25 20:56:21 jimtabor
* Fixed project history
*
@ -91,6 +94,7 @@ static BYTE *stringsRcsId = "$Id$";
* Initial revision.
*/
#ifndef ASMSUPT
COUNT strlen(REG BYTE * s)
{
REG WORD cnt = 0;
@ -204,3 +208,4 @@ BYTE *strchr(BYTE * s, BYTE c)
while (*p);
return 0;
}
#endif

View File

@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$";
/*
* $Log$
* Revision 1.4 2001/03/21 02:56:26 bartoldeman
* See history.txt for changes. Bug fixes and HMA support are the main ones.
*
* Revision 1.3 2000/05/25 20:56:21 jimtabor
* Fixed project history
*
@ -107,12 +110,8 @@ VOID DayToBcd();
/* */
/* WARNING - THIS DRIVER IS NON-PORTABLE!!!! */
/* */
extern WORD days[2][13]; /* this is defined by SYSTIME.C */
WORD days[2][13] =
{
{0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365},
{0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366}
};
static struct ClockRecord clk;
@ -128,11 +127,12 @@ static BYTE bcdSeconds;
static ULONG Ticks;
UWORD DaysSinceEpoch = 0;
WORD clk_driver(rqptr rp)
WORD FAR init_call_clk_driver(rqptr rp)
{
REG COUNT count,
COUNT
c;
BYTE FAR *cp;
int FAR *cp;
WORD *pdays;
switch (rp->r_command)
{
@ -142,9 +142,6 @@ WORD clk_driver(rqptr rp)
return S_DONE;
case C_INPUT:
count = rp->r_count;
if (count > sizeof(struct ClockRecord))
count = sizeof(struct ClockRecord);
{
ULONG remainder,
hs;
@ -158,6 +155,7 @@ WORD clk_driver(rqptr rp)
* (100 x 86400) / 0x1800b0 = 108000 / 19663. -- ror4
*/
hs = 0;
#if 0
if (Ticks >= 64 * 19663ul)
{
hs += 64 * 108000ul;
@ -193,6 +191,15 @@ WORD clk_driver(rqptr rp)
hs += 108000ul;
Ticks -= 19663ul;
}
#else
{
UWORD q1 = Ticks/19663ul;
Ticks -= q1*19663ul;
hs = q1*108000ul;
}
#endif
/*
* Now Ticks < 19663, so Ticks * 108000 < 2123604000 < ULONG_MAX.
* *phew* -- ror4
@ -205,15 +212,13 @@ WORD clk_driver(rqptr rp)
clk.clkSeconds = remainder / 100ul;
clk.clkHundredths = remainder % 100ul;
}
fbcopy((BYTE FAR *) & clk, rp->r_trans, count);
fbcopy((BYTE FAR *) & clk, rp->r_trans, min(sizeof(struct ClockRecord),rp->r_count ));
return S_DONE;
case C_OUTPUT:
count = rp->r_count;
if (count > sizeof(struct ClockRecord))
count = sizeof(struct ClockRecord);
rp->r_count = count;
fbcopy(rp->r_trans, (BYTE FAR *) & clk, count);
rp->r_count = min(rp->r_count,sizeof(struct ClockRecord));
fbcopy(rp->r_trans, (BYTE FAR *) & clk, rp->r_count);
/* Set PC Clock first */
DaysSinceEpoch = clk.clkDays;
@ -224,6 +229,7 @@ WORD clk_driver(rqptr rp)
100ul * clk.clkSeconds +
clk.clkHundredths;
Ticks = 0;
#if 0
if (hs >= 64 * 108000ul)
{
Ticks += 64 * 19663ul;
@ -259,6 +265,15 @@ WORD clk_driver(rqptr rp)
Ticks += 19663ul;
hs -= 108000ul;
}
#else
{
UWORD q1 = hs/108000ul;
hs -= q1*108000ul;
Ticks = q1*19663ul;
}
#endif
Ticks += hs * 19663ul / 108000ul;
}
WritePCClock(Ticks);
@ -266,13 +281,13 @@ WORD clk_driver(rqptr rp)
/* Now set AT clock */
/* Fix year by looping through each year, subtracting */
/* the appropriate number of days for that year. */
for (Year = 1980, c = clk.clkDays; c > 0;)
for (Year = 1980, c = clk.clkDays; ;)
{
count = is_leap_year(Year) ? 366 : 365;
if (c >= count)
pdays = is_leap_year_monthdays(Year);
if (c >= pdays[12])
{
++Year;
c -= count;
c -= pdays[12];
}
else
break;
@ -282,12 +297,14 @@ WORD clk_driver(rqptr rp)
/* days for that year. Use this to index the table. */
for (Month = 1; Month < 13; ++Month)
{
if (days[count == 366][Month] > c)
if (pdays[Month] > c)
{
Day = c - days[count == 366][Month - 1] + 1;
Day = c - pdays[Month - 1] + 1;
break;
}
}
DayToBcd((BYTE *) bcdDays, &Month, &Day, &Year);
bcdMinutes = ByteToBcd(clk.clkMinutes);
bcdHours = ByteToBcd(clk.clkHours);

View File

@ -37,6 +37,9 @@ static BYTE *RcsId = "$Id$";
/*
* $Log$
* Revision 1.4 2001/03/21 02:56:26 bartoldeman
* See history.txt for changes. Bug fixes and HMA support are the main ones.
*
* Revision 1.3 2000/05/25 20:56:21 jimtabor
* Fixed project history
*
@ -94,39 +97,65 @@ static BYTE *RcsId = "$Id$";
* Initial revision.
*/
static WORD days[2][13] =
WORD days[2][13] =
{
{0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365},
{0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366}
};
static WORD ndays[2][13] =
{
/* 1 2 3 4 5 6 7 8 9 10 11 12 */
{0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
{0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
};
extern BYTE
Month,
DayOfMonth,
DayOfWeek;
extern COUNT
Year,
YearsSince1980;
extern request
ClkReqHdr;
/*
return a pointer to an array with the days for that year
*/
VOID DosGetTime(BYTE FAR * hp, BYTE FAR * mp, BYTE FAR * sp, BYTE FAR * hdp)
WORD *is_leap_year_monthdays(int y)
{
/* this is correct in a strict mathematical sense
return ((y) & 3 ? days[0] : (y) % 100 ? days[1] : (y) % 400 ? days[0] : days[1]); */
/* this will work until 2200 - long enough for me - and saves 0x1f bytes */
if ((y & 3) || y == 2100) return days[0];
return days[1];
}
WORD DaysFromYearMonthDay(WORD Year, WORD Month, WORD DayOfMonth)
{
if (Year < 1980) return 0;
return DayOfMonth - 1
+ is_leap_year_monthdays(Year)[Month - 1]
+ ((Year - 1980) * 365)
+ ((Year - 1980 + 3) / 4);
}
WORD FAR init_call_DaysFromYearMonthDay(WORD Year, WORD Month, WORD DayOfMonth)
{
return DaysFromYearMonthDay(Year,Month,DayOfMonth);
}
/* common - call the clock driver */
void ExecuteClockDriverRequest(BYTE command)
{
ClkReqHdr.r_length = sizeof(request);
ClkReqHdr.r_command = C_INPUT;
ClkReqHdr.r_command = command;
ClkReqHdr.r_count = sizeof(struct ClockRecord);
ClkReqHdr.r_trans = (BYTE FAR *) (&ClkRecord);
ClkReqHdr.r_status = 0;
execrh((request FAR *) & ClkReqHdr, (struct dhdr FAR *)clock);
}
VOID DosGetTime(BYTE FAR * hp, BYTE FAR * mp, BYTE FAR * sp, BYTE FAR * hdp)
{
ExecuteClockDriverRequest(C_INPUT);
if (ClkReqHdr.r_status & S_ERROR)
return;
@ -138,6 +167,8 @@ VOID DosGetTime(BYTE FAR * hp, BYTE FAR * mp, BYTE FAR * sp, BYTE FAR * hdp)
COUNT DosSetTime(BYTE FAR * hp, BYTE FAR * mp, BYTE FAR * sp, BYTE FAR * hdp)
{
BYTE Month, DayOfMonth, DayOfWeek; COUNT Year;
DosGetDate((BYTE FAR *) & DayOfWeek, (BYTE FAR *) & Month,
(BYTE FAR *) & DayOfMonth, (COUNT FAR *) & Year);
@ -146,18 +177,10 @@ COUNT DosSetTime(BYTE FAR * hp, BYTE FAR * mp, BYTE FAR * sp, BYTE FAR * hdp)
ClkRecord.clkSeconds = *sp;
ClkRecord.clkHundredths = *hdp;
YearsSince1980 = Year - 1980;
ClkRecord.clkDays = DayOfMonth - 1
+ days[is_leap_year(Year)][Month - 1]
+ ((YearsSince1980) * 365)
+ ((YearsSince1980 + 3) / 4);
ClkRecord.clkDays = DaysFromYearMonthDay(Year, Month, DayOfMonth);
ExecuteClockDriverRequest(C_OUTPUT);
ClkReqHdr.r_length = sizeof(request);
ClkReqHdr.r_command = C_OUTPUT;
ClkReqHdr.r_count = sizeof(struct ClockRecord);
ClkReqHdr.r_trans = (BYTE FAR *) (&ClkRecord);
ClkReqHdr.r_status = 0;
execrh((request FAR *) & ClkReqHdr, (struct dhdr FAR *)clock);
if (ClkReqHdr.r_status & S_ERROR)
return char_error(&ClkReqHdr, (struct dhdr FAR *)clock);
return SUCCESS;
@ -169,25 +192,22 @@ BYTE FAR *wdp,
FAR * mdp;
COUNT FAR *yp;
{
COUNT count,
c;
WORD c;
WORD *pdays;
WORD Year,Month;
ExecuteClockDriverRequest(C_INPUT);
ClkReqHdr.r_length = sizeof(request);
ClkReqHdr.r_command = C_INPUT;
ClkReqHdr.r_count = sizeof(struct ClockRecord);
ClkReqHdr.r_trans = (BYTE FAR *) (&ClkRecord);
ClkReqHdr.r_status = 0;
execrh((request FAR *) & ClkReqHdr, (struct dhdr FAR *)clock);
if (ClkReqHdr.r_status & S_ERROR)
return;
for (Year = 1980, c = ClkRecord.clkDays; c > 0;)
for (Year = 1980, c = ClkRecord.clkDays; ;)
{
count = is_leap_year(Year) ? 366 : 365;
if (c >= count)
pdays = is_leap_year_monthdays(Year);
if (c >= pdays[12])
{
++Year;
c -= count;
c -= pdays[12];
}
else
break;
@ -196,21 +216,19 @@ COUNT FAR *yp;
/* c contains the days left and count the number of days for */
/* that year. Use this to index the table. */
Month = 1;
while (c >= ndays[count == 366][Month])
while (c >= pdays[Month])
{
c -= ndays[count == 366][Month];
++Month;
}
*mp = Month;
*mdp = c + 1;
*mdp = c - pdays[Month-1] + 1;
*yp = Year;
/* Day of week is simple. Take mod 7, add 2 (for Tuesday */
/* 1-1-80) and take mod again */
DayOfWeek = (ClkRecord.clkDays % 7 + 2) % 7;
*wdp = DayOfWeek;
*wdp = (ClkRecord.clkDays + 2) % 7;
}
COUNT DosSetDate(mp, mdp, yp)
@ -218,31 +236,28 @@ BYTE FAR *mp,
FAR * mdp;
COUNT FAR *yp;
{
WORD *pdays, Month, DayOfMonth,Year;
Month = *mp;
DayOfMonth = *mdp;
Year = *yp;
pdays = is_leap_year_monthdays(Year);
if (Year < 1980 || Year > 2099
|| Month < 1 || Month > 12
|| DayOfMonth < 1 || DayOfMonth > ndays[is_leap_year(Year)][Month])
|| DayOfMonth < 1
|| DayOfMonth > pdays[Month] - pdays[Month-1])
return DE_INVLDDATA;
DosGetTime((BYTE FAR *) & ClkRecord.clkHours,
(BYTE FAR *) & ClkRecord.clkMinutes,
(BYTE FAR *) & ClkRecord.clkSeconds,
(BYTE FAR *) & ClkRecord.clkHundredths);
YearsSince1980 = Year - 1980;
ClkRecord.clkDays = DayOfMonth - 1
+ days[is_leap_year(Year)][Month - 1]
+ ((YearsSince1980) * 365)
+ ((YearsSince1980 + 3) / 4);
ClkRecord.clkDays = DaysFromYearMonthDay(Year, Month, DayOfMonth);
ExecuteClockDriverRequest(C_OUTPUT);
ClkReqHdr.r_length = sizeof(request);
ClkReqHdr.r_command = C_OUTPUT;
ClkReqHdr.r_count = sizeof(struct ClockRecord);
ClkReqHdr.r_trans = (BYTE FAR *) (&ClkRecord);
ClkReqHdr.r_status = 0;
execrh((request FAR *) & ClkReqHdr, (struct dhdr FAR *)clock);
if (ClkReqHdr.r_status & S_ERROR)
return char_error(&ClkReqHdr, (struct dhdr FAR *)clock);
return SUCCESS;

View File

@ -35,8 +35,8 @@ static BYTE *RcsId = "$Id$";
/*
* $Log$
* Revision 1.6 2001/03/19 04:50:56 bartoldeman
* See history.txt for overview: put kernel 2022beo1 into CVS
* Revision 1.7 2001/03/21 02:56:26 bartoldeman
* See history.txt for changes. Bug fixes and HMA support are the main ones.
*
* Revision 1.6 2001/03/08 21:00:00 bartoldeman
* UMB fixes to DosComLoader
@ -441,7 +441,7 @@ set_name:
}
static COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode)
COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode)
{
COUNT rc,
err,
@ -674,7 +674,7 @@ static COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode)
/* and finally add in the psp size */
if (mode != OVERLAY)
image_size += (ULONG) long2para((LONG) sizeof(psp));
image_size += sizeof(psp); /*TE 03/20/01*/
if (mode != OVERLAY)
{
@ -956,7 +956,7 @@ VOID InitPSP(VOID)
}
/* process 0 */
VOID FAR p_0(VOID)
VOID FAR reloc_call_p_0(VOID)
{
exec_blk exb;
CommandTail Cmd;

View File

@ -4,6 +4,9 @@
# $Id$
#
# $Log$
# Revision 1.4 2001/03/21 02:56:26 bartoldeman
# See history.txt for changes. Bug fixes and HMA support are the main ones.
#
# Revision 1.3 2000/05/25 20:56:23 jimtabor
# Fixed project history
#
@ -36,7 +39,7 @@
#CFLAGS = -mt -1- -v -vi- -k- -f- -ff- -O -Z -d -I$(INCLUDEPATH);..\hdr \
# -L$(LIBPATH) -DI86;PROTO;DEBUG
CFLAGS = -mt -1- -v -vi- -k- -f- -ff- -O -Z -d -I$(INCLUDEPATH);..\hdr \
-L$(LIBPATH) -DI86;PROTO
-L$(LIBPATH) -DI86;PROTO -zAHMA -zCHMA_TEXT -zDHMA_TEXT
# *Implicit Rules*
.c.obj:
@ -66,8 +69,9 @@ b_fat16.h: ..\boot\b_fat16.bin bin2c.com
bin2c ..\boot\b_fat16.bin b_fat16.h b_fat16
sys.com: $(EXE_dependencies)
$(LINK) /m/t/c $(LIBPATH)\c0t.obj+sys.obj,sys,,\
$(LIBS)+$(CLIB);
# $(LINK) /m/t/c $(LIBPATH)\c0t.obj+sys.obj,sys,,\
$(LINK) /m/c $(LIBPATH)\c0s.obj+sys.obj,sys.com,,\
$(LIBS)+$(CLIB);
clobber: clean
$(RM) sys.com b_fat12.h b_fat16.h