int21/ah=26: new_psp now copies the old psp and just sets a few fields

int21/ah=55: child_psp does the rest
init code does the init (fixed values are always copied now)


git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@799 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
Bart Oldeman 2004-03-17 21:28:54 +00:00
parent 77331799bd
commit 69faceffe5
6 changed files with 91 additions and 54 deletions

View File

@ -67,6 +67,7 @@ extern BYTE DosLoadedInHMA;
void MoveKernel(unsigned NewKernelSegment); void MoveKernel(unsigned NewKernelSegment);
#define setvec(n, isr) (void)(*(intvec FAR *)MK_FP(0,4 * (n)) = (isr)) #define setvec(n, isr) (void)(*(intvec FAR *)MK_FP(0,4 * (n)) = (isr))
#define getvec(n) (*(intvec FAR *)MK_FP(0,4 * (n)))
#define GLOBAL extern #define GLOBAL extern
#define NAMEMAX MAX_CDSPATH /* Maximum path for CDS */ #define NAMEMAX MAX_CDSPATH /* Maximum path for CDS */
@ -120,7 +121,6 @@ int ASMCFUNC open(const char *pathname, int flags);
int ASMCFUNC close(int fd); int ASMCFUNC close(int fd);
int ASMCFUNC dup2(int oldfd, int newfd); int ASMCFUNC dup2(int oldfd, int newfd);
int ASMCFUNC allocmem(UWORD size, seg * segp); int ASMCFUNC allocmem(UWORD size, seg * segp);
VOID ASMCFUNC init_PSPInit(seg psp_seg);
VOID ASMCFUNC init_PSPSet(seg psp_seg); VOID ASMCFUNC init_PSPSet(seg psp_seg);
COUNT ASMCFUNC init_DosExec(COUNT mode, exec_blk * ep, BYTE * lp); COUNT ASMCFUNC init_DosExec(COUNT mode, exec_blk * ep, BYTE * lp);
int ASMCFUNC init_setdrive(int drive); int ASMCFUNC init_setdrive(int drive);

View File

@ -649,11 +649,7 @@ dispatch:
/* Dos Create New Psp */ /* Dos Create New Psp */
case 0x26: case 0x26:
{ new_psp(lr.DX, r->CS);
psp FAR *p = MK_FP(cu_psp, 0);
new_psp(lr.DX, p->ps_size);
}
break; break;
/* Read random record(s) using FCB */ /* Read random record(s) using FCB */
@ -1175,7 +1171,7 @@ dispatch:
/* ************UNDOCUMENTED************************************* */ /* ************UNDOCUMENTED************************************* */
/* Dos Create New Psp & set p_size */ /* Dos Create New Psp & set p_size */
case 0x55: case 0x55:
new_psp(lr.DX, lr.SI); child_psp(lr.DX, cu_psp, lr.SI);
cu_psp = lr.DX; cu_psp = lr.DX;
break; break;

View File

@ -226,18 +226,6 @@ _dup2:
int 21h int 21h
jmp short common_exit jmp short common_exit
;; VOID init_PSPInit(seg psp_seg)
global _init_PSPInit
_init_PSPInit:
push si
mov ah, 55h
mov bx, sp
mov dx, [bx+4]
xor si, si
int 21h
pop si
ret
;; VOID init_PSPSet(seg psp_seg) ;; VOID init_PSPSet(seg psp_seg)
global _init_PSPSet global _init_PSPSet
_init_PSPSet: _init_PSPSet:

View File

@ -153,6 +153,67 @@ void InitializeAllBPBs(VOID)
} }
} }
STATIC void PSPInit(void)
{
psp far *p = MK_FP(DOS_PSP, 0);
/* Clear out new psp first */
fmemset(p, 0, sizeof(psp));
/* initialize all entries and exits */
/* CP/M-like exit point */
p->ps_exit = 0x20cd;
/* CP/M-like entry point - call far to special entry */
p->ps_farcall = 0x9a;
p->ps_reentry = MK_FP(0, 0x30 * 4);
/* unix style call - 0xcd 0x21 0xcb (int 21, retf) */
p->ps_unix[0] = 0xcd;
p->ps_unix[1] = 0x21;
p->ps_unix[2] = 0xcb;
/* Now for parent-child relationships */
/* parent psp segment */
p->ps_parent = FP_SEG(p);
/* previous psp pointer */
p->ps_prevpsp = MK_FP(0xffff,0xffff);
/* Environment and memory useage parameters */
/* memory size in paragraphs */
/* p->ps_size = 0; clear from above */
/* environment paragraph */
p->ps_environ = DOS_PSP + 8;
/* terminate address */
p->ps_isv22 = getvec(0x22);
/* break address */
p->ps_isv23 = getvec(0x23);
/* critical error address */
p->ps_isv24 = getvec(0x24);
/* user stack pointer - int 21 */
/* p->ps_stack = NULL; clear from above */
/* File System parameters */
/* maximum open files */
p->ps_maxfiles = 20;
fmemset(p->ps_files, 0xff, 20);
/* open file table pointer */
p->ps_filetab = p->ps_files;
/* first command line argument */
/* p->ps_fcb1.fcb_drive = 0; already set */
fmemset(p->ps_fcb1.fcb_fname, ' ', FNAME_SIZE + FEXT_SIZE);
/* second command line argument */
/* p->ps_fcb2.fcb_drive = 0; already set */
fmemset(p->ps_fcb2.fcb_fname, ' ', FNAME_SIZE + FEXT_SIZE);
/* local command line */
/* p->ps_cmd.ctCount = 0; command tail, already set */
p->ps_cmd.ctBuffer[0] = 0xd; /* command tail */
}
STATIC void init_kernel(void) STATIC void init_kernel(void)
{ {
COUNT i; COUNT i;
@ -196,8 +257,7 @@ STATIC void init_kernel(void)
init_PSPSet(DOS_PSP); init_PSPSet(DOS_PSP);
set_DTA(MK_FP(DOS_PSP, 0x80)); set_DTA(MK_FP(DOS_PSP, 0x80));
init_PSPInit(DOS_PSP); PSPInit();
((psp far *)MK_FP(DOS_PSP, 0))->ps_environ = DOS_PSP + 8;
Init_clk_driver(); Init_clk_driver();

View File

@ -339,7 +339,8 @@ const UWORD *is_leap_year_monthdays(UWORD year);
UWORD DaysFromYearMonthDay(UWORD Year, UWORD Month, UWORD DayOfMonth); UWORD DaysFromYearMonthDay(UWORD Year, UWORD Month, UWORD DayOfMonth);
/* task.c */ /* task.c */
VOID new_psp(seg para, int psize); VOID new_psp(seg para, seg cur_psp);
VOID child_psp(seg para, seg cur_psp, int psize);
VOID return_user(void); VOID return_user(void);
COUNT DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp); COUNT DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp);
ULONG SftGetFsize(int sft_idx); ULONG SftGetFsize(int sft_idx);

View File

@ -165,26 +165,29 @@ STATIC COUNT ChildEnv(exec_blk * exp, UWORD * pChildEnvSeg, char far * pathname)
} }
/* The following code is 8086 dependant */ /* The following code is 8086 dependant */
void new_psp(seg para, int psize) void new_psp(seg para, seg cur_psp)
{ {
psp FAR *p = MK_FP(para, 0); psp FAR *p = MK_FP(para, 0);
psp FAR *q = MK_FP(cu_psp, 0);
fmemcpy(p, MK_FP(cur_psp, 0), sizeof(psp));
/* terminate address */
p->ps_isv22 = getvec(0x22);
/* break address */
p->ps_isv23 = getvec(0x23);
/* critical error address */
p->ps_isv24 = getvec(0x24);
/* parent psp segment set to 0 (see RBIL int21/ah=26) */
p->ps_parent = 0;
}
void child_psp(seg para, seg cur_psp, int psize)
{
psp FAR *p = MK_FP(para, 0);
psp FAR *q = MK_FP(cur_psp, 0);
int i; int i;
/* Clear out new psp first */
fmemset(p, 0, sizeof(psp));
/* initialize all entries and exits */ new_psp(para, cur_psp);
/* CP/M-like exit point */
p->ps_exit = 0x20cd;
/* CP/M-like entry point - call far to special entry */
p->ps_farcall = 0x9a;
p->ps_reentry = MK_FP(0, 0x30 * 4);
/* unix style call - 0xcd 0x21 0xcb (int 21, retf) */
p->ps_unix[0] = 0xcd;
p->ps_unix[1] = 0x21;
p->ps_unix[2] = 0xcb;
/* Now for parent-child relationships */ /* Now for parent-child relationships */
/* parent psp segment */ /* parent psp segment */
@ -195,17 +198,6 @@ void new_psp(seg para, int psize)
/* Environment and memory useage parameters */ /* Environment and memory useage parameters */
/* memory size in paragraphs */ /* memory size in paragraphs */
p->ps_size = psize; p->ps_size = psize;
/* environment paragraph */
/* p->ps_environ = 0; cleared above */
/* terminate address */
p->ps_isv22 = getvec(0x22);
/* break address */
p->ps_isv23 = getvec(0x23);
/* critical error address */
p->ps_isv24 = getvec(0x24);
/* user stack pointer - int 21 */
p->ps_stack = q->ps_stack;
/* File System parameters */ /* File System parameters */
/* maximum open files */ /* maximum open files */
@ -221,14 +213,14 @@ void new_psp(seg para, int psize)
p->ps_files[i] = q->ps_filetab[i]; p->ps_files[i] = q->ps_filetab[i];
/* first command line argument */ /* first command line argument */
/* p->ps_fcb1.fcb_drive = 0; already set */ p->ps_fcb1.fcb_drive = 0;
fmemset(p->ps_fcb1.fcb_fname, ' ', FNAME_SIZE + FEXT_SIZE); fmemset(p->ps_fcb1.fcb_fname, ' ', FNAME_SIZE + FEXT_SIZE);
/* second command line argument */ /* second command line argument */
/* p->ps_fcb2.fcb_drive = 0; already set */ p->ps_fcb2.fcb_drive = 0;
fmemset(p->ps_fcb2.fcb_fname, ' ', FNAME_SIZE + FEXT_SIZE); fmemset(p->ps_fcb2.fcb_fname, ' ', FNAME_SIZE + FEXT_SIZE);
/* local command line */ /* local command line */
/* p->ps_cmd.ctCount = 0; command tail, already set */ p->ps_cmd.ctCount = 0;
p->ps_cmd.ctBuffer[0] = 0xd; /* command tail */ p->ps_cmd.ctBuffer[0] = 0xd; /* command tail */
} }
@ -490,7 +482,7 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd)
/* point to the PSP so we can build it */ /* point to the PSP so we can build it */
setvec(0x22, MK_FP(user_r->CS, user_r->IP)); setvec(0x22, MK_FP(user_r->CS, user_r->IP));
new_psp(mem, mem + asize); child_psp(mem, cu_psp, mem + asize);
fcbcode = patchPSP(mem - 1, env, exp, namep); fcbcode = patchPSP(mem - 1, env, exp, namep);
/* set asize to end of segment */ /* set asize to end of segment */
@ -742,7 +734,7 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd)
/* point to the PSP so we can build it */ /* point to the PSP so we can build it */
setvec(0x22, MK_FP(user_r->CS, user_r->IP)); setvec(0x22, MK_FP(user_r->CS, user_r->IP));
new_psp(mem, mem + asize); child_psp(mem, cu_psp, mem + asize);
fcbcode = patchPSP(mem - 1, env, exp, namep); fcbcode = patchPSP(mem - 1, env, exp, namep);
exp->exec.stack = exp->exec.stack =