New paramblock class and the wip of psp.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@162
This commit is contained in:
parent
d30a5b8a39
commit
59b55b0576
1 changed files with 165 additions and 79 deletions
|
@ -21,6 +21,7 @@
|
|||
#include "dosbox.h"
|
||||
#include "mem.h"
|
||||
#include "dos_inc.h"
|
||||
#include "support.h"
|
||||
|
||||
/*
|
||||
Work in progress, making classes for handling certain internal memory structures in dos
|
||||
|
@ -28,6 +29,7 @@
|
|||
dos work a bit easier.
|
||||
*/
|
||||
|
||||
#pragma pack (push,1)
|
||||
|
||||
struct sPSP {
|
||||
Bit8u exit[2]; /* CP/M-like exit poimt */
|
||||
|
@ -52,130 +54,214 @@ struct sPSP {
|
|||
Bit8u fill_2[16]; /* Lot's of unused stuff i can't care aboue */
|
||||
Bit8u service[3]; /* INT 0x21 Service call int 0x21;retf; */
|
||||
Bit8u fill_3[45]; /* This has some blocks with FCB info */
|
||||
|
||||
CommandTail cmdtail;
|
||||
|
||||
};
|
||||
} GCC_ATTRIBUTE(packed);
|
||||
|
||||
union sParamBlock {
|
||||
struct {
|
||||
Bit16u loadseg;
|
||||
Bit16u relocation;
|
||||
} overlay;
|
||||
struct {
|
||||
Bit16u envseg;
|
||||
RealPt cmdtail;
|
||||
RealPt fcb1;
|
||||
RealPt fcb2;
|
||||
RealPt initsssp;
|
||||
RealPt initcsip;
|
||||
} exec;
|
||||
} GCC_ATTRIBUTE(packed);
|
||||
|
||||
struct sFCB {
|
||||
Bit8u drive; //0 is current drive. when opened 0 is replaced by drivenumber
|
||||
Bit8u filename[8]; //spacepadded to fit
|
||||
Bit8u ext[3]; //spacepadded to fit
|
||||
Bit16u current_block; // set to 0 by open
|
||||
Bit16u record_size; // used by reads Set to 80h by OPEN function
|
||||
Bit32u filesize; //in bytes In this field, the first word is the low-order part of the size
|
||||
Bit16u date;
|
||||
Bit16u time;
|
||||
Bit8u reserved[8];
|
||||
Bit8u current_relative_record_number; //open doesn't set this
|
||||
Bit32u rel_record; //open does not handle this
|
||||
} GCC_ATTRIBUTE(packed);
|
||||
|
||||
#pragma pack (pop)
|
||||
|
||||
#define sGet(s,m) GetIt(((s *)0)->m,(PhysPt)&(((s *)0)->m))
|
||||
#define sSave(s,m,val) SaveIt(((s *)0)->m,(PhysPt)&(((s *)0)->m),val)
|
||||
|
||||
|
||||
|
||||
class DOS_PSP {
|
||||
class MemStruct {
|
||||
public:
|
||||
DOS_PSP(Bit16u segment);
|
||||
Bit8u GetIt(Bit8u,PhysPt addr) {
|
||||
return mem_readb(pt+addr);
|
||||
};
|
||||
Bit16u GetIt(Bit16u,PhysPt addr) {
|
||||
return mem_readw(pt+addr);
|
||||
};
|
||||
Bit32u GetIt(Bit32u,PhysPt addr) {
|
||||
return mem_readd(pt+addr);
|
||||
};
|
||||
void SaveIt(Bit8u,PhysPt addr,Bit8u val) {
|
||||
mem_writeb(pt+addr,val);
|
||||
};
|
||||
void SaveIt(Bit16u,PhysPt addr,Bit16u val) {
|
||||
mem_writew(pt+addr,val);
|
||||
};
|
||||
void SaveIt(Bit32u,PhysPt addr,Bit32u val) {
|
||||
mem_writed(pt+addr,val);
|
||||
};
|
||||
|
||||
void MakeNew(Bit16u env,Bit16u memsize);
|
||||
|
||||
|
||||
Bit16u base_seg;
|
||||
|
||||
private:
|
||||
PhysPt off;
|
||||
PhysPt pt;
|
||||
|
||||
};
|
||||
|
||||
DOS_PSP::DOS_PSP(Bit16u segment) {
|
||||
base_seg=segment;
|
||||
off=Real2Phys(RealMake(segment,0));
|
||||
|
||||
class DOS_PSP :public MemStruct {
|
||||
public:
|
||||
DOS_PSP(Bit16u segment){NewPt(segment);};
|
||||
void NewPt(Bit16u segment);
|
||||
void MakeNew(Bit16u mem_size);
|
||||
Bit8u GetFileHandle(Bitu index);
|
||||
|
||||
private:
|
||||
Bit16u seg;
|
||||
PhysPt pt;
|
||||
};
|
||||
|
||||
void DOS_PSP::MakeNew(Bit16u env,Bit16u next_para) {
|
||||
void DOS_PSP::NewPt(Bit16u segment) {
|
||||
seg=segment;
|
||||
pt=PhysMake(segment,0);
|
||||
};
|
||||
|
||||
|
||||
|
||||
void DOS_PSP::MakeNew(Bit16u mem_size) {
|
||||
Bitu i;
|
||||
for (i=0;i<256;i++) mem_writeb(off+i,0);
|
||||
/* Standard blocks */
|
||||
mem_writeb(off+offsetof(sPSP,exit[0]),0xcd);
|
||||
mem_writeb(off+offsetof(sPSP,exit[1]),0x20);
|
||||
|
||||
mem_writeb(off+offsetof(sPSP,service[0]),0xcd);
|
||||
mem_writeb(off+offsetof(sPSP,service[1]),0x21);
|
||||
mem_writeb(off+offsetof(sPSP,service[2]),0xcb);
|
||||
|
||||
mem_writew(off+offsetof(sPSP,next_seg),next_para);
|
||||
|
||||
|
||||
// mem_writew(off+offsetof(sPSP,psp_parent),dos.psp->base_seg);
|
||||
|
||||
/* Setup initial file table */
|
||||
mem_writed(off+offsetof(sPSP,int_22),RealGetVec(0x22));
|
||||
mem_writed(off+offsetof(sPSP,int_23),RealGetVec(0x23));
|
||||
mem_writed(off+offsetof(sPSP,int_24),RealGetVec(0x24));
|
||||
|
||||
|
||||
#if 0
|
||||
|
||||
newpsp->mem_size=prevpsp->mem_size;
|
||||
newpsp->environment=0;
|
||||
|
||||
newpsp->int_22.full=real_getvec(0x22);
|
||||
newpsp->int_23.full=real_getvec(0x23);
|
||||
newpsp->int_24.full=real_getvec(0x24);
|
||||
|
||||
newpsp->psp_parent=dos.psp;
|
||||
newpsp->prev_psp.full=0xFFFFFFFF;
|
||||
|
||||
Bit32u i;
|
||||
Bit8u * prevfile=real_off(prevpsp->file_table.seg,prevpsp->file_table.off);
|
||||
for (i=0;i<20;i++) newpsp->files[i]=prevfile[i];
|
||||
|
||||
newpsp->max_files=20;
|
||||
newpsp->file_table.seg=pspseg;
|
||||
newpsp->file_table.off=offsetof(PSP,files);
|
||||
/* Save the old DTA in this psp */
|
||||
newpsp->dta.seg=dos.dta.seg;
|
||||
newpsp->dta.off=dos.dta.off;
|
||||
/* Setup the DTA */
|
||||
dos.dta.seg=pspseg;
|
||||
dos.dta.off=0x80;
|
||||
return;
|
||||
#endif
|
||||
|
||||
/* Clear it first */
|
||||
for (i=0;i<256;i++) mem_writeb(pt+i,0);
|
||||
/* Standard blocks,int 20 and int21 retf */
|
||||
sGet(sPSP,max_files);
|
||||
sSave(sPSP,exit[0],0xcd);
|
||||
sSave(sPSP,exit[1],0x20);
|
||||
sSave(sPSP,service[0],0xcd);
|
||||
sSave(sPSP,service[1],0x21);
|
||||
sSave(sPSP,service[2],0xcb);
|
||||
/* psp and psp-parent */
|
||||
sSave(sPSP,psp_parent,dos.psp);
|
||||
sSave(sPSP,prev_psp,RealMake(dos.psp,0));
|
||||
/* terminate 22,break 23,crititcal error 24 address stored */
|
||||
sSave(sPSP,int_22,RealGetVec(0x22));
|
||||
sSave(sPSP,int_23,RealGetVec(0x23));
|
||||
sSave(sPSP,int_24,RealGetVec(0x24));
|
||||
/* Memory size */
|
||||
sSave(sPSP,next_seg,seg+mem_size);
|
||||
/* Process DTA */
|
||||
sSave(sPSP,dta,RealMake(seg,128));
|
||||
/* User Stack pointer */
|
||||
//Copy from previous psp
|
||||
// mem_writed(pt+offsetof(sPSP,stack),
|
||||
|
||||
/* Init file pointer and max_files */
|
||||
sSave(sPSP,file_table,RealMake(seg,offsetof(sPSP,files[0])));
|
||||
sSave(sPSP,max_files,20);
|
||||
/* Copy file table from calling process */
|
||||
for (i=0;i<20;i++) {
|
||||
Bit8u handle=0;
|
||||
// Bitu handle=dos.psp.GetFileHandle(i);
|
||||
sSave(sPSP,files[i],handle);
|
||||
}
|
||||
}
|
||||
|
||||
Bit8u DOS_PSP::GetFileHandle(Bitu index) {
|
||||
if (index>=sGet(sPSP,max_files)) return 0xff;
|
||||
PhysPt files=Real2Phys(sGet(sPSP,file_table));
|
||||
return mem_readb(files+index);
|
||||
};
|
||||
|
||||
|
||||
void DOS_FCB::Set_drive(Bit8u a){
|
||||
mem_writeb(off+offsetof(FCB,drive),a);
|
||||
mem_writeb(off+offsetof(sFCB,drive),a);
|
||||
}
|
||||
void DOS_FCB::Set_filename(char * a){
|
||||
MEM_BlockWrite(off+offsetof(FCB,filename),a,8);
|
||||
MEM_BlockWrite(off+offsetof(sFCB,filename),a,8);
|
||||
}
|
||||
void DOS_FCB::Set_ext(char * a) {
|
||||
MEM_BlockWrite(off+offsetof(FCB,ext),a,3);
|
||||
MEM_BlockWrite(off+offsetof(sFCB,ext),a,3);
|
||||
}
|
||||
void DOS_FCB::Set_current_block(Bit16u a){
|
||||
mem_writew(off+offsetof(FCB,current_block),a);
|
||||
mem_writew(off+offsetof(sFCB,current_block),a);
|
||||
}
|
||||
void DOS_FCB::Set_record_size(Bit16u a){
|
||||
mem_writew(off+offsetof(FCB,record_size),a);
|
||||
mem_writew(off+offsetof(sFCB,record_size),a);
|
||||
}
|
||||
void DOS_FCB::Set_filesize(Bit32u a){
|
||||
mem_writed(off+offsetof(FCB,filesize),a);
|
||||
mem_writed(off+offsetof(sFCB,filesize),a);
|
||||
}
|
||||
void DOS_FCB::Set_date(Bit16u a){
|
||||
mem_writew(off+offsetof(FCB,date),a);
|
||||
mem_writew(off+offsetof(sFCB,date),a);
|
||||
}
|
||||
void DOS_FCB::Set_time(Bit16u a){
|
||||
mem_writew(off+offsetof(FCB,time),a);
|
||||
mem_writew(off+offsetof(sFCB,time),a);
|
||||
}
|
||||
Bit8u DOS_FCB::Get_drive(void){
|
||||
return mem_readb(off+offsetof(FCB,drive));
|
||||
return mem_readb(off+offsetof(sFCB,drive));
|
||||
}
|
||||
void DOS_FCB::Get_filename(char * a){
|
||||
MEM_BlockRead(off+offsetof(FCB,filename),a,8);
|
||||
MEM_BlockRead(off+offsetof(sFCB,filename),a,8);
|
||||
}
|
||||
void DOS_FCB::Get_ext(char * a){
|
||||
MEM_BlockRead(off+offsetof(FCB,ext),a,3);
|
||||
MEM_BlockRead(off+offsetof(sFCB,ext),a,3);
|
||||
}
|
||||
Bit16u DOS_FCB::Get_current_block(void){
|
||||
return mem_readw(off+offsetof(FCB,current_block));
|
||||
return mem_readw(off+offsetof(sFCB,current_block));
|
||||
}
|
||||
Bit16u DOS_FCB::Get_record_size(void){
|
||||
return mem_readw(off+offsetof(FCB,record_size));
|
||||
return mem_readw(off+offsetof(sFCB,record_size));
|
||||
}
|
||||
Bit32u DOS_FCB::Get_filesize(void){
|
||||
return mem_readd(off+offsetof(FCB,filesize));
|
||||
return mem_readd(off+offsetof(sFCB,filesize));
|
||||
}
|
||||
Bit16u DOS_FCB::Get_date(void){
|
||||
return mem_readw(off+offsetof(FCB,date));
|
||||
return mem_readw(off+offsetof(sFCB,date));
|
||||
}
|
||||
Bit16u DOS_FCB::Get_time(void){
|
||||
return mem_readw(off+offsetof(FCB,time));
|
||||
return mem_readw(off+offsetof(sFCB,time));
|
||||
}
|
||||
|
||||
|
||||
void DOS_ParamBlock::InitExec(RealPt cmdtail) {
|
||||
mem_writew(off+offsetof(sParamBlock,exec.envseg),0);
|
||||
mem_writed(off+offsetof(sParamBlock,exec.fcb1),0);
|
||||
mem_writed(off+offsetof(sParamBlock,exec.fcb2),0);
|
||||
mem_writed(off+offsetof(sParamBlock,exec.cmdtail),cmdtail);
|
||||
}
|
||||
|
||||
Bit16u DOS_ParamBlock::loadseg(void) {
|
||||
return mem_readw(off+offsetof(sParamBlock,overlay.loadseg));
|
||||
}
|
||||
Bit16u DOS_ParamBlock::relocation(void){
|
||||
return mem_readw(off+offsetof(sParamBlock,overlay.loadseg));
|
||||
}
|
||||
Bit16u DOS_ParamBlock::envseg(void){
|
||||
return mem_readw(off+offsetof(sParamBlock,exec.envseg));
|
||||
}
|
||||
RealPt DOS_ParamBlock::initsssp(void){
|
||||
return mem_readd(off+offsetof(sParamBlock,exec.initsssp));
|
||||
}
|
||||
RealPt DOS_ParamBlock::initcsip(void){
|
||||
return mem_readd(off+offsetof(sParamBlock,exec.initcsip));
|
||||
}
|
||||
RealPt DOS_ParamBlock::fcb1(void){
|
||||
return mem_readd(off+offsetof(sParamBlock,exec.fcb1));
|
||||
}
|
||||
RealPt DOS_ParamBlock::fcb2(void){
|
||||
return mem_readd(off+offsetof(sParamBlock,exec.fcb2));
|
||||
}
|
||||
RealPt DOS_ParamBlock::cmdtail(void){
|
||||
return mem_readd(off+offsetof(sParamBlock,exec.cmdtail));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue