# HG changeset patch # User Shinji KONO # Date 1532344632 -32400 # Node ID 7c6dc25c2b0557e798f416c8f4e76d4911f2e364 # Parent efbe39fee3aee9d216aca5213a3b3a70624d4cf3 add comment diff -r efbe39fee3ae -r 7c6dc25c2b05 src/trace.c --- a/src/trace.c Mon Jul 23 19:36:38 2018 +0900 +++ b/src/trace.c Mon Jul 23 20:17:12 2018 +0900 @@ -1,7 +1,8 @@ /* 6808 Simulator V092 * + * 2018 Shinji KONO * tracer - + * */ #include @@ -239,6 +240,9 @@ bpskip = getarg(s+1,0); } break; + /* + * we should have disassembler for a mmu page + */ case 'x': // dump { char *next = s+1; if (s[1]=='i') next=s+2; @@ -376,6 +380,8 @@ mem[0xffa7]=0x3f; #endif attention = escape = 1; + // we have to reload romfile + // readimage(); break; default: // one step trace trskip = 1; @@ -387,6 +393,9 @@ set_term(escchar); } +/* + * keep break point / watch point in a list + */ void setbreak(int adr, int count) { BPTR bp = calloc(1,sizeof(BP)); bp->count = count; @@ -402,6 +411,12 @@ breakpoint = bp; } +/* + * length call instruction + * + * if call instruction, put temporary break on next instruction + * (ignoring page boundary, sorry) + */ int nexti(void) { #ifdef USE_MMU int op1 = *mem0(phymem,pcreg,mmu); @@ -453,10 +468,4 @@ return ofs; } - - - - - - - +/* end */ diff -r efbe39fee3ae -r 7c6dc25c2b05 src/vdisk.c --- a/src/vdisk.c Mon Jul 23 19:36:38 2018 +0900 +++ b/src/vdisk.c Mon Jul 23 20:17:12 2018 +0900 @@ -36,19 +36,23 @@ #define MAXPDV 256 +/* + * os9 has one path descriptor for one open file or directory + * keep coresponding information in vdisk file manager + */ typedef struct pathDesc { - char *name; - FILE *fp; + char *name; // path name relative to drvRoot + FILE *fp; // file , memfile for directory int mode; int inode ; // lower 24 bit of unix inode, os9 lsn int num ; int sz ; // used only for directory char drv ; char use ; - char dir; - char *fd ; - char *dirfp; + char dir; // is directory? + char *fd ; // simulated os9 file descriptor ( not used now) + char *dirfp; // simulated os9 directory file } PathDesc, *PathDescPtr; static void @@ -60,8 +64,7 @@ static PathDesc pdv[MAXPDV]; /* - * us 0 system - * 1 caller + * byte order staff */ static inline Word getword(Byte *adr) { @@ -75,7 +78,7 @@ *padr = htons(value); } -static int +int setVdisk(int drv,char *name) { if (drv<0 || drv>=MAXVDRV) return -1; drvRoot[drv] = name; @@ -96,6 +99,8 @@ /* * keep track current directory ( most recently 256 entry ) * too easy approach + * + * dir command keep old directory LSN, so we have to too */ char *cdt[512]; static int cdtptr = 0; @@ -115,6 +120,9 @@ #define MAXPAHTLEN 256 +/* + * print os9 string for debug + */ static void putOs9str(char *s,int max) { if (s==0) { @@ -132,6 +140,10 @@ printf("err %d\n",error); } +/* + * add current directory name to the path + * if name starts /v0, drvRoot will be add + */ static char * addCurdir(char *name, PathDesc *pd, int curdir) { int ns =0 ; @@ -167,6 +179,12 @@ return path; } +/* + * os9 file name may contains garbage such as 8th bit on or traling space + * fix it. and make the pointer to next path for the return value + * + * pd->name will be freed, we have to malloc it + */ static char * checkFileName(char *path, PathDesc *pd, int curdir) { char *p = path; @@ -197,6 +215,9 @@ return p; } +/* + * os9 / unix mode conversion + */ static void os9setmode(Byte *os9mode,int mode) { char m = 0; @@ -266,7 +287,11 @@ #define DIR_NM 29 -/* read direcotry entry */ +/* read direcotry entry + * + * create simulated os9 directory structure for dir command + * writing to the directory is not allowed + * */ static int os9opendir(PathDesc *pd) { DIR *dir; @@ -318,6 +343,8 @@ /* read file descriptor of Path Desc * create file descriptor sector if necessary * if buf!=0, copy it + * + * only dir command accesses this using undocumented getstat fdinfo command */ static int filedescriptor(Byte *buf, int len, Byte *name,int curdir) { @@ -343,7 +370,10 @@ return err; } -/* read direcotry entry for any file in the directory +/* + * undocumented getstat command + * + * read direcotry entry for *any* file in the directory * we only returns a file descriptor only in the current opened directory * * inode==0 should return disk id section @@ -370,16 +400,32 @@ return 255; } +/* + * on os9 level 2, user process may on different memory map + * get DAT table on process descriptor on 0x50 in system page + */ void getDAT() { +#ifdef USE_MMU Word ps = getword(smem(0x50)); // process structure - Byte *dat = smem(ps+0x40); // process dat (dynamic address translation) + Byte *dat = smem(ps+0x40); // process dat (dynamic address translation) for(int i=0; i<8; i++) { pmmu[i] = dat[i*2+1]; } +#endif } /* + * vdisk command processing + * + * vrbf.asm will write a command on 0x40+IOPAGE ( 0xffc0 or 0xe040) + * + * U contains caller's stack (call and return value) on 0x45+IOPAGE + * current directory (cwd or cxd) on 0x44+IOPAGE + * Path dcriptor number on 0x47+IOPAGE + * drive number on 0x41+IOPAGE + * caller's process descriptor on <0x50 + * * each command should have preallocated os9 path descriptor on Y * * name or buffer, can be in a user map, check that drive number ( mem[0x41+IOPAGE] 0 sys 1 user ) @@ -770,7 +816,7 @@ if (pd==0) break; *breg = filedescriptor(pmem(xreg), yreg,(Byte*)pd->name,curdir) ; break; - case 0x20: // Pos.FDInf mandatry for dir command + case 0x20: // Pos.FDInf mandatry for dir command (undocumented, use the source) /* SS.FDInf ($20) - Directly reads a file descriptor from anywhere * on drive. * Entry: R$A=Path # @@ -835,7 +881,7 @@ xreg = getword(frame+4); yreg = getword(frame+6); ureg = getword(frame+8); - pcreg = getword(frame+10)-3; + pcreg = getword(frame+10)-3; // point os9 swi2 prog = (char*)(pmem(pcreg) - pcreg); do_trace(fp); }