TempleOSCDV4.12.ISO
This commit is contained in:
1 parent
93ca216483
commit
b84bbff6db
381 files changed
+18356
-18798
No files matched your search
+36
-36
@@ -94,7 +94,7 @@ U0 ATARepEntry(I64 base0,I64 base1,I64 unit,I64 irq,U8 *msg,
|
||||
I64 type;
|
||||
base0&=-8;
|
||||
base1&=-4;
|
||||
CATARep *tempha;
|
||||
CATARep *tmpha;
|
||||
if (type=ATAProbe(base0,base1,unit)) {
|
||||
*num_hints+=1;
|
||||
"\n\n$$PURPLE$$ $$BT+X,\"%d\",LM=\"%d\\n\"$$$$FG$$$$LM,4$$",*num_hints,*num_hints;
|
||||
@@ -105,14 +105,14 @@ U0 ATARepEntry(I64 base0,I64 base1,I64 unit,I64 irq,U8 *msg,
|
||||
"%s$$FG$$\nBase0:0x%04X Base1:0x%04X\nIrq:0x%02X Unit:%d$$LM,0$$\n",
|
||||
msg,base0,base1,irq,unit;
|
||||
if (_head) {
|
||||
tempha=CAlloc(sizeof(CATARep));
|
||||
tempha->next=*_head;
|
||||
*_head=tempha;
|
||||
tempha->num=*num_hints;
|
||||
tempha->type=type;
|
||||
tempha->base0=base0;
|
||||
tempha->base1=base1;
|
||||
tempha->unit=unit;
|
||||
tmpha=CAlloc(sizeof(CATARep));
|
||||
tmpha->next=*_head;
|
||||
*_head=tmpha;
|
||||
tmpha->num=*num_hints;
|
||||
tmpha->type=type;
|
||||
tmpha->base0=base0;
|
||||
tmpha->base1=base1;
|
||||
tmpha->unit=unit;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -204,32 +204,32 @@ CATARep *ATARepFind(CATARep *haystack_head,I64 needle_num)
|
||||
|
||||
CATARep *ATAIDDrvs(CATARep *head,CATARep **_ata_drv,CATARep **_atapi_drv)
|
||||
{//This is for when trying to sort-out main hard drives and CD/DVD drives.
|
||||
CATARep *res=NULL,*tempha=head,*ata_drv=NULL,*atapi_drv=NULL;
|
||||
CATARep *res=NULL,*tmpha=head,*ata_drv=NULL,*atapi_drv=NULL;
|
||||
CBlkDev *bd;
|
||||
Bool was_silent=Silent;
|
||||
bd=Let2BlkDev(':',FALSE);
|
||||
Silent(was_silent);
|
||||
while (tempha) {
|
||||
if (!res && bd && bd->type==tempha->type) {
|
||||
while (tmpha) {
|
||||
if (!res && bd && bd->type==tmpha->type) {
|
||||
if (bd->type==BDT_ATAPI &&
|
||||
bd->base0==tempha->base0 && bd->unit==tempha->unit)
|
||||
res=atapi_drv=tempha;
|
||||
else if (bd->type==BDT_ATA && bd->base0==tempha->base0 &&
|
||||
bd->base1==tempha->base1 && bd->unit==tempha->unit)
|
||||
res=ata_drv=tempha;
|
||||
bd->base0==tmpha->base0 && bd->unit==tmpha->unit)
|
||||
res=atapi_drv=tmpha;
|
||||
else if (bd->type==BDT_ATA && bd->base0==tmpha->base0 &&
|
||||
bd->base1==tmpha->base1 && bd->unit==tmpha->unit)
|
||||
res=ata_drv=tmpha;
|
||||
}
|
||||
if (!res || res->type!=tempha->type) {
|
||||
if (tempha->type==BDT_ATA) {
|
||||
if (!ata_drv || tempha->unit<ata_drv->unit ||
|
||||
tempha->unit==ata_drv->unit && tempha->num<ata_drv->num)
|
||||
ata_drv=tempha;
|
||||
} else if (tempha->type==BDT_ATAPI) {
|
||||
if (!atapi_drv || tempha->unit<atapi_drv->unit ||
|
||||
tempha->unit==atapi_drv->unit && tempha->num<atapi_drv->num)
|
||||
atapi_drv=tempha;
|
||||
if (!res || res->type!=tmpha->type) {
|
||||
if (tmpha->type==BDT_ATA) {
|
||||
if (!ata_drv || tmpha->unit<ata_drv->unit ||
|
||||
tmpha->unit==ata_drv->unit && tmpha->num<ata_drv->num)
|
||||
ata_drv=tmpha;
|
||||
} else if (tmpha->type==BDT_ATAPI) {
|
||||
if (!atapi_drv || tmpha->unit<atapi_drv->unit ||
|
||||
tmpha->unit==atapi_drv->unit && tmpha->num<atapi_drv->num)
|
||||
atapi_drv=tmpha;
|
||||
}
|
||||
}
|
||||
tempha=tempha->next;
|
||||
tmpha=tmpha->next;
|
||||
}
|
||||
if (_ata_drv) *_ata_drv =ata_drv;
|
||||
if (_atapi_drv) *_atapi_drv=atapi_drv;
|
||||
@@ -256,7 +256,7 @@ I64 AutoMountIDE()
|
||||
//It uses 'C' and 'T' as first drive letters or whatever you set
|
||||
//in config when compiling Kernel.BIN.
|
||||
I64 res=0;
|
||||
CATARep *head=NULL,*ata_drv=NULL,*atapi_drv=NULL,*tempha;
|
||||
CATARep *head=NULL,*ata_drv=NULL,*atapi_drv=NULL,*tmpha;
|
||||
ATARep(FALSE,TRUE,&head);
|
||||
ATAIDDrvs(head,&ata_drv,&atapi_drv);
|
||||
if (ata_drv && ATAMount(blkdev.first_hd_drv_let,BDT_ATA,
|
||||
@@ -265,18 +265,18 @@ I64 AutoMountIDE()
|
||||
if (atapi_drv && ATAMount(blkdev.first_dvd_drv_let,BDT_ATAPI,
|
||||
atapi_drv->base0,atapi_drv->base1,atapi_drv->unit))
|
||||
res++;
|
||||
tempha=head;
|
||||
while (tempha) {
|
||||
if (tempha!=ata_drv && tempha!=atapi_drv) {
|
||||
if (tempha->type==BDT_ATA && ATAMount(blkdev.first_hd_drv_let,BDT_ATA,
|
||||
tempha->base0,tempha->base1,tempha->unit))
|
||||
tmpha=head;
|
||||
while (tmpha) {
|
||||
if (tmpha!=ata_drv && tmpha!=atapi_drv) {
|
||||
if (tmpha->type==BDT_ATA && ATAMount(blkdev.first_hd_drv_let,BDT_ATA,
|
||||
tmpha->base0,tmpha->base1,tmpha->unit))
|
||||
res++;
|
||||
else if (tempha->type==BDT_ATAPI &&
|
||||
else if (tmpha->type==BDT_ATAPI &&
|
||||
ATAMount(blkdev.first_dvd_drv_let,BDT_ATAPI,
|
||||
tempha->base0,tempha->base1,tempha->unit))
|
||||
tmpha->base0,tmpha->base1,tmpha->unit))
|
||||
res++;
|
||||
}
|
||||
tempha=tempha->next;
|
||||
tmpha=tmpha->next;
|
||||
}
|
||||
LinkedLstDel(head);
|
||||
blkdev.auto_mount_ide_cnt=res;
|
||||
|
||||
+50
-50
@@ -1,6 +1,6 @@
|
||||
U0 DskCacheInit(I64 size_in_U8s)
|
||||
{
|
||||
CCacheBlk *tempc;
|
||||
CCacheBlk *tmpc;
|
||||
I64 i,cnt;
|
||||
|
||||
while (LBts(&sys_semas[SYS_SEMA_DSK_CACHE],0))
|
||||
@@ -20,18 +20,18 @@ U0 DskCacheInit(I64 size_in_U8s)
|
||||
cnt=MSize(blkdev.cache_base)/sizeof(CCacheBlk);
|
||||
blkdev.cache_size=cnt*BLK_SIZE;
|
||||
for (i=0;i<cnt;i++) {
|
||||
tempc=blkdev.cache_base+i;
|
||||
QueIns(tempc,blkdev.cache_ctrl->last_lru);
|
||||
tempc->next_hash=tempc->last_hash=tempc;
|
||||
tempc->dv=NULL;
|
||||
tempc->blk=0;
|
||||
tmpc=blkdev.cache_base+i;
|
||||
QueIns(tmpc,blkdev.cache_ctrl->last_lru);
|
||||
tmpc->next_hash=tmpc->last_hash=tmpc;
|
||||
tmpc->dv=NULL;
|
||||
tmpc->blk=0;
|
||||
}
|
||||
|
||||
blkdev.cache_hash_table=AMAlloc(DSK_CACHE_HASH_SIZE*sizeof(U8 *)*2);
|
||||
for (i=0;i<DSK_CACHE_HASH_SIZE;i++) {
|
||||
tempc=blkdev.cache_hash_table(U8 *)+i*sizeof(U8 *)*2
|
||||
tmpc=blkdev.cache_hash_table(U8 *)+i*sizeof(U8 *)*2
|
||||
-offset(CCacheBlk.next_hash);
|
||||
tempc->next_hash=tempc->last_hash=tempc;
|
||||
tmpc->next_hash=tmpc->last_hash=tmpc;
|
||||
}
|
||||
}
|
||||
LBtr(&sys_semas[SYS_SEMA_DSK_CACHE],0);
|
||||
@@ -43,50 +43,50 @@ I64 DskCacheHash(I64 blk)
|
||||
return blkdev.cache_hash_table(U8 *)+i<<4-offset(CCacheBlk.next_hash);
|
||||
}
|
||||
|
||||
U0 DskCacheQueRem(CCacheBlk *tempc)
|
||||
U0 DskCacheQueRem(CCacheBlk *tmpc)
|
||||
{
|
||||
QueRem(tempc);
|
||||
tempc->next_hash->last_hash=tempc->last_hash;
|
||||
tempc->last_hash->next_hash=tempc->next_hash;
|
||||
QueRem(tmpc);
|
||||
tmpc->next_hash->last_hash=tmpc->last_hash;
|
||||
tmpc->last_hash->next_hash=tmpc->next_hash;
|
||||
}
|
||||
|
||||
U0 DskCacheQueIns(CCacheBlk *tempc)
|
||||
U0 DskCacheQueIns(CCacheBlk *tmpc)
|
||||
{
|
||||
CCacheBlk *temp_n,*temp_l;
|
||||
QueIns(tempc,blkdev.cache_ctrl->last_lru);
|
||||
temp_l=DskCacheHash(tempc->blk);
|
||||
temp_n=temp_l->next_hash;
|
||||
tempc->last_hash=temp_l;
|
||||
tempc->next_hash=temp_n;
|
||||
temp_l->next_hash=temp_n->last_hash=tempc;
|
||||
CCacheBlk *tmp_n,*tmp_l;
|
||||
QueIns(tmpc,blkdev.cache_ctrl->last_lru);
|
||||
tmp_l=DskCacheHash(tmpc->blk);
|
||||
tmp_n=tmp_l->next_hash;
|
||||
tmpc->last_hash=tmp_l;
|
||||
tmpc->next_hash=tmp_n;
|
||||
tmp_l->next_hash=tmp_n->last_hash=tmpc;
|
||||
}
|
||||
|
||||
CCacheBlk *DskCacheFind(CDrv *dv,I64 blk)
|
||||
{
|
||||
CCacheBlk *tempc,*tempc1=DskCacheHash(blk);
|
||||
tempc=tempc1->next_hash;
|
||||
while (tempc!=tempc1) {
|
||||
if (tempc->dv==dv && tempc->blk==blk)
|
||||
return tempc;
|
||||
tempc=tempc->next_hash;
|
||||
CCacheBlk *tmpc,*tmpc1=DskCacheHash(blk);
|
||||
tmpc=tmpc1->next_hash;
|
||||
while (tmpc!=tmpc1) {
|
||||
if (tmpc->dv==dv && tmpc->blk==blk)
|
||||
return tmpc;
|
||||
tmpc=tmpc->next_hash;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
U0 DskCacheAdd(CDrv *dv,U8 *buf, I64 blk, I64 cnt)
|
||||
{
|
||||
CCacheBlk *tempc;
|
||||
CCacheBlk *tmpc;
|
||||
if (blkdev.cache_base) {
|
||||
while (LBts(&sys_semas[SYS_SEMA_DSK_CACHE],0))
|
||||
Yield;
|
||||
while (cnt-->0) {
|
||||
if (!(tempc=DskCacheFind(dv,blk)))
|
||||
tempc=blkdev.cache_ctrl->next_lru;
|
||||
DskCacheQueRem(tempc);
|
||||
MemCpy(&tempc->body,buf,BLK_SIZE);
|
||||
tempc->dv=dv;
|
||||
tempc->blk=blk;
|
||||
DskCacheQueIns(tempc);
|
||||
if (!(tmpc=DskCacheFind(dv,blk)))
|
||||
tmpc=blkdev.cache_ctrl->next_lru;
|
||||
DskCacheQueRem(tmpc);
|
||||
MemCpy(&tmpc->body,buf,BLK_SIZE);
|
||||
tmpc->dv=dv;
|
||||
tmpc->blk=blk;
|
||||
DskCacheQueIns(tmpc);
|
||||
blk++;
|
||||
buf+=BLK_SIZE;
|
||||
}
|
||||
@@ -96,21 +96,21 @@ U0 DskCacheAdd(CDrv *dv,U8 *buf, I64 blk, I64 cnt)
|
||||
|
||||
U0 DskCacheInvalidate2(CDrv *dv)
|
||||
{
|
||||
CCacheBlk *tempc,*tempc1;
|
||||
CCacheBlk *tmpc,*tmpc1;
|
||||
if (blkdev.cache_base) {
|
||||
while (LBts(&sys_semas[SYS_SEMA_DSK_CACHE],0))
|
||||
Yield;
|
||||
tempc=blkdev.cache_ctrl->last_lru;
|
||||
while (tempc!=blkdev.cache_ctrl) {
|
||||
tempc1=tempc->last_lru;
|
||||
if (tempc->dv==dv) {
|
||||
DskCacheQueRem(tempc);
|
||||
tempc->dv=NULL;
|
||||
tempc->blk=0;
|
||||
tempc->next_hash=tempc->last_hash=tempc;
|
||||
QueIns(tempc,blkdev.cache_ctrl->last_lru);
|
||||
tmpc=blkdev.cache_ctrl->last_lru;
|
||||
while (tmpc!=blkdev.cache_ctrl) {
|
||||
tmpc1=tmpc->last_lru;
|
||||
if (tmpc->dv==dv) {
|
||||
DskCacheQueRem(tmpc);
|
||||
tmpc->dv=NULL;
|
||||
tmpc->blk=0;
|
||||
tmpc->next_hash=tmpc->last_hash=tmpc;
|
||||
QueIns(tmpc,blkdev.cache_ctrl->last_lru);
|
||||
}
|
||||
tempc=tempc1;
|
||||
tmpc=tmpc1;
|
||||
}
|
||||
LBtr(&sys_semas[SYS_SEMA_DSK_CACHE],0);
|
||||
}
|
||||
@@ -118,14 +118,14 @@ U0 DskCacheInvalidate2(CDrv *dv)
|
||||
|
||||
U0 RCache(CDrv *dv,U8 **_buf, I64 *_blk, I64 *_cnt)
|
||||
{
|
||||
CCacheBlk *tempc;
|
||||
CCacheBlk *tmpc;
|
||||
if (blkdev.cache_base) {
|
||||
while (LBts(&sys_semas[SYS_SEMA_DSK_CACHE],0))
|
||||
Yield;
|
||||
//fetch leading blks from cache
|
||||
while (*_cnt>0) {
|
||||
if (tempc=DskCacheFind(dv,*_blk)) {
|
||||
MemCpy(*_buf,&tempc->body,BLK_SIZE);
|
||||
if (tmpc=DskCacheFind(dv,*_blk)) {
|
||||
MemCpy(*_buf,&tmpc->body,BLK_SIZE);
|
||||
*_cnt-=1;
|
||||
*_buf+=BLK_SIZE;
|
||||
*_blk+=1;
|
||||
@@ -134,8 +134,8 @@ U0 RCache(CDrv *dv,U8 **_buf, I64 *_blk, I64 *_cnt)
|
||||
}
|
||||
//fetch trailing blks from cache
|
||||
while (*_cnt>0) {
|
||||
if (tempc=DskCacheFind(dv,*_blk+*_cnt-1)) {
|
||||
MemCpy(*_buf+(*_cnt-1)<<BLK_SIZE_BITS,&tempc->body,BLK_SIZE);
|
||||
if (tmpc=DskCacheFind(dv,*_blk+*_cnt-1)) {
|
||||
MemCpy(*_buf+(*_cnt-1)<<BLK_SIZE_BITS,&tmpc->body,BLK_SIZE);
|
||||
*_cnt-=1;
|
||||
} else
|
||||
break;
|
||||
|
||||
+61
-61
@@ -1,10 +1,10 @@
|
||||
Bool DirNew(CDrv *dv,U8 *cur_dir,CDirEntry *tempde,Bool free_old_chain=TRUE)
|
||||
Bool DirNew(CDrv *dv,U8 *cur_dir,CDirEntry *tmpde,Bool free_old_chain=TRUE)
|
||||
{//Makes a directory entry in the directory from a $LK,"CDirEntry",A="MN:CDirEntry"$ node.
|
||||
switch (dv->fs_type) {
|
||||
case FSt_REDSEA:
|
||||
return RedSeaDirNew(dv,cur_dir,tempde,free_old_chain);
|
||||
return RedSeaDirNew(dv,cur_dir,tmpde,free_old_chain);
|
||||
case FSt_FAT32:
|
||||
return FAT32DirNew(dv,cur_dir,tempde,free_old_chain);
|
||||
return FAT32DirNew(dv,cur_dir,tmpde,free_old_chain);
|
||||
case FSt_ISO9660:
|
||||
PrintErr("Not Writable\n");
|
||||
return FALSE;
|
||||
@@ -14,48 +14,48 @@ Bool DirNew(CDrv *dv,U8 *cur_dir,CDirEntry *tempde,Bool free_old_chain=TRUE)
|
||||
}
|
||||
}
|
||||
|
||||
U0 DirEntryDel(CDirEntry *tempde)
|
||||
U0 DirEntryDel(CDirEntry *tmpde)
|
||||
{//Free node returned from $LK,"FilesFind",A="MN:FilesFind"$(). Doesn't Free user_data.
|
||||
//Does not change the directory on disk.
|
||||
if (tempde) {
|
||||
Free(tempde->full_name);
|
||||
Free(tempde);
|
||||
if (tmpde) {
|
||||
Free(tmpde->full_name);
|
||||
Free(tmpde);
|
||||
}
|
||||
}
|
||||
|
||||
U0 DirEntryDel2(CDirEntry *tempde)
|
||||
U0 DirEntryDel2(CDirEntry *tmpde)
|
||||
{//Free node returned from $LK,"FilesFind",A="MN:FilesFind"$(). Frees user_data
|
||||
//Does not change the directory on disk.
|
||||
if (tempde) {
|
||||
Free(tempde->full_name);
|
||||
Free(tempde->user_data);
|
||||
Free(tempde);
|
||||
if (tmpde) {
|
||||
Free(tmpde->full_name);
|
||||
Free(tmpde->user_data);
|
||||
Free(tmpde);
|
||||
}
|
||||
}
|
||||
|
||||
U0 DirTreeDel(CDirEntry *tempde)
|
||||
U0 DirTreeDel(CDirEntry *tmpde)
|
||||
{//Free tree returned from $LK,"FilesFind",A="MN:FilesFind"$(). Doesn't Free user_data.
|
||||
//Does not change the directory on disk.
|
||||
CDirEntry *tempde2;
|
||||
while (tempde) {
|
||||
tempde2=tempde->next;
|
||||
if (tempde->sub)
|
||||
DirTreeDel(tempde->sub);
|
||||
DirEntryDel(tempde);
|
||||
tempde=tempde2;
|
||||
CDirEntry *tmpde2;
|
||||
while (tmpde) {
|
||||
tmpde2=tmpde->next;
|
||||
if (tmpde->sub)
|
||||
DirTreeDel(tmpde->sub);
|
||||
DirEntryDel(tmpde);
|
||||
tmpde=tmpde2;
|
||||
}
|
||||
}
|
||||
|
||||
U0 DirTreeDel2(CDirEntry *tempde)
|
||||
U0 DirTreeDel2(CDirEntry *tmpde)
|
||||
{//Free tree returned from $LK,"FilesFind",A="MN:FilesFind"$(). Frees user_data
|
||||
//Does not change the directory on disk.
|
||||
CDirEntry *tempde2;
|
||||
while (tempde) {
|
||||
tempde2=tempde->next;
|
||||
if (tempde->sub)
|
||||
DirTreeDel2(tempde->sub);
|
||||
DirEntryDel2(tempde);
|
||||
tempde=tempde2;
|
||||
CDirEntry *tmpde2;
|
||||
while (tmpde) {
|
||||
tmpde2=tmpde->next;
|
||||
if (tmpde->sub)
|
||||
DirTreeDel2(tmpde->sub);
|
||||
DirEntryDel2(tmpde);
|
||||
tmpde=tmpde2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,19 +89,19 @@ I64 DirEntryCompareCluster(CDirEntry *e1,CDirEntry *e2)
|
||||
#define SK_NAME 0
|
||||
#define SK_CLUSTER 1
|
||||
|
||||
U0 DirFilesSort(CDirEntry **_tempde,I64 key)
|
||||
U0 DirFilesSort(CDirEntry **_tmpde,I64 key)
|
||||
{
|
||||
I64 i,cnt;
|
||||
CDirEntry *tempde=*_tempde,*tempde1,**sort_buf;
|
||||
if (tempde) {
|
||||
cnt=LinkedLstCnt(tempde);
|
||||
CDirEntry *tmpde=*_tmpde,*tmpde1,**sort_buf;
|
||||
if (tmpde) {
|
||||
cnt=LinkedLstCnt(tmpde);
|
||||
if (cnt>1) {
|
||||
sort_buf=MAlloc(cnt*sizeof(U8 *));
|
||||
i=0;
|
||||
tempde1=tempde;
|
||||
while (tempde1) {
|
||||
sort_buf[i++]=tempde1;
|
||||
tempde1=tempde1->next;
|
||||
tmpde1=tmpde;
|
||||
while (tmpde1) {
|
||||
sort_buf[i++]=tmpde1;
|
||||
tmpde1=tmpde1->next;
|
||||
}
|
||||
switch [key] {
|
||||
case SK_NAME:
|
||||
@@ -111,48 +111,48 @@ U0 DirFilesSort(CDirEntry **_tempde,I64 key)
|
||||
QSortI64(sort_buf,cnt,&DirEntryCompareCluster);
|
||||
break;
|
||||
}
|
||||
tempde=sort_buf[0];
|
||||
*_tempde=tempde;
|
||||
tmpde=sort_buf[0];
|
||||
*_tmpde=tmpde;
|
||||
for (i=0;i<cnt-1;i++) {
|
||||
tempde1=sort_buf[i];
|
||||
tempde1->next=sort_buf[i+1];
|
||||
tmpde1=sort_buf[i];
|
||||
tmpde1->next=sort_buf[i+1];
|
||||
}
|
||||
tempde1=sort_buf[i];
|
||||
tempde1->next=NULL;
|
||||
tmpde1=sort_buf[i];
|
||||
tmpde1->next=NULL;
|
||||
Free(sort_buf);
|
||||
|
||||
tempde1=tempde;
|
||||
while (tempde1) {
|
||||
if (tempde1->sub)
|
||||
DirFilesSort(&tempde1->sub,key);
|
||||
tempde1=tempde1->next;
|
||||
tmpde1=tmpde;
|
||||
while (tmpde1) {
|
||||
if (tmpde1->sub)
|
||||
DirFilesSort(&tmpde1->sub,key);
|
||||
tmpde1=tmpde1->next;
|
||||
}
|
||||
} else
|
||||
if (tempde->sub)
|
||||
DirFilesSort(&tempde->sub,key);
|
||||
if (tmpde->sub)
|
||||
DirFilesSort(&tmpde->sub,key);
|
||||
}
|
||||
}
|
||||
|
||||
CDirEntry *DirFilesFlatten(CDirEntry *tempde,CDirEntry **_res,I64 fuf_flags)
|
||||
CDirEntry *DirFilesFlatten(CDirEntry *tmpde,CDirEntry **_res,I64 fuf_flags)
|
||||
{//Returns last node
|
||||
CDirEntry *tempde1;
|
||||
CDirEntry *tmpde1;
|
||||
Bool del;
|
||||
if (tempde)
|
||||
if (tmpde)
|
||||
while (TRUE) {
|
||||
tempde1=tempde->next;
|
||||
if (!(tempde->attr&RS_ATTR_DIR)||!(fuf_flags&FUF_JUST_FILES)) {
|
||||
_res=*_res=tempde;
|
||||
tmpde1=tmpde->next;
|
||||
if (!(tmpde->attr&RS_ATTR_DIR)||!(fuf_flags&FUF_JUST_FILES)) {
|
||||
_res=*_res=tmpde;
|
||||
del=FALSE;
|
||||
} else
|
||||
del=TRUE;
|
||||
if (tempde->sub) {
|
||||
_res=DirFilesFlatten(tempde->sub,_res,fuf_flags);
|
||||
tempde->sub=NULL;
|
||||
if (tmpde->sub) {
|
||||
_res=DirFilesFlatten(tmpde->sub,_res,fuf_flags);
|
||||
tmpde->sub=NULL;
|
||||
}
|
||||
if (del)
|
||||
DirEntryDel(tempde);
|
||||
if (tempde1)
|
||||
tempde=tempde1;
|
||||
DirEntryDel(tmpde);
|
||||
if (tmpde1)
|
||||
tmpde=tmpde1;
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
+22
-22
@@ -104,28 +104,28 @@ Bool IsDir(U8 *dir_name)
|
||||
|
||||
I64 Dir(U8 *files_find_mask,Bool full)
|
||||
{//List directory.
|
||||
CDirEntry *tempde1=NULL,*tempde2;
|
||||
CDirEntry *tmpde1=NULL,*tmpde2;
|
||||
U8 *st;
|
||||
CDateStruct ds;
|
||||
I64 csize=0xFFFF,c=0xFFFF,res=0;
|
||||
tempde1=FilesFind(files_find_mask);
|
||||
tmpde1=FilesFind(files_find_mask);
|
||||
if (!(st=CurDir))
|
||||
PrintErr("Invalid Drive\n");
|
||||
else {
|
||||
if (tempde1) {
|
||||
if (tmpde1) {
|
||||
Free(st);
|
||||
st=MAllocIdent(tempde1->full_name);
|
||||
st=MAllocIdent(tmpde1->full_name);
|
||||
StrLastRem(st,"/");
|
||||
if (!st[2])
|
||||
StrCpy(st+2,"/");
|
||||
//Find max columns
|
||||
tempde2=tempde1;
|
||||
while (tempde2) {
|
||||
if (tempde2->size>csize)
|
||||
csize=tempde2->size;
|
||||
if (tempde2->cluster>c)
|
||||
c=tempde2->cluster;
|
||||
tempde2=tempde2->next;
|
||||
tmpde2=tmpde1;
|
||||
while (tmpde2) {
|
||||
if (tmpde2->size>csize)
|
||||
csize=tmpde2->size;
|
||||
if (tmpde2->cluster>c)
|
||||
c=tmpde2->cluster;
|
||||
tmpde2=tmpde2->next;
|
||||
}
|
||||
csize=Bsr(csize)/4+1;
|
||||
c=Bsr(c)/4+1;
|
||||
@@ -136,24 +136,24 @@ I64 Dir(U8 *files_find_mask,Bool full)
|
||||
csize,"SIZE",c,"CLUSTER";
|
||||
else
|
||||
"DATE_ TIME_ %*ts\n",csize,"SIZE";
|
||||
while (tempde1) {
|
||||
tempde2=tempde1->next;
|
||||
while (tmpde1) {
|
||||
tmpde2=tmpde1->next;
|
||||
res++;
|
||||
if (full)
|
||||
"%D %T %0*tX %0*tX ",tempde1->datetime,tempde1->datetime,
|
||||
csize,tempde1->size,c,tempde1->cluster;
|
||||
"%D %T %0*tX %0*tX ",tmpde1->datetime,tmpde1->datetime,
|
||||
csize,tmpde1->size,c,tmpde1->cluster;
|
||||
else {
|
||||
Date2Struct(&ds,tempde1->datetime+local_time_offset);
|
||||
Date2Struct(&ds,tmpde1->datetime+local_time_offset);
|
||||
"%02d/%02d %02d:%02d %0*tX ",ds.mon,ds.day_of_mon,ds.hour,ds.min,
|
||||
csize,tempde1->size;
|
||||
csize,tmpde1->size;
|
||||
}
|
||||
if (tempde1->attr & RS_ATTR_DIR)
|
||||
PutDirLink(tempde1->name,tempde1->full_name);
|
||||
if (tmpde1->attr & RS_ATTR_DIR)
|
||||
PutDirLink(tmpde1->name,tmpde1->full_name);
|
||||
else
|
||||
PutFileLink(tempde1->name,tempde1->full_name);
|
||||
PutFileLink(tmpde1->name,tmpde1->full_name);
|
||||
'\n';
|
||||
DirEntryDel(tempde1);
|
||||
tempde1=tempde2;
|
||||
DirEntryDel(tmpde1);
|
||||
tmpde1=tmpde2;
|
||||
}
|
||||
} else
|
||||
"No matching entries\n";
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
U0 DirContextDel(CDirContext *dirc)
|
||||
U0 DirContextDel(CDirContext *dirc,Bool restore=TRUE)
|
||||
{//Change back to old cur_dir and drv.
|
||||
CBlkDev *bd;
|
||||
if (!dirc) return;
|
||||
bd=dirc->old_dv->bd;
|
||||
if (!(bd->flags & BDF_INIT_IN_PROGRESS)) {
|
||||
if (dirc->old_dir) {
|
||||
Drv(Drv2Let(dirc->old_dv));
|
||||
Cd(dirc->old_dir);
|
||||
if (restore) {
|
||||
bd=dirc->old_dv->bd;
|
||||
if (!(bd->flags & BDF_INIT_IN_PROGRESS)) {
|
||||
if (dirc->old_dir) {
|
||||
Drv(Drv2Let(dirc->old_dv));
|
||||
Cd(dirc->old_dir);
|
||||
}
|
||||
} else {
|
||||
Fs->cur_dv=dirc->old_dv;
|
||||
Free(Fs->cur_dir);
|
||||
Fs->cur_dir=StrNew("/");
|
||||
}
|
||||
} else {
|
||||
Fs->cur_dv=dirc->old_dv;
|
||||
Free(Fs->cur_dir);
|
||||
Fs->cur_dir=StrNew("/");
|
||||
}
|
||||
Free(dirc->old_dir);
|
||||
Free(dirc->mask);
|
||||
@@ -23,12 +25,12 @@ CDirContext *DirContextNew(U8 *_mask,Bool make_mask=FALSE,
|
||||
{//Save cur_dir and drv. Change to new dir.
|
||||
Bool valid=TRUE,old_silent;
|
||||
I64 mask_len=StrLen(_mask);
|
||||
U8 *buf,*mask,*temp_mask,*semicolon_mask;
|
||||
U8 *buf,*mask,*tmp_mask,*semicolon_mask;
|
||||
CDirContext *dirc=CAlloc(sizeof(CDirContext));
|
||||
dirc->old_dir=StrNew(Fs->cur_dir);
|
||||
dirc->old_dv=Fs->cur_dv;
|
||||
mask=MStrUtil(_mask,SUF_REM_LEADING|SUF_REM_TRAILING|SUF_REM_CTRL_CHARS);
|
||||
temp_mask=mask;
|
||||
tmp_mask=mask;
|
||||
if (*mask && mask[1]==':') {
|
||||
if (Fs->cur_dv!=Let2Drv(*mask) && !Drv(*mask))
|
||||
valid=FALSE;
|
||||
@@ -76,7 +78,7 @@ CDirContext *DirContextNew(U8 *_mask,Bool make_mask=FALSE,
|
||||
}
|
||||
}
|
||||
Free(buf);
|
||||
Free(temp_mask);
|
||||
Free(tmp_mask);
|
||||
if (!valid) {
|
||||
DirContextDel(dirc);
|
||||
dirc=NULL;
|
||||
|
||||
+12
-12
@@ -1,19 +1,19 @@
|
||||
U8 *FileRead(U8 *filename,I64 *_size=NULL,I64 *_attr=NULL)
|
||||
{//Read whole file from disk.
|
||||
CHashGeneric *temph;
|
||||
CHashGeneric *tmph;
|
||||
U8 *absname,*altname,*curname,*res=NULL;
|
||||
I64 i,size=0,attr=0;
|
||||
CDirContext *dirc;
|
||||
CArcCompress *arc;
|
||||
absname=FileNameAbs(filename);
|
||||
altname=ToggleZorNotZ(absname);
|
||||
if ((temph=HashFind(absname,adam_task->hash_table,HTT_FILE))||
|
||||
(temph=HashFind(altname,adam_task->hash_table,HTT_FILE))) {
|
||||
size=temph->user_data1;
|
||||
if ((tmph=HashFind(absname,adam_task->hash_table,HTT_FILE))||
|
||||
(tmph=HashFind(altname,adam_task->hash_table,HTT_FILE))) {
|
||||
size=tmph->user_data1;
|
||||
res=MAlloc(size+1);
|
||||
MemCpy(res,temph->user_data0,size);
|
||||
MemCpy(res,tmph->user_data0,size);
|
||||
res[size]=0; //Terminate
|
||||
attr=FileAttr(temph->str,attr);
|
||||
attr=FileAttr(tmph->str,attr);
|
||||
} else {
|
||||
for (i=0;i<2 && !res;i++) {//Try name, then altname
|
||||
if (!i)
|
||||
@@ -87,7 +87,7 @@ U8 *FileRead(U8 *filename,I64 *_size=NULL,I64 *_attr=NULL)
|
||||
I64 FileWrite(U8 *filename,U8 *fbuf,I64 size,CDate cdt=0,I64 attr=0)
|
||||
{//Write whole file to disk.
|
||||
I64 c=0;
|
||||
CHashGeneric *temph;
|
||||
CHashGeneric *tmph;
|
||||
CDirContext *dirc;
|
||||
U8 *fbuf2,*absname=FileNameAbs(filename);
|
||||
if (dirc=DirContextNew(filename,FALSE,TRUE)) {
|
||||
@@ -112,13 +112,13 @@ I64 FileWrite(U8 *filename,U8 *fbuf,I64 size,CDate cdt=0,I64 attr=0)
|
||||
default:
|
||||
PrintErr("File System Not Supported\n");
|
||||
}
|
||||
if (temph=HashFind(absname,adam_task->hash_table,HTT_FILE)) {
|
||||
if (tmph=HashFind(absname,adam_task->hash_table,HTT_FILE)) {
|
||||
if (attr & RS_ATTR_RESIDENT) {
|
||||
Free(temph->user_data0);
|
||||
temph->user_data0=AMAllocIdent(fbuf);
|
||||
temph->user_data1=size;
|
||||
Free(tmph->user_data0);
|
||||
tmph->user_data0=AMAllocIdent(fbuf);
|
||||
tmph->user_data1=size;
|
||||
} else
|
||||
HashRemDel(temph,adam_task->hash_table);
|
||||
HashRemDel(tmph,adam_task->hash_table);
|
||||
} else if (attr & RS_ATTR_RESIDENT)
|
||||
HashGenericAdd(absname,HTT_FILE,AMAllocIdent(fbuf),size,0,adam_task);
|
||||
Free(fbuf2);
|
||||
|
||||
+17
-13
@@ -71,6 +71,10 @@ Bool FilesFindMatch(U8 *_test_name,U8 *files_find_mask,I64 fuf_flags=0)
|
||||
!FilesFindMatch(_test_name,FILEMASK_TXT)) {
|
||||
res=FALSE;
|
||||
break;
|
||||
} else if (Bt(&fuf_flags,FUf_JUST_DD) &&
|
||||
!FilesFindMatch(_test_name,FILEMASK_DD)) {
|
||||
res=FALSE;
|
||||
break;
|
||||
} else if (Bt(&fuf_flags,FUf_JUST_SRC) &&
|
||||
!FilesFindMatch(_test_name,FILEMASK_SRC)) {
|
||||
res=FALSE;
|
||||
@@ -83,8 +87,8 @@ Bool FilesFindMatch(U8 *_test_name,U8 *files_find_mask,I64 fuf_flags=0)
|
||||
!FilesFindMatch(_test_name,FILEMASK_JIT)) {
|
||||
res=FALSE;
|
||||
break;
|
||||
} else if (Bt(&fuf_flags,FUf_JUST_GRA) &&
|
||||
!FilesFindMatch(_test_name,FILEMASK_GRA)) {
|
||||
} else if (Bt(&fuf_flags,FUf_JUST_GR) &&
|
||||
!FilesFindMatch(_test_name,FILEMASK_GR)) {
|
||||
res=FALSE;
|
||||
break;
|
||||
} else
|
||||
@@ -214,19 +218,19 @@ U8 *DftExt(U8 *filename,U8 *extension)
|
||||
return res;
|
||||
}
|
||||
|
||||
CDirEntry *Cd2DirEntry(CDirEntry *tempde,U8 *abs_name)
|
||||
CDirEntry *Cd2DirEntry(CDirEntry *tmpde,U8 *abs_name)
|
||||
{
|
||||
I64 i;
|
||||
while (tempde) {
|
||||
i=StrLen(tempde->full_name);
|
||||
if (StrNCmp(tempde->full_name,abs_name,i)||
|
||||
i && tempde->full_name[i-1]!='/' && abs_name[i] && abs_name[i]!='/')
|
||||
tempde=tempde->next;
|
||||
while (tmpde) {
|
||||
i=StrLen(tmpde->full_name);
|
||||
if (StrNCmp(tmpde->full_name,abs_name,i)||
|
||||
i && tmpde->full_name[i-1]!='/' && abs_name[i] && abs_name[i]!='/')
|
||||
tmpde=tmpde->next;
|
||||
else
|
||||
if (StrLen(abs_name)==i)
|
||||
return tempde;
|
||||
return tmpde;
|
||||
else
|
||||
return Cd2DirEntry(tempde->sub,abs_name);
|
||||
return Cd2DirEntry(tmpde->sub,abs_name);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -269,9 +273,9 @@ U8 *ToggleZorNotZ(U8 *name)
|
||||
return res;
|
||||
}
|
||||
|
||||
U8 *FileNameTempTxt()
|
||||
{//Make pretty-safe temp filename in home dir.
|
||||
return MStrPrint("~/SysTemp%X.DD.Z",GetTSC>>8&0xFFFFFFFF);
|
||||
U8 *FileNameTmpTxt()
|
||||
{//Make pretty-safe tmp filename in home dir.
|
||||
return MStrPrint("~/SysTmp%X.DD.Z",GetTSC>>8&0xFFFFFFFF);
|
||||
}
|
||||
|
||||
U8 *CurDir(CTask *task=NULL,CTask *mem_task=NULL)
|
||||
|
||||
+56
-56
@@ -196,50 +196,50 @@ U8 fat_long_name_map[13]={
|
||||
offset(CFAT32DirEntryLong.name3)+2
|
||||
};
|
||||
|
||||
Bool DirLongNameFill(CDirEntry *tempde,CFAT32DirEntryLong *de,I64 *xsum)
|
||||
Bool DirLongNameFill(CDirEntry *tmpde,CFAT32DirEntryLong *de,I64 *xsum)
|
||||
{
|
||||
I64 i;
|
||||
U8 *ptr=de;
|
||||
if (de->ord&0x40) {
|
||||
MemSet(tempde,0,sizeof(CDirEntry));
|
||||
MemSet(tmpde,0,sizeof(CDirEntry));
|
||||
*xsum=de->xsum;
|
||||
} else if (de->type || de->zero || de->xsum!=*xsum) {
|
||||
MemSet(tempde,0,sizeof(CDirEntry));
|
||||
MemSet(tmpde,0,sizeof(CDirEntry));
|
||||
*xsum=0;
|
||||
return FALSE;
|
||||
}
|
||||
switch (de->ord&0x3F) {
|
||||
case 1:
|
||||
for (i=0;i<13;i++)
|
||||
if (!(tempde->name[i]=ptr[fat_long_name_map[i]]))
|
||||
if (!(tmpde->name[i]=ptr[fat_long_name_map[i]]))
|
||||
return TRUE;
|
||||
break;
|
||||
case 2:
|
||||
for (i=0;i<12;i++)
|
||||
if (!(tempde->name[i+13]=ptr[fat_long_name_map[i]]))
|
||||
if (!(tmpde->name[i+13]=ptr[fat_long_name_map[i]]))
|
||||
return TRUE;
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Bool FAT32CDirFill(CDirEntry *tempde,
|
||||
Bool FAT32CDirFill(CDirEntry *tmpde,
|
||||
CFAT32DirEntry *de,CDate _local_time_offset)
|
||||
{
|
||||
Bool res;
|
||||
if (*tempde->name)
|
||||
if (*tmpde->name)
|
||||
res=TRUE;
|
||||
else
|
||||
res=FATFromName(tempde->name,de->name);
|
||||
tempde->cluster=de->cluster_lo+de->cluster_hi<<16;
|
||||
tempde->size=de->size;
|
||||
tempde->attr=de->attr;
|
||||
tempde->datetime=Dos2CDate(de->WrtTime,de->WrtDate)-_local_time_offset;
|
||||
res=FATFromName(tmpde->name,de->name);
|
||||
tmpde->cluster=de->cluster_lo+de->cluster_hi<<16;
|
||||
tmpde->size=de->size;
|
||||
tmpde->attr=de->attr;
|
||||
tmpde->datetime=Dos2CDate(de->WrtTime,de->WrtDate)-_local_time_offset;
|
||||
return res;
|
||||
}
|
||||
|
||||
Bool FAT32DirFill(CFAT32DirEntry *de,
|
||||
CDirEntry *tempde,I64 *_de_cnt,CDate _local_time_offset)
|
||||
CDirEntry *tmpde,I64 *_de_cnt,CDate _local_time_offset)
|
||||
{//Fill up to 3 entries and store cnt of entries.
|
||||
I64 de_cnt=0,i,l,xsum,ord;
|
||||
U8 *ptr,dname[16];
|
||||
@@ -247,19 +247,19 @@ Bool FAT32DirFill(CFAT32DirEntry *de,
|
||||
Bool res;
|
||||
|
||||
MemSet(de,0,sizeof(CFAT32DirEntry));
|
||||
res=FATNameTo(de->name,tempde->name);
|
||||
res=FATNameTo(de->name,tmpde->name);
|
||||
FATFromName(dname,de->name);
|
||||
if (StrCmp(dname,tempde->name)) {
|
||||
if (StrCmp(dname,tmpde->name)) {
|
||||
ord=0x41;
|
||||
xsum=FATNameXSum(de->name);
|
||||
if ((l=StrLen(tempde->name))>13) {
|
||||
if ((l=StrLen(tmpde->name))>13) {
|
||||
ptr=&ld[de_cnt];
|
||||
MemSet(ptr,0,sizeof(CFAT32DirEntryLong));
|
||||
ld[de_cnt].attr=RS_ATTR_LONG_NAME;
|
||||
ld[de_cnt].xsum=xsum;
|
||||
ld[de_cnt].ord=0x42;
|
||||
for (i=13;i<l;i++)
|
||||
ptr[fat_long_name_map[i-13]]=tempde->name[i];
|
||||
ptr[fat_long_name_map[i-13]]=tmpde->name[i];
|
||||
i++;
|
||||
for (;i<26;i++)
|
||||
ptr[fat_long_name_map[i-13]](U16)=0xFFFF;
|
||||
@@ -273,23 +273,23 @@ Bool FAT32DirFill(CFAT32DirEntry *de,
|
||||
ld[de_cnt].xsum=xsum;
|
||||
ld[de_cnt].ord=ord;
|
||||
for (i=0;i<l;i++)
|
||||
ptr[fat_long_name_map[i]]=tempde->name[i];
|
||||
ptr[fat_long_name_map[i]]=tmpde->name[i];
|
||||
i++;
|
||||
for (;i<13;i++)
|
||||
ptr[fat_long_name_map[i]](U16)=0xFFFF;
|
||||
de_cnt++;
|
||||
MemSet(&de[de_cnt],0,sizeof(CFAT32DirEntry));
|
||||
res=FATNameTo(de[de_cnt].name,tempde->name);
|
||||
res=FATNameTo(de[de_cnt].name,tmpde->name);
|
||||
}
|
||||
de[de_cnt].cluster_lo=tempde->cluster.u16[0];
|
||||
de[de_cnt].cluster_hi=tempde->cluster.u16[1];
|
||||
if (!(tempde->attr&RS_ATTR_DIR))
|
||||
de[de_cnt].size=tempde->size;
|
||||
de[de_cnt].attr=tempde->attr;
|
||||
if (!tempde->datetime)
|
||||
tempde->datetime=Now;
|
||||
de[de_cnt].cluster_lo=tmpde->cluster.u16[0];
|
||||
de[de_cnt].cluster_hi=tmpde->cluster.u16[1];
|
||||
if (!(tmpde->attr&RS_ATTR_DIR))
|
||||
de[de_cnt].size=tmpde->size;
|
||||
de[de_cnt].attr=tmpde->attr;
|
||||
if (!tmpde->datetime)
|
||||
tmpde->datetime=Now;
|
||||
CDate2Dos(&de[de_cnt].WrtTime,&de[de_cnt].WrtDate,
|
||||
tempde->datetime+_local_time_offset);
|
||||
tmpde->datetime+_local_time_offset);
|
||||
if (_de_cnt)
|
||||
*_de_cnt=de_cnt+1;
|
||||
return res;
|
||||
@@ -573,17 +573,17 @@ I64 FAT32AllocContiguousClusters(CDrv *dv,I64 cnt)
|
||||
return first;
|
||||
}
|
||||
|
||||
Bool FAT32DirNew(CDrv *dv,U8 *cur_dir,CDirEntry *tempde,Bool free_old_chain)
|
||||
Bool FAT32DirNew(CDrv *dv,U8 *cur_dir,CDirEntry *tmpde,Bool free_old_chain)
|
||||
{
|
||||
//See $LK,"::/Doc/CutCorners.DD"$.
|
||||
CFAT32DirEntry *buf,*last_buf,*temp_buf,de[3];
|
||||
CFAT32DirEntry *buf,*last_buf,*tmp_buf,de[3];
|
||||
I64 i,attr,avail_cnt,de_cnt,c,
|
||||
cur_dir_entry,entries_per_cluster,
|
||||
cur_dir_cluster,xsum=0,last_dir_cluster=INVALID_CLUSTER;
|
||||
U8 ch;
|
||||
Bool written=FALSE,unlock,unlock_break;
|
||||
CDirEntry long_name;
|
||||
FAT32DirFill(&de,tempde,&de_cnt,dv->fat32_local_time_offset);
|
||||
FAT32DirFill(&de,tmpde,&de_cnt,dv->fat32_local_time_offset);
|
||||
MemSet(&long_name,0,sizeof(CDirEntry));
|
||||
try {
|
||||
unlock_break=BreakLock;
|
||||
@@ -620,7 +620,7 @@ Bool FAT32DirNew(CDrv *dv,U8 *cur_dir,CDirEntry *tempde,Bool free_old_chain)
|
||||
if (!*long_name.name)
|
||||
FATFromName(long_name.name,buf[cur_dir_entry].name);
|
||||
//Del old entry with same name
|
||||
if (!StrCmp(long_name.name,tempde->name)) {
|
||||
if (!StrCmp(long_name.name,tmpde->name)) {
|
||||
if (free_old_chain)
|
||||
FAT32FreeClusters(dv,buf[cur_dir_entry].cluster_lo+
|
||||
buf[cur_dir_entry].cluster_hi<<16);
|
||||
@@ -662,7 +662,7 @@ Bool FAT32DirNew(CDrv *dv,U8 *cur_dir,CDirEntry *tempde,Bool free_old_chain)
|
||||
}
|
||||
if (++cur_dir_entry==entries_per_cluster) {
|
||||
last_dir_cluster=cur_dir_cluster;
|
||||
temp_buf=buf; buf=last_buf; last_buf=temp_buf;
|
||||
tmp_buf=buf; buf=last_buf; last_buf=tmp_buf;
|
||||
c=ClusterNumNext(dv,cur_dir_cluster);
|
||||
if (!(0<c<0x0FFFFFF8)) {
|
||||
c=ClustersAlloc(dv,cur_dir_cluster,1,FALSE);
|
||||
@@ -685,7 +685,7 @@ Bool FAT32DirNew(CDrv *dv,U8 *cur_dir,CDirEntry *tempde,Bool free_old_chain)
|
||||
cur_dir_entry+=avail_cnt;
|
||||
if (cur_dir_entry==entries_per_cluster) {
|
||||
last_dir_cluster=cur_dir_cluster;
|
||||
temp_buf=buf; buf=last_buf; last_buf=temp_buf;
|
||||
tmp_buf=buf; buf=last_buf; last_buf=tmp_buf;
|
||||
cur_dir_cluster=ClustersAlloc(dv,cur_dir_cluster,1);
|
||||
cur_dir_entry=0;
|
||||
MemSet(buf,0,BLK_SIZE*dv->spc);
|
||||
@@ -726,7 +726,7 @@ Bool FAT32DirNew(CDrv *dv,U8 *cur_dir,CDirEntry *tempde,Bool free_old_chain)
|
||||
I64 FAT32FilesDel(CDrv *dv,U8 *cur_dir,U8 *files_find_mask,I64 fuf_flags,
|
||||
Bool del_dir,Bool print_msg)
|
||||
{
|
||||
CFAT32DirEntry *buf,*last_buf,*temp_buf;
|
||||
CFAT32DirEntry *buf,*last_buf,*tmp_buf;
|
||||
I64 i,res=0,attr,xsum=0,last_dir_cluster=INVALID_CLUSTER,
|
||||
cur_dir_entry,entries_per_cluster,cur_dir_cluster;
|
||||
U8 ch;
|
||||
@@ -792,7 +792,7 @@ I64 FAT32FilesDel(CDrv *dv,U8 *cur_dir,U8 *files_find_mask,I64 fuf_flags,
|
||||
if (++cur_dir_entry==entries_per_cluster) {
|
||||
last_dir_cluster=cur_dir_cluster;
|
||||
cur_dir_cluster=ClusterNumNext(dv,cur_dir_cluster,1);
|
||||
temp_buf=buf; buf=last_buf; last_buf=temp_buf;
|
||||
tmp_buf=buf; buf=last_buf; last_buf=tmp_buf;
|
||||
RClusters(dv,buf,cur_dir_cluster,1);
|
||||
cur_dir_entry=0;
|
||||
}
|
||||
@@ -851,7 +851,7 @@ CDirEntry *FAT32FilesFind(U8 *files_find_mask,
|
||||
I64 attr,xsum=0,dir_size=0,sub_dir_size,
|
||||
cur_dir_cluster,cur_dir_entry,entries_per_cluster;
|
||||
U8 ch;
|
||||
CDirEntry *res=NULL,*tempde,long_name;
|
||||
CDirEntry *res=NULL,*tmpde,long_name;
|
||||
if (fuf_flags&~FUG_FILES_FIND)
|
||||
throw('FUF');
|
||||
try {
|
||||
@@ -870,41 +870,41 @@ CDirEntry *FAT32FilesFind(U8 *files_find_mask,
|
||||
DirLongNameFill(&long_name,&buf[cur_dir_entry],&xsum);
|
||||
else {
|
||||
if (!(attr&RS_ATTR_VOL_ID)) {
|
||||
tempde=MAlloc(sizeof(CDirEntry));
|
||||
tmpde=MAlloc(sizeof(CDirEntry));
|
||||
if (xsum==FATNameXSum(buf[cur_dir_entry].name))
|
||||
MemCpy(tempde,&long_name,sizeof(CDirEntry));
|
||||
MemCpy(tmpde,&long_name,sizeof(CDirEntry));
|
||||
else
|
||||
MemSet(tempde,0,sizeof(CDirEntry));
|
||||
if (FAT32CDirFill(tempde,&buf[cur_dir_entry],
|
||||
MemSet(tmpde,0,sizeof(CDirEntry));
|
||||
if (FAT32CDirFill(tmpde,&buf[cur_dir_entry],
|
||||
dv->fat32_local_time_offset)) {
|
||||
tempde->parent=parent;
|
||||
tmpde->parent=parent;
|
||||
if (Bt(&fuf_flags,FUf_RECURSE) && attr&RS_ATTR_DIR &&
|
||||
*tempde->name!='.') {
|
||||
tempde->next=res;
|
||||
res=tempde;
|
||||
tempde->full_name=DirNameAbs(tempde->name);
|
||||
*tmpde->name!='.') {
|
||||
tmpde->next=res;
|
||||
res=tmpde;
|
||||
tmpde->full_name=DirNameAbs(tmpde->name);
|
||||
DrvUnlock(dv);
|
||||
if (Cd(tempde->name)) {
|
||||
tempde->sub=FAT32FilesFind(files_find_mask,fuf_flags,
|
||||
tempde,&sub_dir_size);
|
||||
tempde->size=sub_dir_size;
|
||||
if (Cd(tmpde->name)) {
|
||||
tmpde->sub=FAT32FilesFind(files_find_mask,fuf_flags,
|
||||
tmpde,&sub_dir_size);
|
||||
tmpde->size=sub_dir_size;
|
||||
Cd("..");
|
||||
}
|
||||
DrvLock(dv);
|
||||
} else {
|
||||
tempde->full_name=FileNameAbs(tempde->name);
|
||||
tmpde->full_name=FileNameAbs(tmpde->name);
|
||||
if ((attr&RS_ATTR_DIR || !Bt(&fuf_flags,FUf_JUST_DIRS)) &&
|
||||
!(Bt(&fuf_flags,FUf_RECURSE) &&
|
||||
*tempde->name=='.' && attr&RS_ATTR_DIR) &&
|
||||
FilesFindMatch(tempde->full_name,files_find_mask,
|
||||
*tmpde->name=='.' && attr&RS_ATTR_DIR) &&
|
||||
FilesFindMatch(tmpde->full_name,files_find_mask,
|
||||
fuf_flags)) {
|
||||
tempde->next=res;
|
||||
res=tempde;
|
||||
tmpde->next=res;
|
||||
res=tmpde;
|
||||
} else
|
||||
DirEntryDel(tempde);
|
||||
DirEntryDel(tmpde);
|
||||
}
|
||||
} else
|
||||
DirEntryDel(tempde);
|
||||
DirEntryDel(tmpde);
|
||||
}
|
||||
MemSet(&long_name,0,sizeof(CDirEntry));
|
||||
}
|
||||
|
||||
+27
-27
@@ -53,17 +53,17 @@ Bool ISO1FromName(U8 *dst,U8 *src)
|
||||
return FileNameChk(dst);
|
||||
}
|
||||
|
||||
Bool ISO1CDirFill(CDirEntry *tempde,CISO1DirEntry *de)
|
||||
Bool ISO1CDirFill(CDirEntry *tmpde,CISO1DirEntry *de)
|
||||
{
|
||||
Bool res;
|
||||
MemSet(tempde,0,sizeof(CDirEntry));
|
||||
res=ISO1FromName(tempde->name,&de->name_len);
|
||||
tempde->cluster=de->loc.little;
|
||||
tempde->size=de->size.little;
|
||||
tempde->attr=FileAttr(tempde->name);
|
||||
MemSet(tmpde,0,sizeof(CDirEntry));
|
||||
res=ISO1FromName(tmpde->name,&de->name_len);
|
||||
tmpde->cluster=de->loc.little;
|
||||
tmpde->size=de->size.little;
|
||||
tmpde->attr=FileAttr(tmpde->name);
|
||||
if (de->flags & ISO1_ATTR_DIR)
|
||||
tempde->attr|=RS_ATTR_DIR;
|
||||
tempde->datetime=ISO1DateStruct2CDate(&de->date);
|
||||
tmpde->attr|=RS_ATTR_DIR;
|
||||
tmpde->datetime=ISO1DateStruct2CDate(&de->date);
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ CDirEntry *ISO1FilesFind(U8 *files_find_mask,
|
||||
CDrv *dv=Fs->cur_dv;
|
||||
CISO1DirEntry *buf,*buf2,*isoptr;
|
||||
I64 i,cur_dir_cluster=Name2DirCluster(dv,Fs->cur_dir);
|
||||
CDirEntry *res=NULL,*tempde;
|
||||
CDirEntry *res=NULL,*tmpde;
|
||||
if (fuf_flags&~FUG_FILES_FIND)
|
||||
throw('FUF');
|
||||
isoptr=MAlloc(dv->spc<<BLK_SIZE_BITS);
|
||||
@@ -197,32 +197,32 @@ CDirEntry *ISO1FilesFind(U8 *files_find_mask,
|
||||
buf(U8 *)++;
|
||||
i--;
|
||||
} else {
|
||||
tempde=MAlloc(sizeof(CDirEntry));
|
||||
if (ISO1CDirFill(tempde,buf)) {
|
||||
tempde->parent=parent;
|
||||
if (Bt(&fuf_flags,FUf_RECURSE) && tempde->attr&RS_ATTR_DIR &&
|
||||
*tempde->name!='.') {
|
||||
tempde->next=res;
|
||||
res=tempde;
|
||||
tempde->full_name=DirNameAbs(tempde->name);
|
||||
if (Cd(tempde->name)) {
|
||||
tempde->sub=ISO1FilesFind(files_find_mask,fuf_flags,tempde);
|
||||
tmpde=MAlloc(sizeof(CDirEntry));
|
||||
if (ISO1CDirFill(tmpde,buf)) {
|
||||
tmpde->parent=parent;
|
||||
if (Bt(&fuf_flags,FUf_RECURSE) && tmpde->attr&RS_ATTR_DIR &&
|
||||
*tmpde->name!='.') {
|
||||
tmpde->next=res;
|
||||
res=tmpde;
|
||||
tmpde->full_name=DirNameAbs(tmpde->name);
|
||||
if (Cd(tmpde->name)) {
|
||||
tmpde->sub=ISO1FilesFind(files_find_mask,fuf_flags,tmpde);
|
||||
Cd("..");
|
||||
}
|
||||
} else {
|
||||
tempde->full_name=FileNameAbs(tempde->name);
|
||||
if ((tempde->attr & RS_ATTR_DIR ||
|
||||
tmpde->full_name=FileNameAbs(tmpde->name);
|
||||
if ((tmpde->attr & RS_ATTR_DIR ||
|
||||
!Bt(&fuf_flags,FUf_JUST_DIRS)) &&
|
||||
!(Bt(&fuf_flags,FUf_RECURSE) &&
|
||||
*tempde->name=='.' && tempde->attr&RS_ATTR_DIR) &&
|
||||
FilesFindMatch(tempde->full_name,files_find_mask,fuf_flags)) {
|
||||
tempde->next=res;
|
||||
res=tempde;
|
||||
*tmpde->name=='.' && tmpde->attr&RS_ATTR_DIR) &&
|
||||
FilesFindMatch(tmpde->full_name,files_find_mask,fuf_flags)) {
|
||||
tmpde->next=res;
|
||||
res=tmpde;
|
||||
} else
|
||||
DirEntryDel(tempde);
|
||||
DirEntryDel(tmpde);
|
||||
}
|
||||
} else
|
||||
DirEntryDel(tempde);
|
||||
DirEntryDel(tmpde);
|
||||
i-=buf->len;
|
||||
buf(U8 *)+=buf->len;
|
||||
}
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
|
||||
U0 RedSeaFreeFreeLst(CDrv *dv)
|
||||
{
|
||||
CFreeLst *tempf,*tempf1;
|
||||
CFreeLst *tmpf,*tmpf1;
|
||||
Bool unlock;
|
||||
try {
|
||||
unlock=DrvLock(dv);
|
||||
if (tempf=dv->next_free) {
|
||||
while (tempf!=&dv->next_free) {
|
||||
tempf1=tempf->next;
|
||||
Free(tempf);
|
||||
tempf=tempf1;
|
||||
if (tmpf=dv->next_free) {
|
||||
while (tmpf!=&dv->next_free) {
|
||||
tmpf1=tmpf->next;
|
||||
Free(tmpf);
|
||||
tmpf=tmpf1;
|
||||
}
|
||||
}
|
||||
dv->next_free=NULL;
|
||||
@@ -24,7 +24,7 @@ U0 RedSeaFreeFreeLst(CDrv *dv)
|
||||
U0 RedSeaFreeLstBuild(CDrv *dv)
|
||||
{
|
||||
Bool unlock;
|
||||
CFreeLst *tempf;
|
||||
CFreeLst *tmpf;
|
||||
I64 i,first=dv->data_area,max_blk=dv->size+dv->drv_offset;
|
||||
try {
|
||||
unlock=DrvLock(dv);
|
||||
@@ -41,10 +41,10 @@ U0 RedSeaFreeLstBuild(CDrv *dv)
|
||||
i++;
|
||||
}
|
||||
if (i) {
|
||||
tempf=AMAlloc(sizeof(CFreeLst));
|
||||
tempf->size=i;
|
||||
tempf->start=first;
|
||||
QueIns(tempf,dv->last_free);
|
||||
tmpf=AMAlloc(sizeof(CFreeLst));
|
||||
tmpf->size=i;
|
||||
tmpf->start=first;
|
||||
QueIns(tmpf,dv->last_free);
|
||||
}
|
||||
first+=i+1;
|
||||
}
|
||||
@@ -249,7 +249,7 @@ Bool RedSeaCd(U8 *name,I64 cur_dir_cluster)
|
||||
|
||||
U0 RedSeaFreeClusters(CDrv *dv,I64 c,I64 cnt)
|
||||
{
|
||||
CFreeLst *tempf;
|
||||
CFreeLst *tmpf;
|
||||
Bool found=FALSE,unlock,unlock_break;
|
||||
DrvChk(dv);
|
||||
if (!c) return;
|
||||
@@ -261,23 +261,23 @@ U0 RedSeaFreeClusters(CDrv *dv,I64 c,I64 cnt)
|
||||
unlock=DrvLock(dv);
|
||||
if (!dv->next_free)
|
||||
RedSeaFreeLstBuild(dv);
|
||||
tempf=dv->next_free;
|
||||
while (!found && tempf!=&dv->next_free) {
|
||||
if (tempf->start+tempf->size==c) {
|
||||
tempf->size+=cnt;
|
||||
tmpf=dv->next_free;
|
||||
while (!found && tmpf!=&dv->next_free) {
|
||||
if (tmpf->start+tmpf->size==c) {
|
||||
tmpf->size+=cnt;
|
||||
found=TRUE;
|
||||
} else if (c+cnt==tempf->start) {
|
||||
tempf->size+=cnt;
|
||||
tempf->start=c;
|
||||
} else if (c+cnt==tmpf->start) {
|
||||
tmpf->size+=cnt;
|
||||
tmpf->start=c;
|
||||
found=TRUE;
|
||||
}
|
||||
tempf=tempf->next;
|
||||
tmpf=tmpf->next;
|
||||
}
|
||||
if (!found) {
|
||||
tempf=AMAlloc(sizeof(CFreeLst));
|
||||
tempf->size=cnt;
|
||||
tempf->start=c;
|
||||
QueIns(tempf,dv->last_free);
|
||||
tmpf=AMAlloc(sizeof(CFreeLst));
|
||||
tmpf->size=cnt;
|
||||
tmpf->start=c;
|
||||
QueIns(tmpf,dv->last_free);
|
||||
}
|
||||
while (cnt-->0) {
|
||||
DrvFATBlkSet(dv,c);
|
||||
@@ -301,7 +301,7 @@ U0 RedSeaFreeClusters(CDrv *dv,I64 c,I64 cnt)
|
||||
|
||||
I64 RedSeaAllocClusters(CDrv *dv,I64 cnt)
|
||||
{
|
||||
CFreeLst *tempf,*best_free=NULL;
|
||||
CFreeLst *tmpf,*best_free=NULL;
|
||||
I64 i,first,best_size=MAX_I64;
|
||||
Bool unlock,unlock_break;
|
||||
if (cnt<=0)
|
||||
@@ -311,15 +311,15 @@ I64 RedSeaAllocClusters(CDrv *dv,I64 cnt)
|
||||
unlock=DrvLock(dv);
|
||||
if (!dv->next_free)
|
||||
RedSeaFreeLstBuild(dv);
|
||||
tempf=dv->next_free;
|
||||
while (tempf!=&dv->next_free) {
|
||||
if (tempf->size>=cnt && tempf->size<best_size) {
|
||||
best_free=tempf;
|
||||
best_size=tempf->size;
|
||||
if (tempf->size==cnt)
|
||||
tmpf=dv->next_free;
|
||||
while (tmpf!=&dv->next_free) {
|
||||
if (tmpf->size>=cnt && tmpf->size<best_size) {
|
||||
best_free=tmpf;
|
||||
best_size=tmpf->size;
|
||||
if (tmpf->size==cnt)
|
||||
break;
|
||||
}
|
||||
tempf=tempf->next;
|
||||
tmpf=tmpf->next;
|
||||
}
|
||||
if (!best_free)
|
||||
throw('Drv');
|
||||
@@ -349,16 +349,16 @@ I64 RedSeaAllocClusters(CDrv *dv,I64 cnt)
|
||||
return first;
|
||||
}
|
||||
|
||||
Bool RedSeaDirNew(CDrv *dv,U8 *cur_dir,CDirEntry *tempde,Bool free_old_chain)
|
||||
Bool RedSeaDirNew(CDrv *dv,U8 *cur_dir,CDirEntry *tmpde,Bool free_old_chain)
|
||||
{
|
||||
CDirEntry *buf,*buf2,*ptr,de2;
|
||||
CRedSeaBoot *br;
|
||||
I64 c,ch,i=1,j=0,n=BLK_SIZE/CDIR_SIZE,dir_size,cur_dir_cluster;
|
||||
Bool written=FALSE,unlock,unlock_break;
|
||||
U8 *temp,*parent_dir;
|
||||
U8 *tmp,*parent_dir;
|
||||
try {
|
||||
unlock_break=BreakLock;
|
||||
tempde->attr|=RS_ATTR_CONTIGUOUS;
|
||||
tmpde->attr|=RS_ATTR_CONTIGUOUS;
|
||||
unlock=DrvLock(dv);
|
||||
cur_dir_cluster=Name2DirCluster(dv,cur_dir);
|
||||
buf2=MAlloc(BLK_SIZE);
|
||||
@@ -374,7 +374,7 @@ Bool RedSeaDirNew(CDrv *dv,U8 *cur_dir,CDirEntry *tempde,Bool free_old_chain)
|
||||
while (TRUE) {
|
||||
if (!(ch=*ptr->name)) {
|
||||
if (!written)
|
||||
MemCpy(&ptr->start,&tempde->start,CDIR_SIZE);
|
||||
MemCpy(&ptr->start,&tmpde->start,CDIR_SIZE);
|
||||
if ((i+1)*CDIR_SIZE+j<<BLK_SIZE_BITS<dir_size)
|
||||
WBlks(dv,buf(U8 *)+j<<BLK_SIZE_BITS,cur_dir_cluster+j,1);
|
||||
else {
|
||||
@@ -397,38 +397,38 @@ Bool RedSeaDirNew(CDrv *dv,U8 *cur_dir,CDirEntry *tempde,Bool free_old_chain)
|
||||
Free(br);
|
||||
dv->root_cluster=c;
|
||||
} else {
|
||||
temp=StrNew(cur_dir);
|
||||
tmp=StrNew(cur_dir);
|
||||
parent_dir=StrNew(cur_dir);
|
||||
StrLastRem(parent_dir,"/",temp);
|
||||
StrLastRem(parent_dir,"/",tmp);
|
||||
if (!*parent_dir) {
|
||||
Free(parent_dir);
|
||||
parent_dir=StrNew("/");
|
||||
}
|
||||
if (RedSeaFileFind(dv,Name2DirCluster(dv,parent_dir),
|
||||
temp,&de2,FUF_JUST_DIRS)) {
|
||||
tmp,&de2,FUF_JUST_DIRS)) {
|
||||
de2.cluster=c;
|
||||
de2.size=dir_size;
|
||||
RedSeaDirNew(dv,parent_dir,&de2,FALSE);
|
||||
} else
|
||||
throw('Drv');
|
||||
Free(temp);
|
||||
Free(tmp);
|
||||
Free(parent_dir);
|
||||
}
|
||||
}
|
||||
break;
|
||||
} else if (ptr->attr & RS_ATTR_DELETED) {
|
||||
if (!written) {
|
||||
MemCpy(&ptr->start,&tempde->start,CDIR_SIZE);
|
||||
MemCpy(&ptr->start,&tmpde->start,CDIR_SIZE);
|
||||
WBlks(dv,buf(U8 *)+j<<BLK_SIZE_BITS,cur_dir_cluster+j,1);
|
||||
written=TRUE;
|
||||
}
|
||||
} else {
|
||||
if (!StrCmp(tempde->name,ptr->name)) {
|
||||
if (!StrCmp(tmpde->name,ptr->name)) {
|
||||
if (free_old_chain)
|
||||
RedSeaFreeClusters(dv,ptr->cluster,
|
||||
(ptr->size+BLK_SIZE-1)>>BLK_SIZE_BITS);
|
||||
if (!written)
|
||||
MemCpy(&ptr->start,&tempde->start,CDIR_SIZE);
|
||||
MemCpy(&ptr->start,&tmpde->start,CDIR_SIZE);
|
||||
else
|
||||
ptr->attr|=RS_ATTR_DELETED;
|
||||
WBlks(dv,buf(U8 *)+j<<BLK_SIZE_BITS,cur_dir_cluster+j,1);
|
||||
@@ -540,7 +540,7 @@ CDirEntry *RedSeaFilesFind(U8 *files_find_mask,I64 fuf_flags,
|
||||
CDirEntry *parent=NULL)
|
||||
{
|
||||
CDrv *dv=Fs->cur_dv;
|
||||
CDirEntry *buf,*buf2,*ptr,*res=NULL,*tempde;
|
||||
CDirEntry *buf,*buf2,*ptr,*res=NULL,*tmpde;
|
||||
I64 ch,cur_dir_cluster;
|
||||
if (fuf_flags&~FUG_FILES_FIND)
|
||||
throw('FUF');
|
||||
@@ -565,31 +565,31 @@ CDirEntry *RedSeaFilesFind(U8 *files_find_mask,I64 fuf_flags,
|
||||
if (!(ch=*ptr->name))
|
||||
break;
|
||||
else if (!(ptr->attr & RS_ATTR_DELETED)) {
|
||||
tempde=CAlloc(sizeof(CDirEntry));
|
||||
MemCpy(&tempde->start,&ptr->start,CDIR_SIZE);
|
||||
tempde->parent=parent;
|
||||
if (Bt(&fuf_flags,FUf_RECURSE) && tempde->attr&RS_ATTR_DIR &&
|
||||
*tempde->name!='.') {
|
||||
tempde->next=res;
|
||||
res=tempde;
|
||||
tempde->full_name=DirNameAbs(tempde->name);
|
||||
tmpde=CAlloc(sizeof(CDirEntry));
|
||||
MemCpy(&tmpde->start,&ptr->start,CDIR_SIZE);
|
||||
tmpde->parent=parent;
|
||||
if (Bt(&fuf_flags,FUf_RECURSE) && tmpde->attr&RS_ATTR_DIR &&
|
||||
*tmpde->name!='.') {
|
||||
tmpde->next=res;
|
||||
res=tmpde;
|
||||
tmpde->full_name=DirNameAbs(tmpde->name);
|
||||
DrvUnlock(dv);
|
||||
if (Cd(tempde->name)) {
|
||||
tempde->sub=RedSeaFilesFind(files_find_mask,fuf_flags,tempde);
|
||||
if (Cd(tmpde->name)) {
|
||||
tmpde->sub=RedSeaFilesFind(files_find_mask,fuf_flags,tmpde);
|
||||
Cd("..");
|
||||
}
|
||||
DrvLock(dv);
|
||||
} else {
|
||||
tempde->full_name=FileNameAbs(tempde->name);
|
||||
if ((tempde->attr&RS_ATTR_DIR ||
|
||||
tmpde->full_name=FileNameAbs(tmpde->name);
|
||||
if ((tmpde->attr&RS_ATTR_DIR ||
|
||||
!Bt(&fuf_flags,FUf_JUST_DIRS)) &&
|
||||
!(Bt(&fuf_flags,FUf_RECURSE) && *tempde->name=='.' &&
|
||||
tempde->attr&RS_ATTR_DIR) &&
|
||||
FilesFindMatch(tempde->full_name,files_find_mask,fuf_flags)) {
|
||||
tempde->next=res;
|
||||
res=tempde;
|
||||
!(Bt(&fuf_flags,FUf_RECURSE) && *tmpde->name=='.' &&
|
||||
tmpde->attr&RS_ATTR_DIR) &&
|
||||
FilesFindMatch(tmpde->full_name,files_find_mask,fuf_flags)) {
|
||||
tmpde->next=res;
|
||||
res=tmpde;
|
||||
} else
|
||||
DirEntryDel(tempde);
|
||||
DirEntryDel(tmpde);
|
||||
}
|
||||
}
|
||||
ptr(U8 *)+=CDIR_SIZE;
|
||||
|
||||
+26
-26
@@ -6,7 +6,7 @@ asm {
|
||||
U0 ArcEntryGet(CArcCtrl *c)
|
||||
{
|
||||
I64 i;
|
||||
CArcEntry *temp,*temp1;
|
||||
CArcEntry *tmp,*tmp1;
|
||||
|
||||
if (c->entry_used) {
|
||||
i=c->free_idx;
|
||||
@@ -24,15 +24,15 @@ U0 ArcEntryGet(CArcCtrl *c)
|
||||
do if (++i==c->free_limit)
|
||||
i=c->min_table_entry;
|
||||
while (c->hash[i]);
|
||||
temp=&c->compress[i];
|
||||
c->next_entry=temp;
|
||||
temp1=&c->hash[temp->basecode];
|
||||
while (temp1) {
|
||||
if (temp1->next==temp) {
|
||||
temp1->next=temp->next;
|
||||
tmp=&c->compress[i];
|
||||
c->next_entry=tmp;
|
||||
tmp1=&c->hash[tmp->basecode];
|
||||
while (tmp1) {
|
||||
if (tmp1->next==tmp) {
|
||||
tmp1->next=tmp->next;
|
||||
break;
|
||||
} else
|
||||
temp1=temp1->next;
|
||||
tmp1=tmp1->next;
|
||||
}
|
||||
}
|
||||
c->free_idx=i;
|
||||
@@ -109,7 +109,7 @@ I64 ArcDetermineCompressionType(U8 *src,I64 size)
|
||||
|
||||
U0 ArcCompressBuf(CArcCtrl *c)
|
||||
{//Use $LK,"CompressBuf",A="MN:CompressBuf"$() unless doing more than one buf.
|
||||
CArcEntry *temp,*temp1;
|
||||
CArcEntry *tmp,*tmp1;
|
||||
I64 ch,basecode;
|
||||
U8 *src_ptr,*src_limit;
|
||||
|
||||
@@ -126,24 +126,24 @@ U0 ArcCompressBuf(CArcCtrl *c)
|
||||
ac_start:
|
||||
if (src_ptr>=src_limit) goto ac_done;
|
||||
ch=*src_ptr++;
|
||||
if (temp=c->hash[basecode])
|
||||
if (tmp=c->hash[basecode])
|
||||
do {
|
||||
if (temp->ch==ch) {
|
||||
basecode=temp-&c->compress[0];
|
||||
if (tmp->ch==ch) {
|
||||
basecode=tmp-&c->compress[0];
|
||||
goto ac_start;
|
||||
}
|
||||
} while (temp=temp->next);
|
||||
} while (tmp=tmp->next);
|
||||
|
||||
BFieldOrU32(c->dst_buf,c->dst_pos,basecode);
|
||||
c->dst_pos+=c->cur_bits_in_use;
|
||||
|
||||
c->entry_used=TRUE;
|
||||
temp=c->cur_entry;
|
||||
temp->basecode=basecode;
|
||||
temp->ch=ch;
|
||||
temp1=&c->hash[basecode];
|
||||
temp->next=temp1->next;
|
||||
temp1->next=temp;
|
||||
tmp=c->cur_entry;
|
||||
tmp->basecode=basecode;
|
||||
tmp->ch=ch;
|
||||
tmp1=&c->hash[basecode];
|
||||
tmp->next=tmp1->next;
|
||||
tmp1->next=tmp;
|
||||
|
||||
basecode=ch;
|
||||
}
|
||||
@@ -166,7 +166,7 @@ U0 ArcExpandBuf(CArcCtrl *c)
|
||||
{//Use $LK,"ExpandBuf",A="MN:ExpandBuf"$() unless you know what you're doing.
|
||||
U8 *dst_ptr,*dst_limit;
|
||||
I64 basecode,lastcode,code;
|
||||
CArcEntry *temp,*temp1;
|
||||
CArcEntry *tmp,*tmp1;
|
||||
|
||||
dst_ptr=c->dst_buf+c->dst_pos;
|
||||
dst_limit=c->dst_buf+c->dst_size;
|
||||
@@ -201,12 +201,12 @@ U0 ArcExpandBuf(CArcCtrl *c)
|
||||
c->last_ch=code;
|
||||
|
||||
c->entry_used=TRUE;
|
||||
temp=c->cur_entry;
|
||||
temp->basecode=lastcode;
|
||||
temp->ch=c->last_ch;
|
||||
temp1=&c->hash[lastcode];
|
||||
temp->next=temp1->next;
|
||||
temp1->next=temp;
|
||||
tmp=c->cur_entry;
|
||||
tmp->basecode=lastcode;
|
||||
tmp->ch=c->last_ch;
|
||||
tmp1=&c->hash[lastcode];
|
||||
tmp->next=tmp1->next;
|
||||
tmp1->next=tmp;
|
||||
|
||||
ArcEntryGet(c);
|
||||
while (dst_ptr<dst_limit && c->stk_ptr!=c->stk_base)
|
||||
|
||||
+8
-8
@@ -2,9 +2,9 @@ U0 RawPutChar(I64 ch)
|
||||
{/*For RAW output during boot and in debugger.
|
||||
|
||||
See $LK,"GrUpdateTextFG",A="MN:GrUpdateTextFG"$ for
|
||||
the normal screen text output routine.
|
||||
the normal scrn text output routine.
|
||||
|
||||
See also $LK,"GrUpdateScreen",A="MN:GrUpdateScreen"$().
|
||||
See also $LK,"GrUpdateScrn",A="MN:GrUpdateScrn"$().
|
||||
*/
|
||||
I64 i,row,col;
|
||||
U8 *ptr,*ptr1,*ptr2;
|
||||
@@ -58,13 +58,13 @@ See also $LK,"GrUpdateScreen",A="MN:GrUpdateScreen"$().
|
||||
OutU8(VGAP_DATA,0x0F); //All planes -- WHITE
|
||||
if (text.raw_flags&RWF_SCROLL && text.raw_col && !row && !col) {
|
||||
//Scroll cached image
|
||||
MemCpy(text.raw_screen_image,
|
||||
text.raw_screen_image+GR_WIDTH*FONT_HEIGHT>>3,
|
||||
MemCpy(text.raw_scrn_image,
|
||||
text.raw_scrn_image+GR_WIDTH*FONT_HEIGHT>>3,
|
||||
GR_WIDTH*(GR_HEIGHT-FONT_HEIGHT)>>3);
|
||||
MemSet(text.raw_screen_image+GR_WIDTH*(GR_HEIGHT-FONT_HEIGHT)>>3,0,
|
||||
MemSet(text.raw_scrn_image+GR_WIDTH*(GR_HEIGHT-FONT_HEIGHT)>>3,0,
|
||||
GR_WIDTH*FONT_HEIGHT>>3);
|
||||
|
||||
MemCpy(text.vga_alias,text.raw_screen_image,GR_WIDTH*GR_HEIGHT>>3);
|
||||
MemCpy(text.vga_alias,text.raw_scrn_image,GR_WIDTH*GR_HEIGHT>>3);
|
||||
text.raw_col-=text.cols;
|
||||
row=text.rows-1;
|
||||
}
|
||||
@@ -72,7 +72,7 @@ See also $LK,"GrUpdateScreen",A="MN:GrUpdateScreen"$().
|
||||
CLI
|
||||
ptr=ptr1=col+row*GR_WIDTH*FONT_HEIGHT>>3;
|
||||
ptr+=text.vga_alias;
|
||||
ptr1+=text.raw_screen_image; //Write to cached image as well
|
||||
ptr1+=text.raw_scrn_image; //Write to cached image as well
|
||||
ptr2=&text.font[ch&255];
|
||||
for (i=0;i<FONT_HEIGHT;i++) {
|
||||
*ptr=*ptr1=rev_bits_table[*ptr2++];
|
||||
@@ -86,7 +86,7 @@ See also $LK,"GrUpdateScreen",A="MN:GrUpdateScreen"$().
|
||||
}
|
||||
|
||||
U0 VGAFlush()
|
||||
{//Flush winmgr vga cache, so updates whole screen.
|
||||
{//Flush winmgr vga cache, so updates whole scrn.
|
||||
LBts(&sys_semas[SYS_SEMA_FLUSH_VGA_IMAGE],0);
|
||||
}
|
||||
|
||||
|
||||
+58
-58
@@ -8,25 +8,25 @@ U0 EdLiteUpdate(CLine *head,CLine *cur_line,I64 cur_col,I64 line_start_col)
|
||||
{
|
||||
I64 ch,i,j,k,k2,cursor_col,cursor_row=-1;
|
||||
U8 *st;
|
||||
CLine *templ=cur_line;
|
||||
CLine *tmpl=cur_line;
|
||||
Bool done_eof=FALSE;
|
||||
text.raw_col=0;
|
||||
for (i=0;i<text.rows/2;i++)
|
||||
if (templ->last!=head)
|
||||
templ=templ->last;
|
||||
if (tmpl->last!=head)
|
||||
tmpl=tmpl->last;
|
||||
for (i=0;i<text.rows;i++) {
|
||||
if (cursor_row<0 && templ==cur_line) {
|
||||
if (cursor_row<0 && tmpl==cur_line) {
|
||||
k=0;
|
||||
for (j=0;j<cur_col;j++)
|
||||
if (templ->line[j]=='\t')
|
||||
if (tmpl->line[j]=='\t')
|
||||
k=(k+8)&~7;
|
||||
else
|
||||
k++;
|
||||
cursor_col=k;
|
||||
cursor_row=i;
|
||||
}
|
||||
if (templ!=head) {
|
||||
st=templ->line;
|
||||
if (tmpl!=head) {
|
||||
st=tmpl->line;
|
||||
k=0;
|
||||
j=0;
|
||||
while (ch=*st++) {
|
||||
@@ -42,7 +42,7 @@ U0 EdLiteUpdate(CLine *head,CLine *cur_line,I64 cur_col,I64 line_start_col)
|
||||
}
|
||||
if (j<text.cols)
|
||||
'\n';
|
||||
templ=templ->next;
|
||||
tmpl=tmpl->next;
|
||||
} else {
|
||||
if (!done_eof) {
|
||||
'<EOF>';
|
||||
@@ -60,13 +60,13 @@ Bool EdLite(U8 *filename,I64 num=1,I64 edf_dof_flags=0)
|
||||
U8 *src,*src2,*src3,*dst,*buf,*bin_data=NULL;
|
||||
I64 i,cnt=0,ch,sc,size,bin_size=0,line_start_col=0,cur_col=0,
|
||||
old_raw_flags=text.raw_flags;
|
||||
CLine head,*templ,*templ1,*cur_line;
|
||||
CLine head,*tmpl,*tmpl1,*cur_line;
|
||||
Bool res=FALSE,
|
||||
old_raw=Raw(ON),
|
||||
old_debug=InDbg(ON),
|
||||
old_debug=DbgMode(ON),
|
||||
old_single=SingleUser(ON);
|
||||
|
||||
if (!filename) filename=blkdev.temp_filename;
|
||||
if (!filename) filename=blkdev.tmp_filename;
|
||||
buf=FileRead(filename,&size);
|
||||
|
||||
PUSHFD
|
||||
@@ -93,9 +93,9 @@ Bool EdLite(U8 *filename,I64 num=1,I64 edf_dof_flags=0)
|
||||
*dst++=ch;
|
||||
*dst=0;
|
||||
|
||||
templ=MAlloc(sizeof(CLine));
|
||||
templ->line=StrNew(src2);
|
||||
QueIns(templ,head.last);
|
||||
tmpl=MAlloc(sizeof(CLine));
|
||||
tmpl->line=StrNew(src2);
|
||||
QueIns(tmpl,head.last);
|
||||
cnt++;
|
||||
}
|
||||
|
||||
@@ -145,10 +145,10 @@ Bool EdLite(U8 *filename,I64 num=1,I64 edf_dof_flags=0)
|
||||
case SC_CURSOR_RIGHT:
|
||||
cur_col++;
|
||||
if (cur_col>StrLen(cur_line->line)) {
|
||||
templ=cur_line->next;
|
||||
if (templ!=&head) {
|
||||
tmpl=cur_line->next;
|
||||
if (tmpl!=&head) {
|
||||
cur_col=0;
|
||||
cur_line=templ;
|
||||
cur_line=tmpl;
|
||||
} else
|
||||
cur_col=StrLen(cur_line->line);
|
||||
}
|
||||
@@ -157,10 +157,10 @@ Bool EdLite(U8 *filename,I64 num=1,I64 edf_dof_flags=0)
|
||||
if (cur_col)
|
||||
cur_col--;
|
||||
else {
|
||||
templ=cur_line->last;
|
||||
if (templ!=&head) {
|
||||
cur_line=templ;
|
||||
cur_col=StrLen(templ->line);
|
||||
tmpl=cur_line->last;
|
||||
if (tmpl!=&head) {
|
||||
cur_line=tmpl;
|
||||
cur_col=StrLen(tmpl->line);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -182,14 +182,14 @@ Bool EdLite(U8 *filename,I64 num=1,I64 edf_dof_flags=0)
|
||||
break;
|
||||
case SC_DELETE:
|
||||
if (cur_col==StrLen(cur_line->line)) {
|
||||
templ=cur_line->next;
|
||||
if (cur_line!=&head && templ!=&head) {
|
||||
src=MStrPrint("%s%s",cur_line->line,templ->line);
|
||||
tmpl=cur_line->next;
|
||||
if (cur_line!=&head && tmpl!=&head) {
|
||||
src=MStrPrint("%s%s",cur_line->line,tmpl->line);
|
||||
Free(cur_line->line);
|
||||
Free(templ->line);
|
||||
Free(tmpl->line);
|
||||
cur_line->line=src;
|
||||
QueRem(templ);
|
||||
Free(templ);
|
||||
QueRem(tmpl);
|
||||
Free(tmpl);
|
||||
}
|
||||
} else
|
||||
StrCpy(cur_line->line+cur_col,cur_line->line+cur_col+1);
|
||||
@@ -198,11 +198,11 @@ Bool EdLite(U8 *filename,I64 num=1,I64 edf_dof_flags=0)
|
||||
break;
|
||||
case '\n':
|
||||
case '\r':
|
||||
templ=MAlloc(sizeof(CLine));
|
||||
templ->line=StrNew(cur_line->line+cur_col);
|
||||
tmpl=MAlloc(sizeof(CLine));
|
||||
tmpl->line=StrNew(cur_line->line+cur_col);
|
||||
cur_line->line[cur_col]=0;
|
||||
QueIns(templ,cur_line);
|
||||
cur_line=templ;
|
||||
QueIns(tmpl,cur_line);
|
||||
cur_line=tmpl;
|
||||
cur_col=0;
|
||||
break;
|
||||
case CH_BACKSPACE:
|
||||
@@ -210,24 +210,24 @@ Bool EdLite(U8 *filename,I64 num=1,I64 edf_dof_flags=0)
|
||||
StrCpy(cur_line->line+cur_col-1,cur_line->line+cur_col);
|
||||
cur_col--;
|
||||
} else if (cur_line!=&head && cur_line->last!=&head) {
|
||||
templ=cur_line->last;
|
||||
src=MStrPrint("%s%s",templ->line,cur_line->line);
|
||||
cur_col=StrLen(templ->line);
|
||||
tmpl=cur_line->last;
|
||||
src=MStrPrint("%s%s",tmpl->line,cur_line->line);
|
||||
cur_col=StrLen(tmpl->line);
|
||||
Free(cur_line->line);
|
||||
Free(templ->line);
|
||||
templ->line=src;
|
||||
Free(tmpl->line);
|
||||
tmpl->line=src;
|
||||
QueRem(cur_line);
|
||||
Free(cur_line);
|
||||
cur_line=templ;
|
||||
cur_line=tmpl;
|
||||
}
|
||||
break;
|
||||
case CH_CTRLY:
|
||||
if (cur_line!=&head) {
|
||||
templ=cur_line;
|
||||
tmpl=cur_line;
|
||||
cur_line=cur_line->next;
|
||||
QueRem(templ);
|
||||
Free(templ->line);
|
||||
Free(templ);
|
||||
QueRem(tmpl);
|
||||
Free(tmpl->line);
|
||||
Free(tmpl);
|
||||
cur_col=0;
|
||||
}
|
||||
break;
|
||||
@@ -258,20 +258,20 @@ Bool EdLite(U8 *filename,I64 num=1,I64 edf_dof_flags=0)
|
||||
} else {
|
||||
size=bin_size;
|
||||
|
||||
templ=head.next;
|
||||
while (templ!=&head) {
|
||||
size+=StrLen(templ->line)+1;
|
||||
templ=templ->next;
|
||||
tmpl=head.next;
|
||||
while (tmpl!=&head) {
|
||||
size+=StrLen(tmpl->line)+1;
|
||||
tmpl=tmpl->next;
|
||||
}
|
||||
|
||||
buf=dst=MAlloc(size);
|
||||
templ=head.next;
|
||||
while (templ!=&head) {
|
||||
i=StrLen(templ->line);
|
||||
MemCpy(dst,templ->line,i);
|
||||
tmpl=head.next;
|
||||
while (tmpl!=&head) {
|
||||
i=StrLen(tmpl->line);
|
||||
MemCpy(dst,tmpl->line,i);
|
||||
dst+=i;
|
||||
*dst++='\n';
|
||||
templ=templ->next;
|
||||
tmpl=tmpl->next;
|
||||
}
|
||||
if (bin_data)
|
||||
MemCpy(dst,bin_data,bin_size);
|
||||
@@ -282,18 +282,18 @@ Bool EdLite(U8 *filename,I64 num=1,I64 edf_dof_flags=0)
|
||||
res=TRUE;
|
||||
}
|
||||
|
||||
templ=head.next;
|
||||
while (templ!=&head) {
|
||||
templ1=templ->next;
|
||||
QueRem(templ);
|
||||
Free(templ->line);
|
||||
Free(templ);
|
||||
templ=templ1;
|
||||
tmpl=head.next;
|
||||
while (tmpl!=&head) {
|
||||
tmpl1=tmpl->next;
|
||||
QueRem(tmpl);
|
||||
Free(tmpl->line);
|
||||
Free(tmpl);
|
||||
tmpl=tmpl1;
|
||||
}
|
||||
Free(head.line);
|
||||
Free(bin_data);
|
||||
Raw(old_raw);
|
||||
InDbg(old_debug);
|
||||
DbgMode(old_debug);
|
||||
SingleUser(old_single);
|
||||
text.raw_flags=text.raw_flags&~RWF_SHOW_DOLLAR|old_raw_flags&RWF_SHOW_DOLLAR;
|
||||
POPFD
|
||||
|
||||
+63
-63
@@ -11,39 +11,39 @@ U0 HashFunSegFind(CHashTable *h,U8 *addr,
|
||||
Bool *_has_lower,U64 *_best,CHash **_res)
|
||||
{
|
||||
Bool *has_lower=*_has_lower;
|
||||
CHashExport *tempex;
|
||||
CHashExport *tmpex;
|
||||
U64 i,j,best=*_best;
|
||||
CHash *res=*_res;
|
||||
for (i=0;i<=h->mask;i++) {
|
||||
tempex=h->body[i];
|
||||
while (tempex) {
|
||||
tmpex=h->body[i];
|
||||
while (tmpex) {
|
||||
j=0;
|
||||
if (tempex->type&HTT_FUN) {
|
||||
if (!Bt(&tempex(CHashFun *)->flags,Cf_EXTERN) &&
|
||||
!Bt(&tempex(CHashFun *)->flags,Ff_INTERNAL))
|
||||
j=tempex(CHashFun *)->exe_addr;
|
||||
} else if (tempex->type&HTT_EXPORT_SYS_SYM)
|
||||
j=tempex->val;
|
||||
if (tmpex->type&HTT_FUN) {
|
||||
if (!Bt(&tmpex(CHashFun *)->flags,Cf_EXTERN) &&
|
||||
!Bt(&tmpex(CHashFun *)->flags,Ff_INTERNAL))
|
||||
j=tmpex(CHashFun *)->exe_addr;
|
||||
} else if (tmpex->type&HTT_EXPORT_SYS_SYM)
|
||||
j=tmpex->val;
|
||||
if (j) {
|
||||
j=addr(I64)-j;
|
||||
if (0<=j<=best) {
|
||||
if (tempex->type&HTT_EXPORT_SYS_SYM) {
|
||||
if (tmpex->type&HTT_EXPORT_SYS_SYM) {
|
||||
if (j<best || j==best && !has_lower) {
|
||||
has_lower=HasLower(tempex->str);
|
||||
has_lower=HasLower(tmpex->str);
|
||||
best=j;
|
||||
res=tempex;
|
||||
res=tmpex;
|
||||
}
|
||||
} else if (tempex->type&HTT_FUN) {
|
||||
} else if (tmpex->type&HTT_FUN) {
|
||||
if (j<best || j==best &&
|
||||
(res && res->type&HTT_EXPORT_SYS_SYM||!has_lower)) {
|
||||
has_lower=HasLower(tempex->str);
|
||||
has_lower=HasLower(tmpex->str);
|
||||
best=j;
|
||||
res=tempex;
|
||||
res=tmpex;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
tempex=tempex->next;
|
||||
tmpex=tmpex->next;
|
||||
}
|
||||
}
|
||||
*_has_lower=has_lower;
|
||||
@@ -63,7 +63,7 @@ CHash *FunSegFind(U8 *addr,I64 *_offset)
|
||||
*_offset=best;
|
||||
return NULL;
|
||||
}
|
||||
if (IsDbg)
|
||||
if (IsDbgMode)
|
||||
for (i=0;i<mp_cnt;i++) {
|
||||
c=&cpu_structs[i];
|
||||
task=c->seth_task;
|
||||
@@ -89,25 +89,25 @@ fs_abort_task:
|
||||
return res;
|
||||
}
|
||||
|
||||
U0 FunSegCacheAdd(CHash *temps,U8 *addr)
|
||||
U0 FunSegCacheAdd(CHash *tmps,U8 *addr)
|
||||
{
|
||||
I64 i;
|
||||
CDbgInfo *dbg_info;
|
||||
CFunSegCache *tempfsc;
|
||||
if (temps && temps->type&HTT_FUN &&
|
||||
(dbg_info=temps(CHashFun *)->dbg_info)) {
|
||||
CFunSegCache *tmpfsc;
|
||||
if (tmps && tmps->type&HTT_FUN &&
|
||||
(dbg_info=tmps(CHashFun *)->dbg_info)) {
|
||||
lock i=dbg.fun_seg_cache_index++;
|
||||
tempfsc=&dbg.fun_seg_cache[i&(FUN_SEG_CACHE_SIZE-1)];
|
||||
tempfsc->base=dbg_info->body[0];
|
||||
if (addr<tempfsc->base)
|
||||
tempfsc->base=addr;
|
||||
tempfsc->limit=dbg_info->body[dbg_info->max_line+1-dbg_info->min_line];
|
||||
if (addr>=tempfsc->limit)
|
||||
tempfsc->limit=addr+1;
|
||||
i=MinI64(StrLen(temps->str),FUN_SEG_CACHE_STR_LEN-1);
|
||||
MemCpy(tempfsc->str,temps->str,i);
|
||||
tempfsc->str[i]=0;
|
||||
tempfsc->time_stamp=tS;
|
||||
tmpfsc=&dbg.fun_seg_cache[i&(FUN_SEG_CACHE_SIZE-1)];
|
||||
tmpfsc->base=dbg_info->body[0];
|
||||
if (addr<tmpfsc->base)
|
||||
tmpfsc->base=addr;
|
||||
tmpfsc->limit=dbg_info->body[dbg_info->max_line+1-dbg_info->min_line];
|
||||
if (addr>=tmpfsc->limit)
|
||||
tmpfsc->limit=addr+1;
|
||||
i=MinI64(StrLen(tmps->str),FUN_SEG_CACHE_STR_LEN-1);
|
||||
MemCpy(tmpfsc->str,tmps->str,i);
|
||||
tmpfsc->str[i]=0;
|
||||
tmpfsc->time_stamp=tS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,17 +115,17 @@ U8 *FunSegCacheFind(U8 *addr,I64 *_offset)
|
||||
{
|
||||
I64 i;
|
||||
F64 timeout;
|
||||
CFunSegCache *tempfsc=dbg.fun_seg_cache;
|
||||
CFunSegCache *tmpfsc=dbg.fun_seg_cache;
|
||||
if (addr==SYS_IDLE_PT) {
|
||||
*_offset=0;
|
||||
return "SYS_IDLE_PT";
|
||||
} else {
|
||||
timeout=tS+8.0;
|
||||
for (i=0;i<FUN_SEG_CACHE_SIZE;i++,tempfsc++)
|
||||
if (tempfsc->base<=addr<tempfsc->limit &&
|
||||
tempfsc->time_stamp>timeout) {
|
||||
*_offset=addr-tempfsc->base;
|
||||
return tempfsc->str;
|
||||
for (i=0;i<FUN_SEG_CACHE_SIZE;i++,tmpfsc++)
|
||||
if (tmpfsc->base<=addr<tmpfsc->limit &&
|
||||
tmpfsc->time_stamp>timeout) {
|
||||
*_offset=addr-tmpfsc->base;
|
||||
return tmpfsc->str;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -134,21 +134,21 @@ U8 *FunSegCacheFind(U8 *addr,I64 *_offset)
|
||||
U0 StrPrintFunSeg(U8 *buf,I64 addr,I64 field_len,I64 flags)
|
||||
{
|
||||
I64 offset;
|
||||
CHashExport *tempex;
|
||||
CHashExport *tmpex;
|
||||
U8 *str,*str2;
|
||||
Bool is_fun=FALSE;
|
||||
if (!(flags&SPF_TRUNCATE))
|
||||
if (!(flags&PRTF_TRUNCATE))
|
||||
field_len=0;
|
||||
if (addr) {
|
||||
if (str=FunSegCacheFind(addr,&offset)) {
|
||||
if (addr!=SYS_IDLE_PT)
|
||||
is_fun=TRUE;
|
||||
} else {
|
||||
if (tempex=FunSegFind(addr,&offset)) {
|
||||
if (tempex->type&HTT_FUN)
|
||||
if (tmpex=FunSegFind(addr,&offset)) {
|
||||
if (tmpex->type&HTT_FUN)
|
||||
is_fun=TRUE;
|
||||
FunSegCacheAdd(tempex,addr);
|
||||
str=tempex->str;
|
||||
FunSegCacheAdd(tmpex,addr);
|
||||
str=tmpex->str;
|
||||
}
|
||||
}
|
||||
if (str) {
|
||||
@@ -156,7 +156,7 @@ U0 StrPrintFunSeg(U8 *buf,I64 addr,I64 field_len,I64 flags)
|
||||
if (is_fun) {
|
||||
str2=MStrPrint("&%s",str);
|
||||
if (field_len>7) {
|
||||
if (flags&SPF_LEFT_JUSTIFY && StrLen(str2)<field_len-7)
|
||||
if (flags&PRTF_LEFT_JUSTIFY && StrLen(str2)<field_len-7)
|
||||
StrPrint(buf,"%s+0x%04X",str2,offset);
|
||||
else
|
||||
StrPrint(buf,"%*ts+0x%04X",field_len-7,str2,offset);
|
||||
@@ -165,7 +165,7 @@ U0 StrPrintFunSeg(U8 *buf,I64 addr,I64 field_len,I64 flags)
|
||||
Free(str2);
|
||||
} else {
|
||||
if (field_len>7) {
|
||||
if (flags&SPF_LEFT_JUSTIFY && StrLen(str)<field_len-7)
|
||||
if (flags&PRTF_LEFT_JUSTIFY && StrLen(str)<field_len-7)
|
||||
StrPrint(buf,"%s+0x%04X",str,offset);
|
||||
else
|
||||
StrPrint(buf,"%*ts+0x%04X",field_len-7,str,offset);
|
||||
@@ -175,7 +175,7 @@ U0 StrPrintFunSeg(U8 *buf,I64 addr,I64 field_len,I64 flags)
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (flags&SPF_TRUNCATE)
|
||||
if (flags&PRTF_TRUNCATE)
|
||||
StrPrint(buf,"%*tX",field_len,addr);
|
||||
else
|
||||
StrPrint(buf,"%X",addr);
|
||||
@@ -183,14 +183,14 @@ U0 StrPrintFunSeg(U8 *buf,I64 addr,I64 field_len,I64 flags)
|
||||
|
||||
I64 SrcLineNum(U8 *addr,I64 cnt=1)
|
||||
{//linenum for src of addr.
|
||||
CHashSrcSym *temph;
|
||||
CHashSrcSym *tmph;
|
||||
I64 cur_line,first_line,last_line,num_lines,offset;
|
||||
CDbgInfo *dbg_info;
|
||||
U32 *body;
|
||||
U8 *src,*src2;
|
||||
if (temph=FunSegFind(addr,&offset)) {
|
||||
if (temph->type&(HTT_FUN|HTT_EXPORT_SYS_SYM)) {
|
||||
if (dbg_info=temph->dbg_info) {
|
||||
if (tmph=FunSegFind(addr,&offset)) {
|
||||
if (tmph->type&(HTT_FUN|HTT_EXPORT_SYS_SYM)) {
|
||||
if (dbg_info=tmph->dbg_info) {
|
||||
num_lines=dbg_info->max_line-dbg_info->min_line+1;
|
||||
body=dbg_info->body;
|
||||
|
||||
@@ -222,9 +222,9 @@ I64 SrcLineNum(U8 *addr,I64 cnt=1)
|
||||
if (addr<body[cur_line]+cnt)
|
||||
return cur_line+dbg_info->min_line;
|
||||
|
||||
} else if (temph->src_link) {
|
||||
src =StrNew(temph->src_link);
|
||||
src2=StrNew(temph->src_link);
|
||||
} else if (tmph->src_link) {
|
||||
src =StrNew(tmph->src_link);
|
||||
src2=StrNew(tmph->src_link);
|
||||
StrLastRem(src,",",src2);
|
||||
cur_line=Str2I64(src2);
|
||||
Free(src);
|
||||
@@ -238,14 +238,14 @@ I64 SrcLineNum(U8 *addr,I64 cnt=1)
|
||||
|
||||
U8 *SrcFileName(U8 *addr,I64 cnt=1,CTask *mem_task=NULL)
|
||||
{//MAlloc filename for src of addr.
|
||||
CHashSrcSym *temph;
|
||||
CHashSrcSym *tmph;
|
||||
I64 i,j,ii,offset,best=NULL,d,best_d;
|
||||
U32 *body;
|
||||
CDbgInfo *dbg_info;
|
||||
U8 *src;
|
||||
if ((temph=FunSegFind(addr,&offset)) &&
|
||||
temph->type&(HTT_FUN|HTT_EXPORT_SYS_SYM)) {
|
||||
if (dbg_info=temph->dbg_info) {
|
||||
if ((tmph=FunSegFind(addr,&offset)) &&
|
||||
tmph->type&(HTT_FUN|HTT_EXPORT_SYS_SYM)) {
|
||||
if (dbg_info=tmph->dbg_info) {
|
||||
j=dbg_info->max_line-dbg_info->min_line+1;
|
||||
body=dbg_info->body;
|
||||
best_d=MAX_I64;
|
||||
@@ -258,13 +258,13 @@ U8 *SrcFileName(U8 *addr,I64 cnt=1,CTask *mem_task=NULL)
|
||||
d=addr(I64)-body[i];
|
||||
if (d<best_d) {
|
||||
best_d=d;
|
||||
best=temph->src_link;
|
||||
best=tmph->src_link;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
best=temph->src_link;
|
||||
best=tmph->src_link;
|
||||
}
|
||||
if (best) {
|
||||
src=StrNew(best,mem_task);
|
||||
@@ -325,10 +325,10 @@ Bool Man(U8 *st,I64 edf_dof_flags=0)
|
||||
{//Owner's manual for symbol. Edit src code for symbol.
|
||||
Bool res=FALSE;
|
||||
U8 **st2;
|
||||
CHashSrcSym *temph;
|
||||
CHashSrcSym *tmph;
|
||||
if (IsRaw) {
|
||||
if ((temph=HashFind(st,Fs->hash_table,HTG_SRC_SYM)) && temph->src_link)
|
||||
res=EdLiteFileLine(temph->src_link,edf_dof_flags);
|
||||
if ((tmph=HashFind(st,Fs->hash_table,HTG_SRC_SYM)) && tmph->src_link)
|
||||
res=EdLiteFileLine(tmph->src_link,edf_dof_flags);
|
||||
} else {
|
||||
st2=MStrPrint("MN:%s",st);
|
||||
res=Ed(st2,edf_dof_flags);
|
||||
|
||||
+42
-42
@@ -1,18 +1,18 @@
|
||||
U0 LinkedLstDel(U8 **_lst)
|
||||
{//Free entire linked-list.
|
||||
U8 **templ;
|
||||
U8 **tmpl;
|
||||
while (_lst) {
|
||||
templ=*_lst;
|
||||
tmpl=*_lst;
|
||||
Free(_lst);
|
||||
_lst=templ;
|
||||
_lst=tmpl;
|
||||
}
|
||||
}
|
||||
|
||||
U8 *LinkedLstCopy(U8 **_lst,CTask *mem_task=NULL)
|
||||
{//MAlloc ident copy of entire linked-list.
|
||||
U8 *res=NULL,**templ=&res;
|
||||
U8 *res=NULL,**tmpl=&res;
|
||||
while (_lst) {
|
||||
templ=*templ=MAllocIdent(_lst,mem_task);
|
||||
tmpl=*tmpl=MAllocIdent(_lst,mem_task);
|
||||
_lst=*_lst;
|
||||
}
|
||||
return res;
|
||||
@@ -40,46 +40,46 @@ I64 LinkedLstSize(U8 **_lst)
|
||||
|
||||
U0 QueDel(CQue *head,Bool querem=FALSE)
|
||||
{//Free entries in queue, not head.
|
||||
CQue *tempq=head->next,*tempq1;
|
||||
while (tempq!=head) {
|
||||
tempq1=tempq->next;
|
||||
CQue *tmpq=head->next,*tmpq1;
|
||||
while (tmpq!=head) {
|
||||
tmpq1=tmpq->next;
|
||||
if (querem)
|
||||
QueRem(tempq);
|
||||
Free(tempq);
|
||||
tempq=tempq1;
|
||||
QueRem(tmpq);
|
||||
Free(tmpq);
|
||||
tmpq=tmpq1;
|
||||
}
|
||||
}
|
||||
|
||||
CQue *QueCopy(CQue *head,CTask *mem_task=NULL)
|
||||
{//MAlloc ident copy of entire queue and head.
|
||||
CQue *res=MAllocIdent(head,mem_task),*tempq=head->next,*tempq1;
|
||||
CQue *res=MAllocIdent(head,mem_task),*tmpq=head->next,*tmpq1;
|
||||
QueInit(res);
|
||||
while (tempq!=head) {
|
||||
tempq1=MAllocIdent(tempq,mem_task);
|
||||
QueIns(tempq1,res->last);
|
||||
tempq=tempq->next;
|
||||
while (tmpq!=head) {
|
||||
tmpq1=MAllocIdent(tmpq,mem_task);
|
||||
QueIns(tmpq1,res->last);
|
||||
tmpq=tmpq->next;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
I64 QueCnt(CQue *head)
|
||||
{//Count of nodes in queue, not head.
|
||||
CQue *tempq=head->next;
|
||||
CQue *tmpq=head->next;
|
||||
I64 res=0;
|
||||
while (tempq!=head) {
|
||||
while (tmpq!=head) {
|
||||
res++;
|
||||
tempq=tempq->next;
|
||||
tmpq=tmpq->next;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
I64 QueSize(CQue *head)
|
||||
{//Mem size of all nodes in queue, not head.
|
||||
CQue *tempq=head->next;
|
||||
CQue *tmpq=head->next;
|
||||
I64 res=0;
|
||||
while (tempq!=head) {
|
||||
res+=MSize2(tempq);
|
||||
tempq=tempq->next;
|
||||
while (tmpq!=head) {
|
||||
res+=MSize2(tmpq);
|
||||
tmpq=tmpq->next;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@@ -95,34 +95,34 @@ CQueVectU8 *QueVectU8New(I64 min_idx=0)
|
||||
|
||||
U0 QueVectU8Put(CQueVectU8 *v,I64 idx,U8 ch)
|
||||
{//Put U8 at idx i.
|
||||
CQueVectU8 *tempv;
|
||||
CQueVectU8 *tmpv;
|
||||
idx-=v->min_idx;
|
||||
if (idx<0) return;
|
||||
if (idx<v->total_cnt) {
|
||||
tempv=v;
|
||||
tmpv=v;
|
||||
do {
|
||||
idx-=tempv->node_cnt;
|
||||
idx-=tmpv->node_cnt;
|
||||
if (idx<0) {
|
||||
tempv->body[idx+tempv->node_cnt]=ch;
|
||||
tmpv->body[idx+tmpv->node_cnt]=ch;
|
||||
return;
|
||||
}
|
||||
tempv=tempv->next;
|
||||
} while (tempv!=v);
|
||||
tmpv=tmpv->next;
|
||||
} while (tmpv!=v);
|
||||
} else
|
||||
idx-=v->total_cnt;
|
||||
|
||||
while (TRUE) {
|
||||
tempv=v->last;
|
||||
if (tempv->node_cnt>=QUE_VECT_U8_CNT) {
|
||||
tempv=MAlloc(sizeof(CQueVectU8));
|
||||
tempv->node_cnt=0;
|
||||
QueIns(tempv,v->last);
|
||||
tmpv=v->last;
|
||||
if (tmpv->node_cnt>=QUE_VECT_U8_CNT) {
|
||||
tmpv=MAlloc(sizeof(CQueVectU8));
|
||||
tmpv->node_cnt=0;
|
||||
QueIns(tmpv,v->last);
|
||||
}
|
||||
if (idx--) {
|
||||
tempv->body[tempv->node_cnt++]=0;
|
||||
tmpv->body[tmpv->node_cnt++]=0;
|
||||
v->total_cnt++;
|
||||
} else {
|
||||
tempv->body[tempv->node_cnt++]=ch;
|
||||
tmpv->body[tmpv->node_cnt++]=ch;
|
||||
v->total_cnt++;
|
||||
break;
|
||||
}
|
||||
@@ -139,16 +139,16 @@ U0 QueVectU8Del(CQueVectU8 *v)
|
||||
|
||||
I64 QueVectU8Get(CQueVectU8 *v,I64 idx)
|
||||
{//Get U8 at idx i.
|
||||
CQueVectU8 *tempv;
|
||||
CQueVectU8 *tmpv;
|
||||
idx-=v->min_idx;
|
||||
if (!(0<=idx<v->total_cnt)) return 0;
|
||||
tempv=v;
|
||||
tmpv=v;
|
||||
do {
|
||||
idx-=tempv->node_cnt;
|
||||
idx-=tmpv->node_cnt;
|
||||
if (idx<0)
|
||||
return tempv->body[idx+tempv->node_cnt];
|
||||
tempv=tempv->next;
|
||||
} while (tempv!=v);
|
||||
return tmpv->body[idx+tmpv->node_cnt];
|
||||
tmpv=tmpv->next;
|
||||
} while (tmpv!=v);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
+39
-39
@@ -215,7 +215,7 @@ U0 Da(U8 **addr,I64 cnt=0x10)
|
||||
}
|
||||
|
||||
U0 RawPrint(I64 ms=100,U8 *fmt,...)
|
||||
{//Print using $LK,"Raw",A="MN:Raw"$ screen output for a length of time.
|
||||
{//Print using $LK,"Raw",A="MN:Raw"$ scrn output for a length of time.
|
||||
//$BK,1$Your heap must be good.$BK,0$
|
||||
U8 *buf=StrPrintJoin(NULL,fmt,argc,argv);
|
||||
Bool old_raw,old_input_filter;
|
||||
@@ -233,7 +233,7 @@ U0 RawPrint(I64 ms=100,U8 *fmt,...)
|
||||
|
||||
U0 RawD(I64 ms=100,U8 *addr,I64 cnt=0x80)
|
||||
{//Dumps a block of mem using $LK,"Raw",A="MN:Raw"$
|
||||
//screen output for a fixed length
|
||||
//scrn output for a fixed length
|
||||
//of time.
|
||||
Bool old_raw,old_input_filter;
|
||||
PUSHFD
|
||||
@@ -249,7 +249,7 @@ U0 RawD(I64 ms=100,U8 *addr,I64 cnt=0x80)
|
||||
|
||||
U0 RawDm(I64 ms=100,U8 *addr,I64 cnt=0x80)
|
||||
{//Dumps a block of mem using $LK,"Raw",A="MN:Raw"$
|
||||
//screen output for a fixed length
|
||||
//scrn output for a fixed length
|
||||
//of time.
|
||||
Bool old_raw,old_input_filter;
|
||||
PUSHFD
|
||||
@@ -343,23 +343,23 @@ U8 *SysGetStr2(I64)
|
||||
|
||||
CBpt *BptFind(U8 *needle_addr,CTask *haystack_task=NULL,Bool rem=FALSE)
|
||||
{
|
||||
CBpt *res=NULL,*tempb,*tempb1,*tempb2;
|
||||
CBpt *res=NULL,*tmpb,*tmpb1,*tmpb2;
|
||||
if (!haystack_task) haystack_task=Fs;
|
||||
PUSHFD
|
||||
CLI
|
||||
tempb1=&haystack_task->bpt_lst;
|
||||
tempb=haystack_task->bpt_lst;
|
||||
while (tempb) {
|
||||
tempb2=tempb->next;
|
||||
if (tempb->addr==needle_addr) {
|
||||
res=tempb;
|
||||
tmpb1=&haystack_task->bpt_lst;
|
||||
tmpb=haystack_task->bpt_lst;
|
||||
while (tmpb) {
|
||||
tmpb2=tmpb->next;
|
||||
if (tmpb->addr==needle_addr) {
|
||||
res=tmpb;
|
||||
if (rem)
|
||||
tempb1->next=tempb2;
|
||||
tmpb1->next=tmpb2;
|
||||
else
|
||||
tempb1=&tempb->next;
|
||||
tmpb1=&tmpb->next;
|
||||
} else
|
||||
tempb1=&tempb->next;
|
||||
tempb=tempb2;
|
||||
tmpb1=&tmpb->next;
|
||||
tmpb=tmpb2;
|
||||
}
|
||||
POPFD
|
||||
return res;
|
||||
@@ -367,18 +367,18 @@ CBpt *BptFind(U8 *needle_addr,CTask *haystack_task=NULL,Bool rem=FALSE)
|
||||
|
||||
Bool BptS(U8 *addr,CTask *task=NULL,Bool live=TRUE)
|
||||
{//Set breakpoint.
|
||||
CBpt *tempb;
|
||||
CBpt *tmpb;
|
||||
Bool res=TRUE;
|
||||
if (!task) task=Fs;
|
||||
PUSHFD
|
||||
CLI
|
||||
if (!(tempb=BptFind(addr,task,FALSE))) {
|
||||
tempb=CAlloc(sizeof(CBpt),task);
|
||||
tempb->addr=addr;
|
||||
tempb->val=*addr;
|
||||
if (!(tmpb=BptFind(addr,task,FALSE))) {
|
||||
tmpb=CAlloc(sizeof(CBpt),task);
|
||||
tmpb->addr=addr;
|
||||
tmpb->val=*addr;
|
||||
res=FALSE;
|
||||
tempb->next=task->bpt_lst;
|
||||
task->bpt_lst=tempb;
|
||||
tmpb->next=task->bpt_lst;
|
||||
task->bpt_lst=tmpb;
|
||||
if (task==Fs && live)
|
||||
*addr=OC_BPT;
|
||||
}
|
||||
@@ -388,17 +388,17 @@ Bool BptS(U8 *addr,CTask *task=NULL,Bool live=TRUE)
|
||||
|
||||
Bool BptR(U8 *addr,CTask *task=NULL,Bool live=TRUE,Bool rem=TRUE)
|
||||
{//Rem breakpoint.
|
||||
CBpt *tempb;
|
||||
CBpt *tmpb;
|
||||
Bool res=FALSE;
|
||||
if (!task) task=Fs;
|
||||
PUSHFD
|
||||
CLI
|
||||
if (tempb=BptFind(addr,task,rem)) {
|
||||
if (tmpb=BptFind(addr,task,rem)) {
|
||||
if (task==Fs && live)
|
||||
*tempb->addr=tempb->val;
|
||||
*tmpb->addr=tmpb->val;
|
||||
res=TRUE;
|
||||
if (rem)
|
||||
Free(tempb);
|
||||
Free(tmpb);
|
||||
}
|
||||
POPFD
|
||||
return res;
|
||||
@@ -423,18 +423,18 @@ I64 B2(CTask *task=NULL,Bool live=TRUE)
|
||||
{//Rem all breakpoints.
|
||||
//Return: cnt of removed.
|
||||
I64 res=0;
|
||||
CBpt *tempb,*tempb1;
|
||||
CBpt *tmpb,*tmpb1;
|
||||
if (!task) task=Fs;
|
||||
PUSHFD
|
||||
CLI
|
||||
tempb=task->bpt_lst;
|
||||
tmpb=task->bpt_lst;
|
||||
task->bpt_lst=NULL;
|
||||
while (tempb) {
|
||||
tempb1=tempb->next;
|
||||
while (tmpb) {
|
||||
tmpb1=tmpb->next;
|
||||
if (task==Fs && live)
|
||||
*tempb->addr=tempb->val;
|
||||
Free(tempb);
|
||||
tempb=tempb1;
|
||||
*tmpb->addr=tmpb->val;
|
||||
Free(tmpb);
|
||||
tmpb=tmpb1;
|
||||
res++;
|
||||
}
|
||||
POPFD
|
||||
@@ -451,13 +451,13 @@ U0 G(U8 *ip=INVALID_PTR,CTask *task=NULL)
|
||||
">B2;\t\t\t//Clear all break points\n"
|
||||
">G2;\t\t\t//Clear all break points and Go\n\n"
|
||||
"After resuming, <CTRL-ALT-n> next focus task\n"
|
||||
"After resuming, <CTRL-ALT-v> flushes screen VGA cache\n";
|
||||
"After resuming, <CTRL-ALT-v> flushes scrn VGA cache\n";
|
||||
else {
|
||||
LBtr(&task->task_flags,TASKf_DISABLE_BPTS);
|
||||
LBtr(&task->rflags,RFLAGf_TRAP);//No single step
|
||||
Suspend(task,FALSE);
|
||||
if (task==Fs) {
|
||||
if (IsDbg && task->next_cc!=&task->next_cc) {
|
||||
if (IsDbgMode && task->next_cc!=&task->next_cc) {
|
||||
"Exit Dbg\n";
|
||||
Btr(&task->last_cc->flags,CCf_PMT);
|
||||
}
|
||||
@@ -486,7 +486,7 @@ public U0 S(U8 *ip=INVALID_PTR,CTask *task=NULL) //Single-step.
|
||||
LBts(&task->rflags,RFLAGf_TRAP);
|
||||
Suspend(task,FALSE);
|
||||
if (task==Fs) {
|
||||
if (IsDbg) {
|
||||
if (IsDbgMode) {
|
||||
if (task->next_cc!=&task->next_cc)
|
||||
Btr(&task->last_cc->flags,CCf_PMT);
|
||||
}
|
||||
@@ -527,7 +527,7 @@ U0 DbgHelp()
|
||||
">G2;\t\t\t\t//B2;VGAFlush;WinFocus;G;\n"
|
||||
">Exit;\t\t\t\t//Exit (kill) task.\n\n"
|
||||
"After resuming, <CTRL-ALT-n> next focus task.\n"
|
||||
"After resuming, <CTRL-ALT-v> flushes screen VGA cache.\n\n";
|
||||
"After resuming, <CTRL-ALT-v> flushes scrn VGA cache.\n\n";
|
||||
}
|
||||
|
||||
U0 Dbg2()
|
||||
@@ -595,7 +595,7 @@ U0 Fault2(I64 fault_num,I64 fault_err_code)
|
||||
Bool was_raw,was_single_user,was_silent,was_in_dbg;
|
||||
I64 i,old_raw_flags=text.raw_flags;
|
||||
was_single_user=SingleUser(ON);
|
||||
if (!IsDbg)
|
||||
if (!IsDbgMode)
|
||||
dbg.focus_task=sys_focus_task;
|
||||
sys_focus_task=NULL;
|
||||
if (fault_num==I_BPT)
|
||||
@@ -612,7 +612,7 @@ U0 Fault2(I64 fault_num,I64 fault_err_code)
|
||||
"\"\n";
|
||||
"Fault:0x%02X %Z\t\tErr Code:%08X\n",
|
||||
fault_num,fault_num,"ST_INT_NAMES",fault_err_code;
|
||||
was_in_dbg=InDbg(ON);
|
||||
was_in_dbg=DbgMode(ON);
|
||||
"RIP:%08X",Fs->rip; //Sometimes crashes on %p, so do this first
|
||||
":%p RSP:%08X\n",Fs->rip,Fs->rsp;
|
||||
if (fault_num==I_PAGE_FAULT) {
|
||||
@@ -621,7 +621,7 @@ U0 Fault2(I64 fault_num,I64 fault_err_code)
|
||||
"Fault Addr:%08X:%p\n",i,i;
|
||||
}
|
||||
Fault3(fault_num,fault_err_code);
|
||||
InDbg(was_in_dbg);
|
||||
DbgMode(was_in_dbg);
|
||||
Silent(was_silent);
|
||||
Raw(was_raw);
|
||||
text.raw_flags=old_raw_flags;
|
||||
|
||||
+29
-29
@@ -1,34 +1,34 @@
|
||||
CHashDefineStr *DefineLoad(U8 *dname,U8 *st)
|
||||
{//Create DEFINE hash entry with string.
|
||||
CHashDefineStr *temph=CAlloc(sizeof(CHashDefineStr));
|
||||
temph->type=HTT_DEFINE_STR;
|
||||
temph->str=StrNew(dname);
|
||||
temph->data=StrNew(st);
|
||||
temph->cnt=-1;
|
||||
temph->src_link=MStrPrint("AD:0x%X",Caller);
|
||||
HashAdd(temph,Fs->hash_table);
|
||||
return temph;
|
||||
CHashDefineStr *tmph=CAlloc(sizeof(CHashDefineStr));
|
||||
tmph->type=HTT_DEFINE_STR;
|
||||
tmph->str=StrNew(dname);
|
||||
tmph->data=StrNew(st);
|
||||
tmph->cnt=-1;
|
||||
tmph->src_link=MStrPrint("AD:0x%X",Caller);
|
||||
HashAdd(tmph,Fs->hash_table);
|
||||
return tmph;
|
||||
}
|
||||
|
||||
CHashDefineStr *DefineLstLoad(U8 *dname,U8 *lst)
|
||||
{//Create DEFINE list. Not efficient, but handy.
|
||||
I64 cnt=0;
|
||||
U8 *ptr,**idx;
|
||||
CHashDefineStr *temph=CAlloc(sizeof(CHashDefineStr));
|
||||
temph->type=HTT_DEFINE_STR;
|
||||
temph->str=StrNew(dname);
|
||||
temph->src_link=MStrPrint("AD:0x%X",Caller);
|
||||
CHashDefineStr *tmph=CAlloc(sizeof(CHashDefineStr));
|
||||
tmph->type=HTT_DEFINE_STR;
|
||||
tmph->str=StrNew(dname);
|
||||
tmph->src_link=MStrPrint("AD:0x%X",Caller);
|
||||
ptr=lst;
|
||||
while (*ptr) {
|
||||
if (*ptr!='@')
|
||||
cnt++;
|
||||
while (*ptr++);
|
||||
}
|
||||
temph->data=MAlloc(ptr+1-lst);
|
||||
MemCpy(temph->data,lst,ptr+1-lst);
|
||||
temph->cnt=cnt;
|
||||
tmph->data=MAlloc(ptr+1-lst);
|
||||
MemCpy(tmph->data,lst,ptr+1-lst);
|
||||
tmph->cnt=cnt;
|
||||
|
||||
idx=temph->sub_idx=MAlloc(cnt*sizeof(U8 *));
|
||||
idx=tmph->sub_idx=MAlloc(cnt*sizeof(U8 *));
|
||||
ptr=lst;
|
||||
while (*ptr) {
|
||||
if (*ptr!='@')
|
||||
@@ -36,8 +36,8 @@ CHashDefineStr *DefineLstLoad(U8 *dname,U8 *lst)
|
||||
while (*ptr++);
|
||||
}
|
||||
|
||||
HashAdd(temph,Fs->hash_table);
|
||||
return temph;
|
||||
HashAdd(tmph,Fs->hash_table);
|
||||
return tmph;
|
||||
}
|
||||
|
||||
U0 UndefinedDefine(U8 *dname)
|
||||
@@ -48,9 +48,9 @@ U0 UndefinedDefine(U8 *dname)
|
||||
|
||||
U8 *Define(U8 *dname)
|
||||
{//Look for DEFINE named in hash table, return ptr string.
|
||||
CHashDefineStr *temph;
|
||||
if (temph=HashFind(dname,Fs->hash_table,HTT_DEFINE_STR))
|
||||
return temph->data;
|
||||
CHashDefineStr *tmph;
|
||||
if (tmph=HashFind(dname,Fs->hash_table,HTT_DEFINE_STR))
|
||||
return tmph->data;
|
||||
else if (dname)
|
||||
UndefinedDefine(dname);
|
||||
else
|
||||
@@ -59,10 +59,10 @@ U8 *Define(U8 *dname)
|
||||
|
||||
U8 *DefineSub(I64 sub,U8 *dname)
|
||||
{//Return DEFINE list entry indexed by number.
|
||||
CHashDefineStr *temph;
|
||||
if (temph=HashFind(dname,Fs->hash_table,HTT_DEFINE_STR)) {
|
||||
if (0<=sub<temph->cnt)
|
||||
return temph->sub_idx[sub];
|
||||
CHashDefineStr *tmph;
|
||||
if (tmph=HashFind(dname,Fs->hash_table,HTT_DEFINE_STR)) {
|
||||
if (0<=sub<tmph->cnt)
|
||||
return tmph->sub_idx[sub];
|
||||
else
|
||||
return NULL;
|
||||
} else if (dname)
|
||||
@@ -73,9 +73,9 @@ U8 *DefineSub(I64 sub,U8 *dname)
|
||||
|
||||
I64 DefineCnt(U8 *dname)
|
||||
{//Return cnt of entries in define list.
|
||||
CHashDefineStr *temph;
|
||||
if (temph=HashFind(dname,Fs->hash_table,HTT_DEFINE_STR))
|
||||
return temph->cnt;
|
||||
CHashDefineStr *tmph;
|
||||
if (tmph=HashFind(dname,Fs->hash_table,HTT_DEFINE_STR))
|
||||
return tmph->cnt;
|
||||
else if (dname)
|
||||
UndefinedDefine(dname);
|
||||
else
|
||||
@@ -107,7 +107,7 @@ U0 SysDefinesLoad()
|
||||
"June\0July\0August\0September\0October\0November\0December\0");
|
||||
DefineLstLoad("ST_FILE_ATTRS","R\0H\0S\0V\0D\0A\0 \0 \0X\0T\0Z\0C\0F\0");
|
||||
DefineLstLoad("ST_FILE_UTIL_FLAGS","r\0d\0i\0a\0c\0R\0p\0m\0x\0s\0"
|
||||
"D\0F\0T\0S\0A\0J\0G\0Z\0O\0P\0f\0l\0lb\0la\0");
|
||||
"D\0F\0T\0$$\0S\0A\0J\0G\0Z\0O\0P\0f\0l\0lb\0la\0");
|
||||
DefineLstLoad("ST_BLKDEV_TYPES",
|
||||
"NULL\0RAM\0ATA\0FILE_READ\0FILE_WRITE\0ATAPI\0");
|
||||
DefineLstLoad("ST_DRV_TYPES",
|
||||
|
||||
+6
-8
@@ -9,8 +9,8 @@ U0 SysGlblsInit()
|
||||
sys_focus_task=Fs;
|
||||
QueInit(&sys_macro_head);
|
||||
|
||||
blkdev.dft_iso_filename=AStrNew("::/Temp/CDDVD.ISO");
|
||||
blkdev.temp_filename=AStrNew("~/Temp.DD.Z");
|
||||
blkdev.dft_iso_filename=AStrNew("::/Tmp/CDDVD.ISO");
|
||||
blkdev.tmp_filename=AStrNew("~/Tmp.DD.Z");
|
||||
blkdev.dvd_boot_is_good=TRUE;
|
||||
#exe {
|
||||
if (!kernel_cfg->auto_mount_ide_hd_let)
|
||||
@@ -23,7 +23,7 @@ U0 SysGlblsInit()
|
||||
kernel_cfg->auto_mount_ide_cd_let);
|
||||
}
|
||||
|
||||
InDbg(ON);
|
||||
DbgMode(ON);
|
||||
rev_bits_table =CAlloc(256);
|
||||
set_bits_table =CAlloc(256);
|
||||
for (i=0;i<256;i++)
|
||||
@@ -52,8 +52,6 @@ U0 SysGlblsInit()
|
||||
|
||||
ProgressBarsRst;
|
||||
|
||||
//$AN,"Independent HeapCtrl Example",A="Independent HeapCtrl Example"$
|
||||
i=1; //Rqst 1 blk, we might get more.
|
||||
QueInit(&dev.pci_head);
|
||||
dev.mem64_ptr=MEM_MAPPED_SPACE;
|
||||
|
||||
@@ -79,7 +77,7 @@ U0 SysGrInit()
|
||||
OutU8(VGAP_IDX,VGAR_MAP_MASK);
|
||||
OutU8(VGAP_DATA,0x0F);
|
||||
MemSet(text.vga_alias,0,GR_WIDTH*GR_HEIGHT>>3);
|
||||
text.raw_screen_image=CAlloc(GR_WIDTH*GR_HEIGHT/8);
|
||||
text.raw_scrn_image=CAlloc(GR_WIDTH*GR_HEIGHT/8);
|
||||
text.border_chars[2] (I64)=0x0908070605040302;
|
||||
text.border_chars[10](U32)=0x0D0C0B0A;
|
||||
}
|
||||
@@ -159,7 +157,7 @@ U0 KernelMain()
|
||||
LBts(&sys_run_level,RLf_RAW);
|
||||
TimersInit;
|
||||
if (BIOSTotalMem<ToI64(0.95*MEM_MIN_MEG*0x100000))
|
||||
RawPrint(4000,"!!! Requires $TX,"512 Meg",D="DD_MEM_MIN_MEG"$ of RAM Memory !!!");
|
||||
RawPrint(4000,"!!! Requires $TX,"512Meg",D="DD_MEM_MIN_MEG"$ of RAM Memory !!!");
|
||||
|
||||
IntsInit;
|
||||
"Enable IRQ's\n";
|
||||
@@ -197,7 +195,7 @@ U0 KernelMain()
|
||||
Load("Compiler",LDF_SILENT);
|
||||
LBts(&sys_run_level,RLf_COMPILER);
|
||||
|
||||
InDbg(OFF);
|
||||
DbgMode(OFF);
|
||||
cnts.time_stamp_freq_initial=TimeStampFreqCal;
|
||||
Cd("/");
|
||||
try ExeFile("StartOS"); //Continues $LK,"/StartOS.HC",A="FL:/StartOS.HC,1"$
|
||||
|
||||
+26
-19
@@ -45,8 +45,9 @@ _extern _SAVE_EXCEPT_REGS U0 SaveExceptRegs(CExcept *t);
|
||||
U0 PutExcept(Bool catch_it=TRUE)
|
||||
{//Print exception msg and catch exception.
|
||||
"Except:%c:",Fs->except_ch;
|
||||
"%P:%P:%P:%P\n",Fs->except_caller1,Fs->except_caller2,
|
||||
Fs->except_caller3,Fs->except_caller4;
|
||||
"%P:%P:%P:%P:%P:%P\n",Fs->except_caller1,Fs->except_caller2,
|
||||
Fs->except_caller3,Fs->except_caller4,Fs->except_caller5,
|
||||
Fs->except_caller6,Fs->except_caller7,Fs->except_caller8;
|
||||
Fs->catch_except=catch_it;
|
||||
}
|
||||
|
||||
@@ -63,46 +64,52 @@ class CTryStk
|
||||
U0 SysTry(U8 *catch_start,U8 *untry_start)
|
||||
{
|
||||
I64 *rbp=GetRBP;
|
||||
CExcept *tempt=MAlloc(sizeof(CExcept));
|
||||
tempt->handler_catch=catch_start;
|
||||
tempt->handler_untry=untry_start;
|
||||
tempt->rsp=rbp(U8 *)+sizeof(CTryStk);
|
||||
tempt->rbp=*rbp;
|
||||
tempt->rflags=GetRFlags;
|
||||
SaveExceptRegs(tempt);
|
||||
QueIns(tempt,Fs->last_except);
|
||||
CExcept *tmpt=MAlloc(sizeof(CExcept));
|
||||
tmpt->handler_catch=catch_start;
|
||||
tmpt->handler_untry=untry_start;
|
||||
tmpt->rsp=rbp(U8 *)+sizeof(CTryStk);
|
||||
tmpt->rbp=*rbp;
|
||||
tmpt->rflags=GetRFlags;
|
||||
SaveExceptRegs(tmpt);
|
||||
QueIns(tmpt,Fs->last_except);
|
||||
}
|
||||
|
||||
U0 SysUntry()
|
||||
{
|
||||
CExcept *tempt=Fs->last_except;
|
||||
QueRem(tempt);
|
||||
Free(tempt);
|
||||
CExcept *tmpt=Fs->last_except;
|
||||
QueRem(tmpt);
|
||||
Free(tmpt);
|
||||
}
|
||||
|
||||
U0 throw(I64 ch=0,Bool no_log=FALSE)
|
||||
{//ch can be up to 8 chars like $LK,"PutChars",A="MN:PutChars"$().
|
||||
//In the catcher, fetch ch from Fs->except_ch.
|
||||
CExcept *tempt=Fs->last_except;
|
||||
CExcept *tmpt=Fs->last_except;
|
||||
Bool was_raw;
|
||||
Fs->except_ch=ch;
|
||||
Fs->except_caller1=Caller(1);
|
||||
Fs->except_caller2=Caller(2);
|
||||
Fs->except_caller3=Caller(3);
|
||||
Fs->except_caller4=Caller(4);
|
||||
Fs->except_caller5=Caller(5);
|
||||
Fs->except_caller6=Caller(6);
|
||||
Fs->except_caller7=Caller(7);
|
||||
Fs->except_caller8=Caller(8);
|
||||
Fs->except_rbp=GetRBP;
|
||||
Fs->catch_except=FALSE;
|
||||
if (!no_log)
|
||||
AdamLog("Except:%c:%p:%p:%p:%p\n",ch,Fs->except_caller1,Fs->except_caller2,
|
||||
Fs->except_caller3,Fs->except_caller4);
|
||||
AdamLog("Except:%c:%p:%p:%p:%p:%p:%p\n",ch,Fs->except_caller1,
|
||||
Fs->except_caller2,Fs->except_caller3,Fs->except_caller4,
|
||||
Fs->except_caller5,Fs->except_caller6,Fs->except_caller7,
|
||||
Fs->except_caller8);
|
||||
while (Fs->next_except!=&Fs->next_except) {
|
||||
TestExcept;
|
||||
if (Fs->catch_except)
|
||||
TakeExcept;
|
||||
SetRBP(Fs->except_rbp);
|
||||
tempt=Fs->last_except;
|
||||
QueRem(tempt);
|
||||
Free(tempt);
|
||||
tmpt=Fs->last_except;
|
||||
QueRem(tmpt);
|
||||
Free(tmpt);
|
||||
}
|
||||
was_raw=Raw(ON);
|
||||
PutExcept(FALSE);
|
||||
|
||||
+5
-5
@@ -38,7 +38,7 @@ extern U0 DskCacheInvalidate(CDrv *dv);
|
||||
extern U0 Exit();
|
||||
extern I64 FAT32AllocClusters(CDrv *dv,I64 c,I64 cnt);
|
||||
extern I64 FAT32AllocContiguousClusters(CDrv *dv,I64 cnt);
|
||||
extern Bool FAT32DirNew(CDrv *dv,U8 *cur_dir,CDirEntry *tempde,
|
||||
extern Bool FAT32DirNew(CDrv *dv,U8 *cur_dir,CDirEntry *tmpde,
|
||||
Bool free_old_chain);
|
||||
extern U0 FAT32DrvInit(CDrv *dv);
|
||||
extern Bool FAT32FileFind(CDrv *dv,I64 cur_dir_cluster,U8 *name,
|
||||
@@ -60,7 +60,7 @@ extern CHeapCtrl *HeapCtrlInit(CHeapCtrl *hc=NULL,
|
||||
extern Bool ISO1FileFind(CDrv *dv,I64 cur_dir_cluster,U8 *name,
|
||||
CDirEntry *_res,I64 fuf_flags=0);
|
||||
extern Bool ISODrvInit(CDrv *dv,I64 blk);
|
||||
extern Bool IsDbg();
|
||||
extern Bool IsDbgMode();
|
||||
extern Bool IsDir(U8 *dir_name);
|
||||
extern Bool IsRaw();
|
||||
extern CBlkDev *Let2BlkDev(U8 drv_let=0,Bool except=TRUE);
|
||||
@@ -77,7 +77,7 @@ extern U0 PutChars(U64 ch);
|
||||
extern U0 PutS(U8 *st); //Use $LK,"Print",A="MN:Print"$()
|
||||
extern Bool RBlks(CDrv *dv,U8 *buf, I64 blk, I64 cnt);
|
||||
extern I64 RedSeaAllocClusters(CDrv *dv,I64 cnt);
|
||||
extern Bool RedSeaDirNew(CDrv *dv,U8 *cur_dir,CDirEntry *tempde,
|
||||
extern Bool RedSeaDirNew(CDrv *dv,U8 *cur_dir,CDirEntry *tmpde,
|
||||
Bool free_old_chain);
|
||||
extern U0 RedSeaDrvInit(CDrv *dv);
|
||||
extern Bool RedSeaDrvValidate(U8 drv_let);
|
||||
@@ -88,7 +88,7 @@ extern U0 RedSeaFreeFreeLst(CDrv *dv);
|
||||
extern CTask *SpawnQue(U0 (*fp_addr)(U8 *data),U8 *data=NULL,
|
||||
U8 *task_name=NULL,I64 target_cpu,CTask *parent=NULL, //NULL means adam
|
||||
I64 stk_size=0,I64 flags=1<<SVCf_ADD_TO_QUE);
|
||||
extern U0 SrvCmdDel(CSrvCmd *tempc);
|
||||
extern U0 SrvCmdDel(CSrvCmd *tmpc);
|
||||
extern U0 SrvCmdQueDel(CSrvCmd *head);
|
||||
extern I64 SrvCmdsHandler(I64 run_flags,CTask *task=NULL);
|
||||
extern U0 SrvCtrlInit(CSrvCtrl *ctrl);
|
||||
@@ -99,7 +99,7 @@ extern CSrvCmd *TaskMsg(CTask *_srv,CTask *master,
|
||||
I64 msg_code,I64 a1,I64 a2,I64 flags);
|
||||
extern U0 TaskRstAwaitingMsg(CTask *task=NULL);
|
||||
extern Bool TaskValidate(CTask *task);
|
||||
extern U0 TaskWait(CTask *task=NULL);
|
||||
extern U0 TaskWait(CTask *task=NULL,Bool cmd_line_pmt=FALSE);
|
||||
extern CTask *User(U8 *fmt=NULL,...);
|
||||
extern U0 UserTaskCont();
|
||||
extern Bool WBlks(CDrv *dv,U8 *buf, I64 blk, I64 cnt);
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ CDoc *sys_clipboard_doc;
|
||||
CTask *adam_task;
|
||||
I64 sys_num_spawned_tasks;
|
||||
|
||||
CTask *sys_winmgr_task,*sys_task_being_screen_updated;
|
||||
CTask *sys_winmgr_task,*sys_task_being_scrn_updated;
|
||||
U8 *rev_bits_table, //Table with U8 bits revd
|
||||
*set_bits_table; //Table with count of set bits in a U8
|
||||
CDate local_time_offset;
|
||||
|
||||
+2
-2
@@ -259,7 +259,7 @@ _extern _HASH_SINGLE_TABLE_FIND CHash *HashSingleTableFind(U8 *needle_str,
|
||||
I64 mask,I64 instance=1);//Find string in single hash table.
|
||||
_extern _HASH_BUCKET_FIND CHash **HashBucketFind(U8 *needle_str,
|
||||
CHashTable *haystack_table); //Find hash bucket.
|
||||
_extern _HASH_ADD U0 HashAdd(CHash *temph,
|
||||
_extern _HASH_ADD U0 HashAdd(CHash *tmph,
|
||||
CHashTable *table); //Add entry to hash table.
|
||||
_extern _HASH_REM_DEL Bool HashRemDel(CHash *temph,CHashTable *table,
|
||||
_extern _HASH_REM_DEL Bool HashRemDel(CHash *tmph,CHashTable *table,
|
||||
I64 instance=1);//Remove hash entry and del. Instance must match.
|
||||
+84
-84
@@ -1,18 +1,18 @@
|
||||
I64 HashTypeNum(CHash *temph)
|
||||
I64 HashTypeNum(CHash *tmph)
|
||||
{//Return bit num of hash type, limited to just types.
|
||||
if (temph)
|
||||
return Bsf(temph->type&HTG_TYPE_MASK);
|
||||
if (tmph)
|
||||
return Bsf(tmph->type&HTG_TYPE_MASK);
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
I64 HashVal(CHash *temph)
|
||||
I64 HashVal(CHash *tmph)
|
||||
{//Returns most likely desired value.
|
||||
switch [HashTypeNum(temph)] {
|
||||
switch [HashTypeNum(tmph)] {
|
||||
case HTt_EXPORT_SYS_SYM:
|
||||
return temph(CHashExport *)->val;
|
||||
return tmph(CHashExport *)->val;
|
||||
case HTt_IMPORT_SYS_SYM:
|
||||
return temph(CHashImport *)->module_base;
|
||||
return tmph(CHashImport *)->module_base;
|
||||
case HTt_DEFINE_STR:
|
||||
case HTt_CLASS:
|
||||
case HTt_INTERNAL_TYPE:
|
||||
@@ -20,25 +20,25 @@ I64 HashVal(CHash *temph)
|
||||
case HTt_DICT_WORD:
|
||||
case HTt_OPCODE:
|
||||
case HTt_HELP_FILE:
|
||||
return temph;
|
||||
return tmph;
|
||||
case HTt_GLBL_VAR:
|
||||
if (temph(CHashGlblVar *)->flags&GVF_EXTERN)
|
||||
return &temph(CHashGlblVar *)->data_addr;
|
||||
if (tmph(CHashGlblVar *)->flags&GVF_EXTERN)
|
||||
return &tmph(CHashGlblVar *)->data_addr;
|
||||
else
|
||||
return temph(CHashGlblVar *)->data_addr;
|
||||
return tmph(CHashGlblVar *)->data_addr;
|
||||
case HTt_FUN:
|
||||
if (Bt(&temph(CHashFun *)->flags,Cf_EXTERN))
|
||||
return temph;
|
||||
if (Bt(&tmph(CHashFun *)->flags,Cf_EXTERN))
|
||||
return tmph;
|
||||
else
|
||||
return temph(CHashFun *)->exe_addr;
|
||||
return tmph(CHashFun *)->exe_addr;
|
||||
case HTt_REG:
|
||||
return temph(CHashReg *)->reg_num|temph(CHashReg *)->reg_type<<8;
|
||||
return tmph(CHashReg *)->reg_num|tmph(CHashReg *)->reg_type<<8;
|
||||
case HTt_KEYWORD:
|
||||
case HTt_ASM_KEYWORD:
|
||||
case HTt_MODULE:
|
||||
case HTt_FILE:
|
||||
case HTt_FRAME_PTR:
|
||||
return temph(CHashGeneric *)->user_data0;
|
||||
return tmph(CHashGeneric *)->user_data0;
|
||||
|
||||
case -1: //nobound switch
|
||||
case HTt_NUM_TYPES: //nobound switch
|
||||
@@ -56,48 +56,48 @@ CHashTable *HashTableNew(I64 size,CTask *mem_task=NULL)
|
||||
return table;
|
||||
}
|
||||
|
||||
U0 HashDel(CHashSrcSym *temph)
|
||||
U0 HashDel(CHashSrcSym *tmph)
|
||||
{//Free a std TempleOS system hash entry.
|
||||
if (!temph) return;
|
||||
if (!(temph->type&HTT_DICT_WORD))
|
||||
Free(temph->str);
|
||||
if (temph->type & HTG_SRC_SYM) {
|
||||
Free(temph->src_link);
|
||||
Free(temph->idx);
|
||||
Free(temph->import_name);
|
||||
LinkedLstDel(temph->ie_lst);
|
||||
if (temph->type & (HTT_FUN | HTT_EXPORT_SYS_SYM))
|
||||
Free(temph->dbg_info);
|
||||
if (temph->type & (HTT_FUN | HTT_CLASS))
|
||||
if (!tmph) return;
|
||||
if (!(tmph->type&HTT_DICT_WORD))
|
||||
Free(tmph->str);
|
||||
if (tmph->type & HTG_SRC_SYM) {
|
||||
Free(tmph->src_link);
|
||||
Free(tmph->idx);
|
||||
Free(tmph->import_name);
|
||||
LinkedLstDel(tmph->ie_lst);
|
||||
if (tmph->type & (HTT_FUN | HTT_EXPORT_SYS_SYM))
|
||||
Free(tmph->dbg_info);
|
||||
if (tmph->type & (HTT_FUN | HTT_CLASS))
|
||||
//Assumes code not on heap, so doesn't Free.
|
||||
//$LK,"ClassMemberLstDel",A="MN:ClassMemberLstDel"$() is an import to the Kernel module
|
||||
ClassMemberLstDel(temph);
|
||||
else if (temph->type&HTT_DEFINE_STR)
|
||||
Free(temph(CHashDefineStr *)->data);
|
||||
else if (temph->type & HTT_GLBL_VAR) {
|
||||
if (!(temph(CHashGlblVar *)->flags&GVF_ALIAS))
|
||||
Free(temph(CHashGlblVar *)->data_addr);
|
||||
LinkedLstDel(temph(CHashGlblVar *)->dim.next);
|
||||
if (temph(CHashGlblVar *)->fun_ptr)
|
||||
HashDel(temph(CHashGlblVar *)->fun_ptr
|
||||
-temph(CHashGlblVar *)->fun_ptr->ptr_stars_cnt);
|
||||
ClassMemberLstDel(tmph);
|
||||
else if (tmph->type&HTT_DEFINE_STR)
|
||||
Free(tmph(CHashDefineStr *)->data);
|
||||
else if (tmph->type & HTT_GLBL_VAR) {
|
||||
if (!(tmph(CHashGlblVar *)->flags&GVF_ALIAS))
|
||||
Free(tmph(CHashGlblVar *)->data_addr);
|
||||
LinkedLstDel(tmph(CHashGlblVar *)->dim.next);
|
||||
if (tmph(CHashGlblVar *)->fun_ptr)
|
||||
HashDel(tmph(CHashGlblVar *)->fun_ptr
|
||||
-tmph(CHashGlblVar *)->fun_ptr->ptr_stars_cnt);
|
||||
}
|
||||
} else if (temph->type & HTT_FILE)
|
||||
Free(temph(CHashGeneric *)->user_data0);
|
||||
Free(temph);
|
||||
} else if (tmph->type & HTT_FILE)
|
||||
Free(tmph(CHashGeneric *)->user_data0);
|
||||
Free(tmph);
|
||||
}
|
||||
|
||||
U0 HashTableDel(CHashTable *table)
|
||||
{//Free std system hash table, calling $LK,"HashDel",A="MN:HashDel"$() on entries.
|
||||
I64 i;
|
||||
CHashSrcSym *temph,*temph1;
|
||||
CHashSrcSym *tmph,*tmph1;
|
||||
if (!table) return;
|
||||
for (i=0;i<=table->mask;i++) {
|
||||
temph=table->body[i];
|
||||
while (temph) {
|
||||
temph1=temph->next;
|
||||
HashDel(temph);
|
||||
temph=temph1;
|
||||
tmph=table->body[i];
|
||||
while (tmph) {
|
||||
tmph1=tmph->next;
|
||||
HashDel(tmph);
|
||||
tmph=tmph1;
|
||||
}
|
||||
}
|
||||
Free(table->body);
|
||||
@@ -107,30 +107,30 @@ U0 HashTableDel(CHashTable *table)
|
||||
I64 HashTablePurge(CHashTable *table)
|
||||
{//Eliminate ExportSysSyms that have been usurped.
|
||||
I64 i,res=0;
|
||||
CHashSrcSym *temph,*temph1,*temph2;
|
||||
CHashSrcSym *tmph,*tmph1,*tmph2;
|
||||
if (!table) return 0;
|
||||
PUSHFD
|
||||
CLI //Precaution
|
||||
for (i=0;i<=table->mask;i++) {
|
||||
temph=table->body[i];
|
||||
while (temph) {
|
||||
temph1=temph->next; //We delete only older ones
|
||||
if (temph->type&(HTT_FUN|HTT_GLBL_VAR)) {
|
||||
temph2=temph->next; //Older always later in chain
|
||||
while (temph2) {
|
||||
if ((temph2->type&HTT_EXPORT_SYS_SYM ||
|
||||
temph2->type&HTG_TYPE_MASK==HTT_INVALID) &&
|
||||
!StrCmp(temph2->str,temph->str)) {
|
||||
if (temph2->type&HTG_TYPE_MASK==HTT_INVALID)
|
||||
temph2->type=HTT_KEYWORD;//Won't delete HTT_INVALID
|
||||
HashRemDel(temph2,table);
|
||||
tmph=table->body[i];
|
||||
while (tmph) {
|
||||
tmph1=tmph->next; //We delete only older ones
|
||||
if (tmph->type&(HTT_FUN|HTT_GLBL_VAR)) {
|
||||
tmph2=tmph->next; //Older always later in chain
|
||||
while (tmph2) {
|
||||
if ((tmph2->type&HTT_EXPORT_SYS_SYM ||
|
||||
tmph2->type&HTG_TYPE_MASK==HTT_INVALID) &&
|
||||
!StrCmp(tmph2->str,tmph->str)) {
|
||||
if (tmph2->type&HTG_TYPE_MASK==HTT_INVALID)
|
||||
tmph2->type=HTT_KEYWORD;//Won't delete HTT_INVALID
|
||||
HashRemDel(tmph2,table);
|
||||
res++;
|
||||
break;
|
||||
}
|
||||
temph2=temph2->next;
|
||||
tmph2=tmph2->next;
|
||||
}
|
||||
}
|
||||
temph=temph1;
|
||||
tmph=tmph1;
|
||||
}
|
||||
}
|
||||
POPFD
|
||||
@@ -153,11 +153,11 @@ CHashGeneric *HashGenericAdd(U8 *name,I64 type,
|
||||
|
||||
U0 HashSrcFileSet(CCmpCtrl *cc,CHashSrcSym *h,I64 line_num_offset=0)
|
||||
{//Set $LK,"CHashSrcSym",A="MN:CHashSrcSym"$ link and help_index by cur cc pos.
|
||||
CLexFile *tempf=cc->lex_include_stk;
|
||||
I64 line_num=tempf->line_num+line_num_offset;
|
||||
CLexFile *tmpf=cc->lex_include_stk;
|
||||
I64 line_num=tmpf->line_num+line_num_offset;
|
||||
if (line_num<1) line_num=1;
|
||||
Free(h->src_link);
|
||||
h->src_link=MStrPrint("FL:%s,%d",tempf->full_name,line_num);
|
||||
h->src_link=MStrPrint("FL:%s,%d",tmpf->full_name,line_num);
|
||||
if (Bt(&cc->opts,OPTf_KEEP_PRIVATE))
|
||||
h->type|=HTF_PRIVATE;
|
||||
Free(h->idx);
|
||||
@@ -185,18 +185,18 @@ CHashGeneric *HashPublic(U8 *st,I64 mask,Bool val=TRUE)
|
||||
I64 HashLstAdd(U8 *lst,I64 type,CHashTable *table)
|
||||
{//Add a list to a hash table.
|
||||
I64 i=0;
|
||||
CHashGeneric *temph;
|
||||
CHashGeneric *tmph;
|
||||
if (lst) {
|
||||
while (*lst) {
|
||||
if (*lst=='@')
|
||||
lst++;
|
||||
else
|
||||
i++;
|
||||
temph=CAlloc(sizeof(CHashGeneric));
|
||||
temph->user_data0=i-1;
|
||||
temph->str=StrNew(lst);
|
||||
temph->type=type;
|
||||
HashAdd(temph,table);
|
||||
tmph=CAlloc(sizeof(CHashGeneric));
|
||||
tmph->user_data0=i-1;
|
||||
tmph->str=StrNew(lst);
|
||||
tmph->type=type;
|
||||
HashAdd(tmph,table);
|
||||
while (*lst++);
|
||||
}
|
||||
}
|
||||
@@ -205,19 +205,19 @@ I64 HashLstAdd(U8 *lst,I64 type,CHashTable *table)
|
||||
|
||||
I64 HashDefineLstAdd(U8 *dname,I64 type,CHashTable *table)
|
||||
{//Add define list to a hash table. See $LK,"::/Adam/DolDoc/DocInit.HC",A="FF:::/Adam/DolDoc/DocInit.HC,HashDefineLstAdd"$.
|
||||
CHashDefineStr *temph;
|
||||
if (temph=HashFind(dname,Fs->hash_table,HTT_DEFINE_STR))
|
||||
return HashLstAdd(temph->data,type,table);
|
||||
CHashDefineStr *tmph;
|
||||
if (tmph=HashFind(dname,Fs->hash_table,HTT_DEFINE_STR))
|
||||
return HashLstAdd(tmph->data,type,table);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
I64 FramePtr(U8 *name,CTask *task=NULL)
|
||||
{//Find entry in task->hash_table, Return user_data.
|
||||
CHashGeneric *temph;
|
||||
CHashGeneric *tmph;
|
||||
if (!task) task=Fs;
|
||||
if (temph=HashFind(name,task->hash_table,HTT_FRAME_PTR))
|
||||
return temph->user_data0;
|
||||
if (tmph=HashFind(name,task->hash_table,HTT_FRAME_PTR))
|
||||
return tmph->user_data0;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
@@ -229,22 +229,22 @@ CHashGeneric *FramePtrAdd(U8 *name,I64 val=0,CTask *task=NULL)
|
||||
|
||||
I64 FramePtrSet(U8 *name,I64 val,CTask *task=NULL)
|
||||
{//Find hash entry in task->hash_table. Change user_data0.
|
||||
CHashGeneric *temph;
|
||||
CHashGeneric *tmph;
|
||||
if (!task) task=Fs;
|
||||
if (temph=HashFind(name,task->hash_table,HTT_FRAME_PTR))
|
||||
return LXchgI64(&temph->user_data0,val);
|
||||
if (tmph=HashFind(name,task->hash_table,HTT_FRAME_PTR))
|
||||
return LXchgI64(&tmph->user_data0,val);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
I64 FramePtrDel(U8 *name,CTask *task=NULL)
|
||||
{//Remove entry and delete.
|
||||
CHashGeneric *temph;
|
||||
CHashGeneric *tmph;
|
||||
I64 res=0;
|
||||
if (!task) task=Fs;
|
||||
if (temph=HashFind(name,task->hash_table,HTT_FRAME_PTR)) {
|
||||
res=temph->user_data0;
|
||||
HashRemDel(temph,task->hash_table);
|
||||
if (tmph=HashFind(name,task->hash_table,HTT_FRAME_PTR)) {
|
||||
res=tmph->user_data0;
|
||||
HashRemDel(tmph,task->hash_table);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
+4
-4
@@ -180,15 +180,15 @@ U8 *IntFaultHandlersNew()
|
||||
U0 IntInit1()
|
||||
{//Interrupt descriptor table part1.
|
||||
I64 i;
|
||||
CSysLimitBase temp_ptr;
|
||||
CSysLimitBase tmp_ptr;
|
||||
if (!Gs->num) {//Gs cur $LK,"CCPU",A="MN:CCPU"$ struct
|
||||
dev.idt=CAlloc(16*256);
|
||||
for (i=0;i<256;i++)
|
||||
IntEntrySet(i,&IntNop);
|
||||
}
|
||||
temp_ptr.limit=256*16-1;
|
||||
temp_ptr.base =dev.idt;
|
||||
SetRAX(&temp_ptr);
|
||||
tmp_ptr.limit=256*16-1;
|
||||
tmp_ptr.base =dev.idt;
|
||||
SetRAX(&tmp_ptr);
|
||||
LIDT U64 [RAX]
|
||||
}
|
||||
|
||||
|
||||
+37
-37
@@ -2,8 +2,8 @@ U0 LoadOneImport(U8 **_src,U8 *module_base,I64 ld_flags)
|
||||
{
|
||||
U8 *src=*_src,*ptr2,*st_ptr;
|
||||
I64 i,etype;
|
||||
CHashExport *tempex=NULL;
|
||||
CHashImport *tempiss;
|
||||
CHashExport *tmpex=NULL;
|
||||
CHashImport *tmpiss;
|
||||
Bool first=TRUE;
|
||||
|
||||
while (etype=*src++) {
|
||||
@@ -16,27 +16,27 @@ U0 LoadOneImport(U8 **_src,U8 *module_base,I64 ld_flags)
|
||||
return;
|
||||
} else {
|
||||
first=FALSE;
|
||||
if (!(tempex=HashFind(st_ptr,
|
||||
if (!(tmpex=HashFind(st_ptr,
|
||||
Fs->hash_table,HTG_ALL-HTT_IMPORT_SYS_SYM))) {
|
||||
if (!(ld_flags & LDF_SILENT))
|
||||
"Unresolved Reference:%s\n",st_ptr;
|
||||
tempiss=CAlloc(sizeof(CHashImport));
|
||||
tempiss->str=StrNew(st_ptr);
|
||||
tempiss->type=HTT_IMPORT_SYS_SYM;
|
||||
tempiss->module_header_entry=st_ptr-5;
|
||||
tempiss->module_base=module_base;
|
||||
HashAdd(tempiss,Fs->hash_table);
|
||||
tmpiss=CAlloc(sizeof(CHashImport));
|
||||
tmpiss->str=StrNew(st_ptr);
|
||||
tmpiss->type=HTT_IMPORT_SYS_SYM;
|
||||
tmpiss->module_header_entry=st_ptr-5;
|
||||
tmpiss->module_base=module_base;
|
||||
HashAdd(tmpiss,Fs->hash_table);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tempex) {
|
||||
if (tmpex) {
|
||||
ptr2=module_base+i;
|
||||
if (tempex->type & HTT_FUN)
|
||||
i=tempex(CHashFun *)->exe_addr;
|
||||
else if (tempex->type & HTT_GLBL_VAR)
|
||||
i=tempex(CHashGlblVar *)->data_addr;
|
||||
if (tmpex->type & HTT_FUN)
|
||||
i=tmpex(CHashFun *)->exe_addr;
|
||||
else if (tmpex->type & HTT_GLBL_VAR)
|
||||
i=tmpex(CHashGlblVar *)->data_addr;
|
||||
else
|
||||
i=tempex->val;
|
||||
i=tmpex->val;
|
||||
switch (etype) {
|
||||
case IET_REL_I8: *ptr2(U8 *) =i-ptr2-1; break;
|
||||
case IET_IMM_U8: *ptr2(U8 *) =i; break;
|
||||
@@ -54,13 +54,13 @@ U0 LoadOneImport(U8 **_src,U8 *module_base,I64 ld_flags)
|
||||
|
||||
U0 SysSymImportsResolve(U8 *st_ptr,I64 ld_flags)
|
||||
{
|
||||
CHashImport *tempiss;
|
||||
CHashImport *tmpiss;
|
||||
U8 *ptr;
|
||||
while (tempiss=HashSingleTableFind(st_ptr,
|
||||
while (tmpiss=HashSingleTableFind(st_ptr,
|
||||
Fs->hash_table,HTT_IMPORT_SYS_SYM)) {
|
||||
ptr=tempiss->module_header_entry;
|
||||
LoadOneImport(&ptr,tempiss->module_base,ld_flags);
|
||||
tempiss->type=HTT_INVALID;
|
||||
ptr=tmpiss->module_header_entry;
|
||||
LoadOneImport(&ptr,tmpiss->module_base,ld_flags);
|
||||
tmpiss->type=HTT_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ U0 LoadPass1(U8 *src,U8 *module_base,I64 ld_flags)
|
||||
{
|
||||
U8 *ptr2,*ptr3,*st_ptr;
|
||||
I64 i,j,cnt,etype;
|
||||
CHashExport *tempex=NULL;
|
||||
CHashExport *tmpex=NULL;
|
||||
while (etype=*src++) {
|
||||
i=*src(U32 *)++;
|
||||
st_ptr=src;
|
||||
@@ -78,14 +78,14 @@ U0 LoadPass1(U8 *src,U8 *module_base,I64 ld_flags)
|
||||
case IET_IMM32_EXPORT:
|
||||
case IET_REL64_EXPORT:
|
||||
case IET_IMM64_EXPORT:
|
||||
tempex=CAlloc(sizeof(CHashExport));
|
||||
tempex->str=StrNew(st_ptr);
|
||||
tempex->type=HTT_EXPORT_SYS_SYM|HTF_IMM;
|
||||
tmpex=CAlloc(sizeof(CHashExport));
|
||||
tmpex->str=StrNew(st_ptr);
|
||||
tmpex->type=HTT_EXPORT_SYS_SYM|HTF_IMM;
|
||||
if (etype==IET_IMM32_EXPORT||etype==IET_IMM64_EXPORT)
|
||||
tempex->val=i;
|
||||
tmpex->val=i;
|
||||
else
|
||||
tempex->val=i+module_base;
|
||||
HashAdd(tempex,Fs->hash_table);
|
||||
tmpex->val=i+module_base;
|
||||
HashAdd(tmpex,Fs->hash_table);
|
||||
SysSymImportsResolve(st_ptr,ld_flags);
|
||||
break;
|
||||
case IET_REL_I0...IET_IMM_I64:
|
||||
@@ -113,11 +113,11 @@ U0 LoadPass1(U8 *src,U8 *module_base,I64 ld_flags)
|
||||
break;
|
||||
end:
|
||||
if (*st_ptr) {
|
||||
tempex=CAlloc(sizeof(CHashExport));
|
||||
tempex->str=StrNew(st_ptr);
|
||||
tempex->type=HTT_EXPORT_SYS_SYM|HTF_IMM;
|
||||
tempex->val=ptr3;
|
||||
HashAdd(tempex,Fs->hash_table);
|
||||
tmpex=CAlloc(sizeof(CHashExport));
|
||||
tmpex->str=StrNew(st_ptr);
|
||||
tmpex->type=HTT_EXPORT_SYS_SYM|HTF_IMM;
|
||||
tmpex->val=ptr3;
|
||||
HashAdd(tmpex,Fs->hash_table);
|
||||
}
|
||||
cnt=i;
|
||||
for (j=0;j<cnt;j++) {
|
||||
@@ -135,11 +135,11 @@ U0 LoadPass1(U8 *src,U8 *module_base,I64 ld_flags)
|
||||
break;
|
||||
end:
|
||||
if (*st_ptr) {
|
||||
tempex=CAlloc(sizeof(CHashExport));
|
||||
tempex->str=StrNew(st_ptr);
|
||||
tempex->type=HTT_EXPORT_SYS_SYM|HTF_IMM;
|
||||
tempex->val=ptr3;
|
||||
HashAdd(tempex,Fs->hash_table);
|
||||
tmpex=CAlloc(sizeof(CHashExport));
|
||||
tmpex->str=StrNew(st_ptr);
|
||||
tmpex->type=HTT_EXPORT_SYS_SYM|HTF_IMM;
|
||||
tmpex->val=ptr3;
|
||||
HashAdd(tmpex,Fs->hash_table);
|
||||
}
|
||||
cnt=i;
|
||||
for (j=0;j<cnt;j++) {
|
||||
|
||||
+28
-16
@@ -177,7 +177,7 @@ U0 Snd(F64 freq)
|
||||
} else
|
||||
OutU8(0x61,InU8(0x61)&~3);
|
||||
}
|
||||
if (!IsDbg && snd.record) {
|
||||
if (!IsDbgMode && snd.record) {
|
||||
d=ACAlloc(sizeof(CSndData));
|
||||
d->freq=freq;
|
||||
d->time=tS;
|
||||
@@ -187,6 +187,18 @@ U0 Snd(F64 freq)
|
||||
}
|
||||
}
|
||||
|
||||
U0 SndRst()
|
||||
{//Fix stuck sound.
|
||||
if (Bt(&sys_semas[SYS_SEMA_SND],0)) {
|
||||
Sleep(1);
|
||||
if (Bt(&sys_semas[SYS_SEMA_SND],0)) {
|
||||
Sleep(1);
|
||||
LBtr(&sys_semas[SYS_SEMA_SND],0);
|
||||
}
|
||||
}
|
||||
Snd(0);
|
||||
}
|
||||
|
||||
U0 Beep(I64 freq=500,Bool busy=FALSE)
|
||||
{//Make beep at given freq.
|
||||
Snd(freq);
|
||||
@@ -202,7 +214,7 @@ U0 Beep(I64 freq=500,Bool busy=FALSE)
|
||||
}
|
||||
|
||||
Bool Mute(Bool val)
|
||||
{//Turn-off or on sound.
|
||||
{//Turn-off sound.
|
||||
Bool res;
|
||||
if (val) {
|
||||
PUSHFD
|
||||
@@ -221,55 +233,55 @@ Bool IsMute()
|
||||
}
|
||||
|
||||
Bool Silent(Bool val=ON)
|
||||
{//Turns-off StdOut console text output, not sound.
|
||||
{//Turn-off StdOut console text. (Not sound.)
|
||||
return LBEqu(&Fs->display_flags,DISPLAYf_SILENT,val);
|
||||
}
|
||||
|
||||
Bool IsSilent()
|
||||
{//Is StdOut turned-off?
|
||||
{//Return StdOut turned-off?
|
||||
return Bt(&Fs->display_flags,DISPLAYf_SILENT);
|
||||
}
|
||||
|
||||
Bool SysDbg(Bool val)
|
||||
{//Sets or resets sysdbg bit you can use while debugging.
|
||||
{//Set SysDbg bit you can use while debugging.
|
||||
return LBEqu(&sys_semas[SYS_SEMA_DEBUG],0,val);
|
||||
}
|
||||
|
||||
Bool IsSysDbg()
|
||||
{//Is sysdbg bit set?
|
||||
{//Return SysDbg bit.
|
||||
return Bt(&sys_semas[SYS_SEMA_DEBUG],0);
|
||||
}
|
||||
|
||||
Bool Raw(Bool val)
|
||||
{//Switches to direct screen, non-windowed output.
|
||||
{//Set to direct scrn, BLACK & WHITE, non-windowed output mode.
|
||||
if (!val)
|
||||
VGAFlush;
|
||||
return !LBEqu(&Fs->display_flags,DISPLAYf_NOT_RAW,!val);
|
||||
}
|
||||
|
||||
Bool IsRaw()
|
||||
{//Are we in BLACK & WHITE raw screen mode?
|
||||
{//Are we in BLACK & WHITE raw scrn mode?
|
||||
return !Bt(&Fs->display_flags,DISPLAYf_NOT_RAW);
|
||||
}
|
||||
|
||||
Bool SingleUser(Bool val)
|
||||
{//Sets or resets single-user mode bit.
|
||||
{//Set single-user mode.
|
||||
return LBEqu(&sys_semas[SYS_SEMA_SINGLE_USER],0,val);
|
||||
}
|
||||
|
||||
Bool IsSingleUser()
|
||||
{//Are we in single-user mode?
|
||||
{//Return single-user mode.
|
||||
return Bt(&sys_semas[SYS_SEMA_SINGLE_USER],0);
|
||||
}
|
||||
|
||||
Bool InDbg(Bool val)
|
||||
{//Set in-debugger flag.
|
||||
return LBEqu(&sys_semas[SYS_SEMA_IN_DEBUGGER],0,val);
|
||||
Bool DbgMode(Bool val)
|
||||
{//Set dbg-mode.
|
||||
return LBEqu(&sys_semas[SYS_SEMA_DBG_MODE],0,val);
|
||||
}
|
||||
|
||||
Bool IsDbg()
|
||||
{//Return in-debugger flag.
|
||||
return Bt(&sys_semas[SYS_SEMA_IN_DEBUGGER],0);
|
||||
Bool IsDbgMode()
|
||||
{//Return dbg-mode.
|
||||
return Bt(&sys_semas[SYS_SEMA_DBG_MODE],0);
|
||||
}
|
||||
|
||||
U0 ProgressBarsRst()
|
||||
|
||||
+1
-1
@@ -72,7 +72,7 @@ CORE0_32BIT_INIT:: //Entry point for $LK,"BootRAM",A="MN:BootRAM"$.
|
||||
MOV FS,AX
|
||||
MOV GS,AX
|
||||
MOV SS,AX
|
||||
MOV ESP,BOOT_RAM_LIMIT //Temp Stk
|
||||
MOV ESP,BOOT_RAM_LIMIT //Tmp Stk
|
||||
|
||||
//Patch abs addresses
|
||||
MOV ECX,U32 CPatchTableAbsAddr.abs_addres_cnt[ESI]
|
||||
|
||||
+45
-40
@@ -1,10 +1,10 @@
|
||||
U0 Exit()
|
||||
{//Terminate own task.
|
||||
if (Fs==sys_focus_task && IsDbg) {
|
||||
if (Fs==sys_focus_task && IsDbgMode) {
|
||||
LBts(&Fs->task_flags,TASKf_KILL_AFTER_DBG);
|
||||
G;
|
||||
} else {
|
||||
if (!Gs->num && !IsDbg)
|
||||
if (!Gs->num && !IsDbgMode)
|
||||
SingleUser(OFF);
|
||||
Fs->rflags=GetRFlags;
|
||||
Fs->rsp=GetRSP;
|
||||
@@ -25,14 +25,19 @@ Bool TaskValidate(CTask *task)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
U0 BirthWait(CTask **_task,I64 task_num=-1)
|
||||
I64 BirthWait(CTask **_task,I64 task_num=-1)
|
||||
{//Wait for task valid and not task_num.
|
||||
while (!TaskValidate(*_task)||(*_task)->task_num==task_num)
|
||||
Yield;
|
||||
return (*_task)->task_num;
|
||||
}
|
||||
|
||||
U0 DeathWait(CTask **_task)
|
||||
U0 DeathWait(CTask **_task,Bool send_exit=FALSE)
|
||||
{//Wait for task death.
|
||||
if (send_exit && TaskValidate(*_task)) {
|
||||
TaskWait(*_task,TRUE);
|
||||
XTalk(*_task,"Exit;\n");
|
||||
}
|
||||
while (TaskValidate(*_task))
|
||||
Yield;
|
||||
}
|
||||
@@ -79,11 +84,11 @@ Bool IsSuspended(CTask *task=NULL)
|
||||
|
||||
CTaskStk *TaskStkNew(I64 stk_size,CTask *task)
|
||||
{
|
||||
CTaskStk *temps=MAlloc(stk_size+offset(CTaskStk.stk_base),task);
|
||||
temps->next_stk=NULL;
|
||||
temps->stk_ptr=NULL;
|
||||
temps->stk_size=MSize(temps)-offset(CTaskStk.stk_base);
|
||||
return temps;
|
||||
CTaskStk *tmps=MAlloc(stk_size+offset(CTaskStk.stk_base),task);
|
||||
tmps->next_stk=NULL;
|
||||
tmps->stk_ptr=NULL;
|
||||
tmps->stk_size=MSize(tmps)-offset(CTaskStk.stk_base);
|
||||
return tmps;
|
||||
}
|
||||
|
||||
#exe {Option(OPTf_NO_REG_VAR,ON);};
|
||||
@@ -91,7 +96,7 @@ argpop I64 CallStkGrow(I64 stk_size_threshold,I64 stk_size,
|
||||
/*argpop*/I64 (*fp_addr)(...),...)
|
||||
{//Grow stk in call with any fixed num of args.
|
||||
//See $LK,"::/Demo/StkGrow.HC"$.
|
||||
CTaskStk *temps,*temps2,**_stk;
|
||||
CTaskStk *tmps,*tmps2,**_stk;
|
||||
I64 res,*rsp,*rsp2,*old_stk;
|
||||
|
||||
if (UnusedStk>=stk_size_threshold) {
|
||||
@@ -108,14 +113,14 @@ argpop I64 CallStkGrow(I64 stk_size_threshold,I64 stk_size,
|
||||
|
||||
} else {
|
||||
|
||||
temps2=TaskStkNew(stk_size,Fs);
|
||||
temps2->next_stk=temps=Fs->stk;
|
||||
rsp2=(&temps2->stk_base)(U8 *)+temps2->stk_size;
|
||||
tmps2=TaskStkNew(stk_size,Fs);
|
||||
tmps2->next_stk=tmps=Fs->stk;
|
||||
rsp2=(&tmps2->stk_base)(U8 *)+tmps2->stk_size;
|
||||
old_stk=rsp=&argv[argc];
|
||||
while (argc-->0)
|
||||
*--rsp2=*--rsp;
|
||||
_stk=&Fs->stk;
|
||||
temps->stk_ptr=rsp=GetRSP;
|
||||
tmps->stk_ptr=rsp=GetRSP;
|
||||
asm {
|
||||
IMPORT _FREE; //We are in a function, not at glbl scope.
|
||||
//The compiler treats these in isolation.
|
||||
@@ -123,9 +128,9 @@ argpop I64 CallStkGrow(I64 stk_size_threshold,I64 stk_size,
|
||||
PUSHFD
|
||||
POP RDX //flags
|
||||
CLI
|
||||
MOV RBX,U64 &temps2[RBP]
|
||||
MOV RBX,U64 &tmps2[RBP]
|
||||
MOV RAX,&_stk[RBP]
|
||||
MOV U64 [RAX],RBX //Fs->stk=temps2
|
||||
MOV U64 [RAX],RBX //Fs->stk=tmps2
|
||||
MOV RSP,U64 &rsp2[RBP]
|
||||
PUSH RDX
|
||||
POPFD
|
||||
@@ -136,14 +141,14 @@ argpop I64 CallStkGrow(I64 stk_size_threshold,I64 stk_size,
|
||||
PUSHFD
|
||||
POP RDX //flags
|
||||
CLI
|
||||
MOV RBX,U64 &temps[RBP]
|
||||
MOV RBX,U64 &tmps[RBP]
|
||||
MOV RAX,&_stk[RBP]
|
||||
MOV U64 [RAX],RBX //Fs->stk=temps
|
||||
MOV U64 [RAX],RBX //Fs->stk=tmps
|
||||
MOV RSP,U64 &rsp[RBP]
|
||||
PUSH RDX
|
||||
POPFD
|
||||
|
||||
PUSH U64 &temps2[RBP]
|
||||
PUSH U64 &tmps2[RBP]
|
||||
CALL _FREE
|
||||
|
||||
MOV RDX,U64 &old_stk[RBP]
|
||||
@@ -161,7 +166,7 @@ argpop I64 CallStkGrow(I64 stk_size_threshold,I64 stk_size,
|
||||
|
||||
I64 TaskInit(CTask *task,I64 stk_size)
|
||||
{//Returns Fs of task
|
||||
CTaskStk *temps;
|
||||
CTaskStk *tmps;
|
||||
|
||||
QueInit(&task->code_heap->next_mem_blk);
|
||||
task->code_heap->last_mergable=NULL;
|
||||
@@ -196,8 +201,8 @@ I64 TaskInit(CTask *task,I64 stk_size)
|
||||
|
||||
if (!stk_size)
|
||||
stk_size=MEM_DFT_STK;
|
||||
task->stk=temps=TaskStkNew(stk_size,task);
|
||||
task->rsp=(&temps->stk_base)(U8 *)+temps->stk_size;
|
||||
task->stk=tmps=TaskStkNew(stk_size,task);
|
||||
task->rsp=(&tmps->stk_base)(U8 *)+tmps->stk_size;
|
||||
|
||||
task->text_attr =WHITE<<4+BLUE;
|
||||
task->border_src =BDS_CONST;
|
||||
@@ -426,8 +431,8 @@ U0 TaskDel(CTask *task)
|
||||
|
||||
I64 TaskEnd()
|
||||
{//Called with irq's off.
|
||||
CTask *task=Fs,*tempt,*tempt1;
|
||||
if (task==sys_task_being_screen_updated) {
|
||||
CTask *task=Fs,*tmpt,*tmpt1;
|
||||
if (task==sys_task_being_scrn_updated) {
|
||||
LBts(&task->task_flags,TASKf_KILL_TASK);
|
||||
return task->next_task;
|
||||
}
|
||||
@@ -448,13 +453,13 @@ I64 TaskEnd()
|
||||
|
||||
DrvsRelease;
|
||||
BlkDevsRelease;
|
||||
tempt1=(&task->next_child_task)(U8 *)-offset(CTask.next_sibling_task);
|
||||
tempt=tempt1->next_sibling_task;
|
||||
if (tempt!=tempt1) {
|
||||
tmpt1=(&task->next_child_task)(U8 *)-offset(CTask.next_sibling_task);
|
||||
tmpt=tmpt1->next_sibling_task;
|
||||
if (tmpt!=tmpt1) {
|
||||
do {
|
||||
LBts(&tempt->task_flags,TASKf_KILL_TASK);
|
||||
tempt=tempt->next_sibling_task;
|
||||
} while (tempt!=tempt1);
|
||||
LBts(&tmpt->task_flags,TASKf_KILL_TASK);
|
||||
tmpt=tmpt->next_sibling_task;
|
||||
} while (tmpt!=tmpt1);
|
||||
return task->next_task;
|
||||
}
|
||||
if (LBtr(&task->display_flags,DISPLAYf_SHOW))
|
||||
@@ -482,17 +487,17 @@ I64 TaskEnd()
|
||||
//QueRem
|
||||
task->task_signature(I64)=0;
|
||||
|
||||
tempt =task->next_input_filter_task;
|
||||
tempt1=task->last_input_filter_task;
|
||||
tempt1->next_input_filter_task=tempt;
|
||||
tempt ->last_input_filter_task=tempt1;
|
||||
tmpt =task->next_input_filter_task;
|
||||
tmpt1=task->last_input_filter_task;
|
||||
tmpt1->next_input_filter_task=tmpt;
|
||||
tmpt ->last_input_filter_task=tmpt1;
|
||||
|
||||
tempt =task->next_sibling_task;
|
||||
tempt1=task->last_sibling_task;
|
||||
tempt1->next_sibling_task=tempt;
|
||||
tempt ->last_sibling_task=tempt1;
|
||||
tmpt =task->next_sibling_task;
|
||||
tmpt1=task->last_sibling_task;
|
||||
tmpt1->next_sibling_task=tmpt;
|
||||
tmpt ->last_sibling_task=tmpt1;
|
||||
|
||||
tempt =task->next_task; //save to return
|
||||
tmpt =task->next_task; //save to return
|
||||
TaskQueRem(task);
|
||||
|
||||
LBtr(&task->srv_ctrl.flags,SVCRf_LOCKED);
|
||||
@@ -504,7 +509,7 @@ I64 TaskEnd()
|
||||
QueIns(task,Gs->last_dying);
|
||||
LBtr(&Gs->cpu_flags,CPUf_DYING_TASK_QUE);
|
||||
|
||||
return tempt;
|
||||
return tmpt;
|
||||
}
|
||||
|
||||
U0 TaskKillDying()
|
||||
|
||||
+2191
-2187
File diff suppressed because it is too large.
Load diff
+100
-92
@@ -6,6 +6,7 @@ extern class CAOTHeapGlbl;
|
||||
extern class CAOTImportExport;
|
||||
extern class CCPU;
|
||||
extern class CDC;
|
||||
extern class CDirContext;
|
||||
extern class CDoc;
|
||||
extern class CFile;
|
||||
extern class CHashClass;
|
||||
@@ -268,8 +269,8 @@ public class CMathODE
|
||||
*DstateDt,
|
||||
*state_scale,
|
||||
*initial_state,
|
||||
*temp0,*temp1,*temp2,*temp3,
|
||||
*temp4,*temp5,*temp6,*temp7;
|
||||
*tmp0,*tmp1,*tmp2,*tmp3,
|
||||
*tmp4,*tmp5,*tmp6,*tmp7;
|
||||
CTask *mem_task,*win_task;
|
||||
U0 (*derivative)(CMathODE *o,F64 t,F64 *state,F64 *DstateDt);
|
||||
I64 user_data;
|
||||
@@ -594,7 +595,7 @@ class CSema
|
||||
#define SYS_SEMA_RECORD_MACRO 1
|
||||
#define SYS_SEMA_SYS_TIMER 2
|
||||
#define SYS_SEMA_SYS_DATE 3
|
||||
#define SYS_SEMA_IN_DEBUGGER 4
|
||||
#define SYS_SEMA_DBG_MODE 4
|
||||
#define SYS_SEMA_SND 5
|
||||
#define SYS_SEMA_HEAPLOG_ACTIVE 6
|
||||
#define SYS_SEMA_HEAPLOG_LOCK 7
|
||||
@@ -981,9 +982,9 @@ public class CHashGlblVar:CHashSrcSym
|
||||
|
||||
//CDocEntry.de_flags. These are +/- flags
|
||||
#define DOCEF_LEFT_CB 0x10000
|
||||
#define DOCEF_LEFT_AUTO 0x20000
|
||||
#define DOCEF_LEFT_IN_STR 0x20000
|
||||
#define DOCEF_RIGHT_CB 0x40000
|
||||
#define DOCEF_RIGHT_AUTO 0x80000
|
||||
#define DOCEF_RIGHT_IN_STR 0x80000
|
||||
#define DOCEF_LEFT_X 0x100000
|
||||
#define DOCEF_CENTER_X 0x200000
|
||||
#define DOCEF_RIGHT_X 0x400000
|
||||
@@ -1069,9 +1070,9 @@ public class CHashGlblVar:CHashSrcSym
|
||||
|
||||
//CDocEntry.de_flags. These are +/- flags
|
||||
#define DOCEf_LEFT_CB 16
|
||||
#define DOCEf_LEFT_AUTO 17
|
||||
#define DOCEf_LEFT_IN_STR 17
|
||||
#define DOCEf_RIGHT_CB 18
|
||||
#define DOCEf_RIGHT_AUTO 19
|
||||
#define DOCEf_RIGHT_IN_STR 19
|
||||
#define DOCEf_LEFT_X 20
|
||||
#define DOCEf_CENTER_X 21
|
||||
#define DOCEf_RIGHT_X 22
|
||||
@@ -1114,7 +1115,7 @@ public class CHashGlblVar:CHashSrcSym
|
||||
public class CDocBin
|
||||
{
|
||||
CDocBin *next,*last;
|
||||
I32 temp_use_cnt,renum_num;
|
||||
I32 tmp_use_cnt,renum_num;
|
||||
U8 *tag;
|
||||
U0 start;
|
||||
U32 num,flags,size,use_cnt;
|
||||
@@ -1239,6 +1240,7 @@ class CEdFindText
|
||||
|
||||
class CEdFileName
|
||||
{
|
||||
CDirContext *dirc;
|
||||
U8 name[256] fmtstr "$$DA-P,LEN=255,A=\"FileName:%s\"$$";
|
||||
};
|
||||
|
||||
@@ -1344,7 +1346,7 @@ class CDocUndo
|
||||
|
||||
#define RECALCt_NORMAL 0x00
|
||||
#define RECALCt_FIND_CURSOR 0x01
|
||||
#define RECALCt_TO_SCREEN 0x02
|
||||
#define RECALCt_TO_SCRN 0x02
|
||||
#define RECALCG_MASK 0xFF
|
||||
|
||||
#define RECALCF_HAS_CURSOR 0x100
|
||||
@@ -1495,9 +1497,9 @@ public class CAutoCompleteGlbls
|
||||
};
|
||||
|
||||
#help_index "AutoComplete/Dictionary"
|
||||
#define ACD_WORD_FILENAME "/Adam/AutoComplete/ACWords.DAT.Z"
|
||||
#define ACD_DEF_FILENAME "/Adam/AutoComplete/ACDefs.DAT"
|
||||
#define ACD_DEF_FILENAME_Z "/Adam/AutoComplete/ACDefs.DAT.Z"
|
||||
#define ACD_WORD_FILENAME "/Adam/AutoComplete/ACWords.DATA.Z"
|
||||
#define ACD_DEF_FILENAME "/Adam/AutoComplete/ACDefs.DATA"
|
||||
#define ACD_DEF_FILENAME_Z "/Adam/AutoComplete/ACDefs.DATA.Z"
|
||||
|
||||
#define ACD_H1 0
|
||||
#define ACD_H1_END 1
|
||||
@@ -1790,7 +1792,7 @@ POP R8 POP RDI POP RSI POP RBP POP RBX POP RDX POP RCX POP RAX
|
||||
|
||||
#define REGG_CLOBBERED 0x013F //RAX,RCX,RDX,RBX,R8
|
||||
#define REGG_SAVED 0x0030 //RBP,RSP
|
||||
#define REGG_STK_TEMP 0x0200 //R9
|
||||
#define REGG_STK_TMP 0x0200 //R9
|
||||
#define REGG_LOCAL_VARS 0xCCC0 //RSI,RDI,R10,R11,R14,R15
|
||||
#define REGG_LOCAL_NON_PTR_VARS 0x3000 //R12,R13
|
||||
|
||||
@@ -1833,7 +1835,7 @@ class CAsmNum2
|
||||
|
||||
class CAsmIns
|
||||
{
|
||||
CInst *tempi;
|
||||
CInst *tmpins;
|
||||
CAsmNum2 imm,disp;
|
||||
I64 U8_cnt,last_opcode_U8,
|
||||
REX,ModrM,SIB;
|
||||
@@ -2220,7 +2222,7 @@ public class CCmpGlbls
|
||||
U32 *dual_U16_tokens1,*dual_U16_tokens2,*dual_U16_tokens3,
|
||||
*binary_ops;
|
||||
I64 num_reg_vars,num_non_ptr_vars,
|
||||
stk_temps_mask,reg_vars_mask,non_ptr_vars_mask;
|
||||
stk_tmps_mask,reg_vars_mask,non_ptr_vars_mask;
|
||||
U8 *to_reg_vars_map,*non_ptr_vars_map;
|
||||
I64 size_arg_mask[9],
|
||||
compiled_lines;
|
||||
@@ -2288,9 +2290,10 @@ public class CATARep
|
||||
#help_index "File/FileNames"
|
||||
#define FILEMASK_JIT "*.HC*;*.HH*"
|
||||
#define FILEMASK_AOT "*.HC*;*.HH*;*.PRJ*"
|
||||
#define FILEMASK_SRC "*.HC*;*.HH*;*.AUT*;*.PRJ*"
|
||||
#define FILEMASK_TXT FILEMASK_SRC ";*.DD*;*.TXT*"
|
||||
#define FILEMASK_GRA "*.GRA*;*.BMP*"
|
||||
#define FILEMASK_SRC "*.HC*;*.HH*;*.IN*;*.PRJ*"
|
||||
#define FILEMASK_DD FILEMASK_SRC ";*.DD*"
|
||||
#define FILEMASK_TXT FILEMASK_DD ";*.TXT*"
|
||||
#define FILEMASK_GR "*.GR*;*.BMP*"
|
||||
|
||||
#help_index "File/Low Level"
|
||||
#define BLK_SIZE_BITS 9
|
||||
@@ -2580,47 +2583,49 @@ public class CDirEntry
|
||||
#define FUf_JUST_DIRS 10
|
||||
#define FUf_JUST_FILES 11
|
||||
#define FUf_JUST_TXT 12
|
||||
#define FUf_JUST_SRC 13
|
||||
#define FUf_JUST_AOT 14
|
||||
#define FUf_JUST_JIT 15
|
||||
#define FUf_JUST_GRA 16
|
||||
#define FUf_Z_OR_NOT_Z 17
|
||||
#define FUf_CLUSTER_ORDER 18
|
||||
#define FUf_SCAN_PARENTS 19
|
||||
#define FUf_FLATTEN_TREE 20
|
||||
#define FUf_WHOLE_LABELS 21
|
||||
#define FUf_WHOLE_LABELS_BEFORE 22
|
||||
#define FUf_WHOLE_LABELS_AFTER 23
|
||||
#define FUf_JUST_DD 13
|
||||
#define FUf_JUST_SRC 14
|
||||
#define FUf_JUST_AOT 15
|
||||
#define FUf_JUST_JIT 16
|
||||
#define FUf_JUST_GR 17
|
||||
#define FUf_Z_OR_NOT_Z 18
|
||||
#define FUf_CLUSTER_ORDER 19
|
||||
#define FUf_SCAN_PARENTS 20
|
||||
#define FUf_FLATTEN_TREE 21
|
||||
#define FUf_WHOLE_LABELS 22
|
||||
#define FUf_WHOLE_LABELS_BEFORE 23
|
||||
#define FUf_WHOLE_LABELS_AFTER 24
|
||||
|
||||
#define FUF_RECURSE 0x000001 //r
|
||||
#define FUF_DIFF 0x000002 //d
|
||||
#define FUF_IGNORE 0x000004 //i
|
||||
#define FUF_ALL 0x000008 //a
|
||||
#define FUF_CANCEL 0x000010 //c
|
||||
#define FUF_REPLACE 0x000020 //R
|
||||
#define FUF_RISKY 0x000020 //R
|
||||
#define FUF_PUBLIC 0x000040 //p
|
||||
#define FUF_MAP 0x000080 //m
|
||||
#define FUF_EXPAND 0x000100 //x
|
||||
#define FUF_SINGLE 0x000200 //s
|
||||
#define FUF_JUST_DIRS 0x000400 //D
|
||||
#define FUF_JUST_FILES 0x000800 //F
|
||||
#define FUF_JUST_TXT 0x001000 //T
|
||||
#define FUF_JUST_SRC 0x002000 //S
|
||||
#define FUF_JUST_AOT 0x004000 //A
|
||||
#define FUF_JUST_JIT 0x008000 //J
|
||||
#define FUF_JUST_GRA 0x010000 //G
|
||||
#define FUF_Z_OR_NOT_Z 0x020000 //Z
|
||||
#define FUF_CLUSTER_ORDER 0x040000 //O Move disk head one direction
|
||||
#define FUF_SCAN_PARENTS 0x080000 //P
|
||||
#define FUF_FLATTEN_TREE 0x100000 //f
|
||||
#define FUF_WHOLE_LABELS 0x200000 //l
|
||||
#define FUF_WHOLE_LABELS_BEFORE 0x400000 //lb
|
||||
#define FUF_WHOLE_LABELS_AFTER 0x800000 //la
|
||||
#define FUF_RECURSE 0x0000001 //r
|
||||
#define FUF_DIFF 0x0000002 //d
|
||||
#define FUF_IGNORE 0x0000004 //i
|
||||
#define FUF_ALL 0x0000008 //a
|
||||
#define FUF_CANCEL 0x0000010 //c
|
||||
#define FUF_REPLACE 0x0000020 //R
|
||||
#define FUF_RISKY 0x0000020 //R
|
||||
#define FUF_PUBLIC 0x0000040 //p
|
||||
#define FUF_MAP 0x0000080 //m
|
||||
#define FUF_EXPAND 0x0000100 //x
|
||||
#define FUF_SINGLE 0x0000200 //s
|
||||
#define FUF_JUST_DIRS 0x0000400 //D
|
||||
#define FUF_JUST_FILES 0x0000800 //F
|
||||
#define FUF_JUST_TXT 0x0001000 //T
|
||||
#define FUF_JUST_DD 0x0002000 //$$
|
||||
#define FUF_JUST_SRC 0x0004000 //S
|
||||
#define FUF_JUST_AOT 0x0008000 //A
|
||||
#define FUF_JUST_JIT 0x0010000 //J
|
||||
#define FUF_JUST_GR 0x0020000 //G
|
||||
#define FUF_Z_OR_NOT_Z 0x0040000 //Z
|
||||
#define FUF_CLUSTER_ORDER 0x0080000 //O Move disk head one direction
|
||||
#define FUF_SCAN_PARENTS 0x0100000 //P
|
||||
#define FUF_FLATTEN_TREE 0x0200000 //f
|
||||
#define FUF_WHOLE_LABELS 0x0400000 //l
|
||||
#define FUF_WHOLE_LABELS_BEFORE 0x0800000 //lb
|
||||
#define FUF_WHOLE_LABELS_AFTER 0x1000000 //la
|
||||
|
||||
#define FUG_FILES_FIND (FUF_RECURSE|FUF_SINGLE|FUF_CLUSTER_ORDER|\
|
||||
FUF_JUST_DIRS|FUF_JUST_FILES|FUF_JUST_TXT|\
|
||||
FUF_JUST_SRC|FUF_JUST_AOT|FUF_JUST_JIT|FUF_JUST_GRA|FUF_FLATTEN_TREE)
|
||||
FUF_JUST_DIRS|FUF_JUST_FILES|FUF_JUST_TXT|FUF_JUST_DD|\
|
||||
FUF_JUST_SRC|FUF_JUST_AOT|FUF_JUST_JIT|FUF_JUST_GR|FUF_FLATTEN_TREE)
|
||||
#define FUG_FILE_FIND (FUF_JUST_DIRS|FUF_JUST_FILES|FUF_Z_OR_NOT_Z|\
|
||||
FUF_SCAN_PARENTS)
|
||||
|
||||
@@ -2757,7 +2762,7 @@ public class CBlkDevGlbls
|
||||
{
|
||||
CBlkDev *blkdevs;
|
||||
U8 *dft_iso_filename; //See $LK,"blkdev.dft_iso_filename",A="FF:::/Kernel/KEnd.HC,blkdev.dft_iso_filename"$
|
||||
U8 *temp_filename;
|
||||
U8 *tmp_filename;
|
||||
U8 *home_dir;
|
||||
CCacheBlk *cache_base,*cache_ctrl,**cache_hash_table;
|
||||
I64 cache_size,read_cnt,write_cnt;
|
||||
@@ -2844,10 +2849,10 @@ There is no high kernel memory because RAM's physical
|
||||
addresses are low. (All motherboards that I know of
|
||||
put RAM in low addresses of 64-bit address space.)
|
||||
It's ring-0-only so all (or none) is kernel, remember.
|
||||
2 Meg hardware pages are used. Only the caching bits matter.
|
||||
2Meg hardware pages are used. Only the caching bits matter.
|
||||
Remember, it is ring-0-only and identity-mapped!
|
||||
|
||||
All code is placed in just the lowest 2 Gig, so the CALL REL32
|
||||
All code is placed in just the lowest 2Gig, so the CALL REL32
|
||||
inst always works. It never changes out of ring-0, remember,
|
||||
so I don't need to waste cycles on use SYSCALL or software interrupts.
|
||||
Everything just uses CALL REL32.
|
||||
@@ -2894,7 +2899,7 @@ public class CBlkPool
|
||||
{
|
||||
I64 locked_flags,alloced_u8s,used_u8s;
|
||||
CMemBlk *mem_free_lst,
|
||||
*mem_free_2meg_lst, //This is for $LK,"::/Demo/Lectures/Mem/Mem2Meg.HC"$
|
||||
*mem_free_2meg_lst, //This is for Sup1CodeScraps/Mem/Mem2Meg.HC.
|
||||
*free_page_hash[MEM_FREE_PAGE_HASH_SIZE],
|
||||
*free_page_hash2[64-MEM_PAGE_BITS];
|
||||
};
|
||||
@@ -2922,7 +2927,7 @@ public class CDevGlbls
|
||||
{
|
||||
I64 *idt;
|
||||
U8 *mem64_ptr;
|
||||
U8 *uncached_alias; //Alias of lowest 4 Gig.
|
||||
U8 *uncached_alias; //Alias of lowest 4Gig.
|
||||
U8 mp_apic_ids[MP_MAX_PROCESSORS];
|
||||
CMemRange mem32_head;
|
||||
CPCIDev pci_head;
|
||||
@@ -3120,8 +3125,8 @@ public class CCtrl
|
||||
//win pix coordinates
|
||||
I64 left,right,top,bottom;
|
||||
|
||||
//screen pix coordinates (derived)
|
||||
I64 screen_left,screen_right,screen_top,screen_bottom;
|
||||
//scrn pix coordinates (derived)
|
||||
I64 scrn_left,scrn_right,scrn_top,scrn_bottom;
|
||||
|
||||
U8 *state;
|
||||
|
||||
@@ -3280,16 +3285,17 @@ public class CTaskSettings
|
||||
#define TASKf_KILL_TASK 1
|
||||
#define TASKf_SUSPENDED 2
|
||||
#define TASKf_IDLE 3
|
||||
#define TASKf_INPUT_FILTER_TASK 4
|
||||
#define TASKf_FILTER_INPUT 5
|
||||
#define TASKf_HAS_SONG 6
|
||||
#define TASKf_DISABLE_BPTS 7
|
||||
#define TASKf_AWAITING_MSG 8
|
||||
#define TASKf_BREAK_LOCKED 9
|
||||
#define TASKf_PENDING_BREAK 10
|
||||
#define TASKf_BREAK_TO_SHIFT_ESC 11
|
||||
#define TASKf_KILL_AFTER_DBG 12
|
||||
#define TASKf_NONTIMER_RAND 13
|
||||
#define TASKf_CMD_LINE_PMT 4
|
||||
#define TASKf_INPUT_FILTER_TASK 5
|
||||
#define TASKf_FILTER_INPUT 6
|
||||
#define TASKf_HAS_SONG 7
|
||||
#define TASKf_DISABLE_BPTS 8
|
||||
#define TASKf_AWAITING_MSG 9
|
||||
#define TASKf_BREAK_LOCKED 10
|
||||
#define TASKf_PENDING_BREAK 11
|
||||
#define TASKf_BREAK_TO_SHIFT_ESC 12
|
||||
#define TASKf_KILL_AFTER_DBG 13
|
||||
#define TASKf_NONTIMER_RAND 14
|
||||
|
||||
//CTask.display_flags
|
||||
#define DISPLAYf_SHOW 0
|
||||
@@ -3367,7 +3373,8 @@ U0 pad;#assert $$==offset(CTaskDying.wake_jiffy)
|
||||
CExcept *next_except,*last_except;
|
||||
I64 except_rbp, //throw routine's RBP
|
||||
except_ch; //throw(ch)
|
||||
U8 *except_caller1,*except_caller2,*except_caller3,*except_caller4;
|
||||
U8 *except_caller1,*except_caller2,*except_caller3,*except_caller4,
|
||||
*except_caller5,*except_caller6,*except_caller7,*except_caller8;
|
||||
|
||||
Bool catch_except;
|
||||
Bool new_answer;
|
||||
@@ -3595,7 +3602,7 @@ public class CSysFixedArea
|
||||
public class CTextGlbls
|
||||
{
|
||||
I64 raw_col,raw_flags;
|
||||
U8 *raw_screen_image;
|
||||
U8 *raw_scrn_image;
|
||||
I64 rows,cols; //Use TEXT_ROWS,TEXT_COLS
|
||||
U64 *font,*aux_font;
|
||||
U8 *vga_alias,*vga_text_alias;
|
||||
@@ -3609,7 +3616,7 @@ public class CTextGlbls
|
||||
#define GR_WIDTH 640
|
||||
#define GR_HEIGHT 480
|
||||
|
||||
//z-vals less than zero are in front of screen and not drawn.
|
||||
//z-vals less than zero are in front of scrn and not drawn.
|
||||
//we want to shift all Z-vals into a drawable range.
|
||||
//GR_Z_ALL is set to half of the Z-range which is an I32.
|
||||
#define GR_Z_ALL (MAX_I32/2)
|
||||
@@ -3632,7 +3639,7 @@ public class CTextGlbls
|
||||
#define DCF_LOCATE_NEAREST 0x800
|
||||
#define DCF_DONT_DRAW 0x1000
|
||||
#define DCF_ALIAS 0x2000
|
||||
#define DCF_SCREEN_BITMAP 0x4000
|
||||
#define DCF_SCRN_BITMAP 0x4000
|
||||
#define DCF_FILL_NOT_COLOR 0x8000
|
||||
#define DCF_RECORD_EXTENTS 0x10000
|
||||
#define DCF_ON_TOP 0x20000
|
||||
@@ -3685,7 +3692,8 @@ public class CDC
|
||||
|
||||
//Can be changed from the default $LK,"DCTransform",A="MN:DCTransform"$()
|
||||
U0 (*transform)(CDC *dc,I64 *x,I64 *y,I64 *z);
|
||||
//Can be changed from the default $LK,"DCLighting",A="MN:DCLighting"$()
|
||||
|
||||
//Can be changed from the default $LK,"DCLighting",A="MN:DCLighting"$()
|
||||
U0 (*lighting)(CDC *dc,CD3I32 *p1,CD3I32 *p2,
|
||||
CD3I32 *p3,CColorROPU32 color);
|
||||
|
||||
@@ -3700,7 +3708,7 @@ public class CDC
|
||||
I64 collision_cnt;
|
||||
|
||||
//Set by $LK,"DCF_RECORD_EXTENTS",A="MN:DCF_RECORD_EXTENTS"$
|
||||
I64 min_x,max_x,min_y,max_y; //screen coordinates
|
||||
I64 min_x,max_x,min_y,max_y; //scrn coordinates
|
||||
|
||||
U32 dc_signature,pad;
|
||||
CTask *mem_task,*win_task;
|
||||
@@ -3885,7 +3893,7 @@ public class CDbgGlbls
|
||||
#define BOOT_SRC_HARDDRV 3
|
||||
#define BOOT_SRC_DVD 4
|
||||
|
||||
// $LK,"Auto",A="MN:Auto"$("") StdIn for call to $LK,"BootHDIns",A="MN:BootHDIns"$().
|
||||
// $LK,"In",A="MN:In"$("") StdIn for call to $LK,"BootHDIns",A="MN:BootHDIns"$().
|
||||
#define STD_DISTRO_DVD_CFG "Tb\nScale2Mem(2048,0x40000)\nt \n\n\n\n"
|
||||
|
||||
#help_index "Misc/Registry"
|
||||
@@ -3908,17 +3916,17 @@ class CProgress
|
||||
};
|
||||
|
||||
#help_index "Char/Operations"
|
||||
#define SPF_PAD_ZERO 0x001
|
||||
#define SPF_LEFT_JUSTIFY 0x002
|
||||
#define SPF_TRUNCATE 0x004
|
||||
#define SPF_COMMA 0x008
|
||||
#define SPF_DOLLAR 0x010
|
||||
#define SPF_SLASH 0x020
|
||||
#define SPF_QUESTION 0x040
|
||||
#define SPF_AUX_FMT_NUM 0x080
|
||||
#define SPF_DECIMAL 0x100
|
||||
#define SPF_NEG 0x200
|
||||
#define SPF_NEG_E 0x400
|
||||
#define SPF_NEG_AUX_FMT_NUM 0x800
|
||||
#define PRTF_PAD_ZERO 0x001
|
||||
#define PRTF_LEFT_JUSTIFY 0x002
|
||||
#define PRTF_TRUNCATE 0x004
|
||||
#define PRTF_COMMA 0x008
|
||||
#define PRTF_DOLLAR 0x010
|
||||
#define PRTF_SLASH 0x020
|
||||
#define PRTF_QUESTION 0x040
|
||||
#define PRTF_AUX_FMT_NUM 0x080
|
||||
#define PRTF_DECIMAL 0x100
|
||||
#define PRTF_NEG 0x200
|
||||
#define PRTF_NEG_E 0x400
|
||||
#define PRTF_NEG_AUX_FMT_NUM 0x800
|
||||
|
||||
#help_index ""
|
||||
+29
-28
@@ -181,6 +181,7 @@ public extern I64 B2(CTask *task=NULL,Bool live=TRUE);
|
||||
extern CBpt *BptFind(U8 *needle_addr,CTask *haystack_task=NULL,Bool rem=FALSE);
|
||||
public extern Bool BptR(U8 *addr,CTask *task=NULL,Bool live=TRUE,Bool rem=TRUE);
|
||||
public extern Bool BptS(U8 *addr,CTask *task=NULL,Bool live=TRUE);
|
||||
public extern Bool DbgMode(Bool val);
|
||||
public extern Bool E(U8 *addr,I64 cnt=512,I64 edf_dof_flags=0);
|
||||
public extern Bool EdLite(U8 *filename,I64 num=1,I64 edf_dof_flags=0);
|
||||
extern Bool EdLiteFileLine(U8 *fl_file_line,I64 edf_dof_flags=0);
|
||||
@@ -188,8 +189,7 @@ public extern Bool Fix(I64 edf_dof_flags=0);
|
||||
public extern U0 FixSet(U8 *filename,I64 line);
|
||||
public extern U0 G(U8 *ip=INVALID_PTR,CTask *task=NULL);
|
||||
public extern U0 G2(U8 *ip=INVALID_PTR,CTask *task=NULL);
|
||||
public extern Bool InDbg(Bool val);
|
||||
public extern Bool IsDbg();
|
||||
public extern Bool IsDbgMode();
|
||||
public extern U0 S(U8 *ip=INVALID_PTR,CTask *task=NULL);
|
||||
|
||||
#help_index "Debugging/Debugger;DolDoc/Cmd Line (Typically);"\
|
||||
@@ -289,7 +289,7 @@ public extern Bool MkDir(U8 *filename,I64 entry_cnt=0);
|
||||
public extern Bool DrvMap(U8 drv_let,CDrv *dv);
|
||||
|
||||
#help_index "File/FileNames"
|
||||
extern CDirEntry *Cd2DirEntry(CDirEntry *tempde,U8 *abs_name);
|
||||
extern CDirEntry *Cd2DirEntry(CDirEntry *tmpde,U8 *abs_name);
|
||||
public extern U8 *ChgExt(U8 *filename,U8 *extension);
|
||||
public extern U8 *CurDir(CTask *task=NULL,CTask *mem_task=NULL);
|
||||
public extern U8 *DftExt(U8 *filename,U8 *extension);
|
||||
@@ -310,15 +310,16 @@ public extern U0 PutFileLink(U8 *filename,U8 *full_name=NULL,
|
||||
I64 line=0,Bool plain_text=FALSE);
|
||||
public extern U0 ToFileLine(U8 *_fl_file_line,U8 **_filename,I64 *_linenum);
|
||||
public extern U8 *ToggleZorNotZ(U8 *name);
|
||||
|
||||
#help_index "File/FileNames;Misc"
|
||||
public extern U8 *FileNameTempTxt();
|
||||
public extern U8 *FileNameTmpTxt();
|
||||
|
||||
#help_index "File/Internal"
|
||||
public extern U0 DirContextDel(CDirContext *dirc);
|
||||
public extern U0 DirContextDel(CDirContext *dirc,Bool restore=TRUE);
|
||||
public extern CDirContext *DirContextNew(U8 *mask,
|
||||
Bool make_mask=FALSE,Bool make_dirs=FALSE,Bool no_mask=FALSE);
|
||||
public extern Bool DirNew(CDrv *dv,U8 *cur_dir,
|
||||
CDirEntry *tempde,Bool free_old_chain=TRUE);
|
||||
CDirEntry *tmpde,Bool free_old_chain=TRUE);
|
||||
extern I64 FileAttr(U8 *name,I64 old_attr=0);
|
||||
|
||||
#help_index "File/Low Level"
|
||||
@@ -361,10 +362,10 @@ public extern I64 WClustersBlks(CDrv *dv,U8 *buf,I64 c,I64 blks);
|
||||
public extern U0 WZeroBlks(CDrv *dv,I64 blk,I64 cnt);
|
||||
|
||||
#help_index "File/Program Routines"
|
||||
public extern U0 DirEntryDel(CDirEntry *tempde);
|
||||
public extern U0 DirEntryDel2(CDirEntry *tempde);
|
||||
public extern U0 DirTreeDel(CDirEntry *tempde);
|
||||
public extern U0 DirTreeDel2(CDirEntry *tempde);
|
||||
public extern U0 DirEntryDel(CDirEntry *tmpde);
|
||||
public extern U0 DirEntryDel2(CDirEntry *tmpde);
|
||||
public extern U0 DirTreeDel(CDirEntry *tmpde);
|
||||
public extern U0 DirTreeDel2(CDirEntry *tmpde);
|
||||
public extern Bool FileFind(U8 *filename,CDirEntry *_de=NULL,I64 fuf_flags=0);
|
||||
public extern U8 *FileRead(U8 *filename,I64 *_size=NULL,I64 *_attr=NULL);
|
||||
public extern I64 FileWrite(U8 *filename,
|
||||
@@ -393,11 +394,10 @@ extern U0 (*fp_set_std_palette)();
|
||||
public extern U8 *Color2Str(U8 *buf,CColorROPU32 c);
|
||||
public extern CColorROPU16 Str2ColorU16(U8 *st);
|
||||
public extern CColorROPU32 Str2ColorU32(U8 *st);
|
||||
|
||||
#help_index "Hash"
|
||||
#help_file "::/Doc/Hash"
|
||||
public _extern _HASH_ADD U0 HashAdd(CHash *temph,CHashTable *table);
|
||||
public _extern _HASH_ADD_AFTER U0 HashAddAfter(CHash *temph,
|
||||
public _extern _HASH_ADD U0 HashAdd(CHash *tmph,CHashTable *table);
|
||||
public _extern _HASH_ADD_AFTER U0 HashAddAfter(CHash *tmph,
|
||||
CHash *pred,CHashTable *table); //Add hash entry after entry.
|
||||
public _extern _HASH_BUCKET_FIND CHash **HashBucketFind(
|
||||
U8 *needle_str,CHashTable *haystack_table);
|
||||
@@ -416,16 +416,16 @@ public extern I64 FramePtrDel(U8 *name,CTask *task=NULL);
|
||||
public extern I64 FramePtrSet(U8 *name,I64 val,CTask *task=NULL);
|
||||
|
||||
#help_index "Hash/System"
|
||||
public extern U0 HashDel(CHashSrcSym *temph);
|
||||
public extern U0 HashDel(CHashSrcSym *tmph);
|
||||
public extern CHashGeneric *HashGenericAdd(U8 *name,
|
||||
I64 type,I64 val=0,I64 u8=0,I64 u16=0,CTask *task=NULL);
|
||||
public extern CHashGeneric *HashPublic(U8 *st,I64 mask,Bool val=TRUE);
|
||||
public _extern _HASH_REM_DEL Bool HashRemDel(CHash *temph,CHashTable *table,
|
||||
I64 instance=1);//instance must match temph's
|
||||
public _extern _HASH_REM_DEL Bool HashRemDel(CHash *tmph,CHashTable *table,
|
||||
I64 instance=1);//instance must match tmph's
|
||||
public extern U0 HashTableDel(CHashTable *table);
|
||||
public extern I64 HashTablePurge(CHashTable *table);
|
||||
public extern I64 HashTypeNum(CHash *temph);
|
||||
public extern I64 HashVal(CHash *temph);
|
||||
public extern I64 HashTypeNum(CHash *tmph);
|
||||
public extern I64 HashVal(CHash *tmph);
|
||||
extern U0 SysSymImportsResolve(U8 *sptr,I64 ld_flags=0);
|
||||
|
||||
#help_index "Hash/System;Char/Lists"
|
||||
@@ -476,7 +476,7 @@ public extern U0 CtrlAltCBSet(U8 ch,U0 (*fp_handler)(I64 sc),
|
||||
public extern U0 KeyDescSet(U8 *fmt,...);
|
||||
public extern CKeyDevEntry *KeyDevAdd(Bool (*fp_put_key)(I64 ch,I64 sc),
|
||||
Bool (*fp_puts)(U8 *st),I64 priority,Bool key_descs=FALSE);
|
||||
public extern U0 KeyDevRem(CKeyDevEntry *tempp);
|
||||
public extern U0 KeyDevRem(CKeyDevEntry *tmpk);
|
||||
extern CKeyDevGlbls keydev;
|
||||
extern CSrvCmd sys_macro_head;
|
||||
extern CTask *sys_macro_task;
|
||||
@@ -623,6 +623,7 @@ public extern U0 Beep(I64 freq=500,Bool busy=FALSE);
|
||||
public extern Bool IsMute();
|
||||
public extern Bool Mute(Bool val);
|
||||
public extern U0 Snd(F64 freq);
|
||||
public extern U0 SndRst();
|
||||
public extern CSndGlbls snd;
|
||||
|
||||
#help_index "StdIn"
|
||||
@@ -632,8 +633,8 @@ public extern CSndGlbls snd;
|
||||
#help_file "::/Doc/Streams"
|
||||
|
||||
#help_index "Task"
|
||||
public extern U0 BirthWait(CTask **_task,I64 task_num=-1);
|
||||
public extern U0 DeathWait(CTask **_task);
|
||||
public extern I64 BirthWait(CTask **_task,I64 task_num=-1);
|
||||
public extern U0 DeathWait(CTask **_task,Bool send_exit=FALSE);
|
||||
public extern U0 Exit();
|
||||
public extern Bool IsSuspended(CTask *task=NULL);
|
||||
public extern Bool Kill(CTask *task,Bool wait=TRUE);
|
||||
@@ -644,13 +645,13 @@ extern U0 TaskKillDying();
|
||||
public extern U0 TaskQueIns(CTask *task,CTask *pred=NULL);
|
||||
public extern U0 TaskQueRem(CTask *task);
|
||||
public extern Bool TaskValidate(CTask *task);
|
||||
public extern U0 TaskWait(CTask *task=NULL);
|
||||
public extern U0 TaskWait(CTask *task=NULL,Bool cmd_line_pmt=FALSE);
|
||||
public extern CTask *User(U8 *fmt=NULL,...);
|
||||
public extern U0 UserCmdLine();
|
||||
public _extern _YIELD U0 Yield();
|
||||
public extern CTask *adam_task;
|
||||
public extern I64 sys_num_spawned_tasks;
|
||||
extern CTask *sys_winmgr_task,*sys_task_being_screen_updated;
|
||||
extern CTask *sys_winmgr_task,*sys_task_being_scrn_updated;
|
||||
|
||||
#help_index "Task/Delay;Time/CPU Cycles"
|
||||
public extern U0 BusyWait(I64 æS); //Loosely timed
|
||||
@@ -674,7 +675,7 @@ public extern U0 WinDerivedValsUpdate(CTask *task);
|
||||
public extern U0 AdamErr(U8 *fmt,...);
|
||||
public extern U0 AdamLog(U8 *fmt,...);
|
||||
public extern I64 ExeCmdLine(CCmpCtrl *cc);
|
||||
public extern U0 SrvCmdDel(CSrvCmd *tempc);
|
||||
public extern U0 SrvCmdDel(CSrvCmd *tmpc);
|
||||
extern U0 SrvCmdLine();
|
||||
public extern I64 SrvCmdsHandler(I64 run_flags,CTask *task=NULL);
|
||||
public extern U0 SrvTaskCont();
|
||||
@@ -694,10 +695,10 @@ public extern Bool JobResScan(CSrvCmd *rqst=NULL,I64 *_res=NULL);
|
||||
#help_index "Task/Srv/Text & Msgs"
|
||||
public extern CSrvCmd *TaskText(CTask *srv,CTask *master,U8 *data,I64 flags);
|
||||
|
||||
#help_index "Task/Srv/Text & Msgs;AutoFile;StdIn/AutoFile"
|
||||
public extern U0 Auto(U8 *fmt,...);
|
||||
public extern U0 AutoFile(U8 *filename);
|
||||
public extern U0 AutoStr(U8 *fmt,...);
|
||||
#help_index "Task/Srv/Text & Msgs;InFile;StdIn/InFile"
|
||||
public extern U0 In(U8 *fmt,...);
|
||||
public extern U0 InFile(U8 *filename);
|
||||
public extern U0 InStr(U8 *fmt,...);
|
||||
public extern U0 XTalk(CTask *task,U8 *fmt,...);
|
||||
public extern U0 XTalkStr(CTask *task,U8 *fmt,...);
|
||||
public extern U0 XTalkStrWait(CTask *task,U8 *fmt,...);
|
||||
|
||||
+28
-28
@@ -1,17 +1,17 @@
|
||||
U0 PutKey(I64 ch=0,I64 sc=0)
|
||||
{//See $LK,"Keyboard Devices",A="HI:Keyboard Devices/System"$.
|
||||
CKeyDevEntry *tempp;
|
||||
CKeyDevEntry *tmpk;
|
||||
if (ch||sc) {
|
||||
tempp=keydev.put_key_head.next;
|
||||
tmpk=keydev.put_key_head.next;
|
||||
if (!Bt(&Fs->display_flags,DISPLAYf_SILENT)) {
|
||||
if (kbd.scan_code & SCF_SCROLL && sys_focus_task==Fs)
|
||||
while (kbd.scan_code & SCF_SCROLL)
|
||||
Yield; //Wait on SCROLL LOCK Key
|
||||
while (tempp!=&keydev.put_key_head) {
|
||||
if ((!(sc&SCF_KEY_DESC) || tempp->flags & KDF_HAS_DESCS) &&
|
||||
(*tempp->put_key)(ch,sc))
|
||||
while (tmpk!=&keydev.put_key_head) {
|
||||
if ((!(sc&SCF_KEY_DESC) || tmpk->flags & KDF_HAS_DESCS) &&
|
||||
(*tmpk->put_key)(ch,sc))
|
||||
break;
|
||||
tempp=tempp->next;
|
||||
tmpk=tmpk->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,22 +33,22 @@ U0 PutS(U8 *st)
|
||||
U8 *ptr;
|
||||
Bool cont=TRUE;
|
||||
if (!st) return;
|
||||
CKeyDevEntry *tempp=keydev.put_key_head.next;
|
||||
CKeyDevEntry *tmpk=keydev.put_key_head.next;
|
||||
if (!Bt(&Fs->display_flags,DISPLAYf_SILENT)) {
|
||||
if (kbd.scan_code & SCF_SCROLL && sys_focus_task==Fs)
|
||||
while (kbd.scan_code & SCF_SCROLL)
|
||||
Yield;
|
||||
while (cont && tempp!=&keydev.put_key_head) {
|
||||
if (tempp->put_s) {
|
||||
if ((*tempp->put_s)(st))
|
||||
while (cont && tmpk!=&keydev.put_key_head) {
|
||||
if (tmpk->put_s) {
|
||||
if ((*tmpk->put_s)(st))
|
||||
break;
|
||||
} else {
|
||||
ptr=st;
|
||||
while (ch=*ptr++)
|
||||
if ((*tempp->put_key)(ch,0))
|
||||
if ((*tmpk->put_key)(ch,0))
|
||||
cont=FALSE;
|
||||
}
|
||||
tempp=tempp->next;
|
||||
tmpk=tmpk->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -61,28 +61,28 @@ U0 KeyDescSet(U8 *fmt,...)
|
||||
Free(buf);
|
||||
}
|
||||
|
||||
U0 KeyDevRem(CKeyDevEntry *tempp)
|
||||
U0 KeyDevRem(CKeyDevEntry *tmpk)
|
||||
{//Remove StdOut hook and free.
|
||||
QueRem(tempp);
|
||||
Free(tempp);
|
||||
QueRem(tmpk);
|
||||
Free(tmpk);
|
||||
}
|
||||
|
||||
CKeyDevEntry *KeyDevAdd(Bool (*fp_put_key)(I64 ch,I64 sc),
|
||||
Bool (*fp_puts)(U8 *st),I64 priority,Bool key_descs=FALSE)
|
||||
{//Places hook in StdOut chain. See $LK,"Keyboard Devices",A="HI:Keyboard Devices/System"$.
|
||||
CKeyDevEntry *tempp=keydev.put_key_head.last,
|
||||
*tempp1=ACAlloc(sizeof(CKeyDevEntry));
|
||||
tempp1->put_key=fp_put_key;
|
||||
tempp1->put_s=fp_puts;
|
||||
tempp1->priority=priority;
|
||||
CKeyDevEntry *tmpk=keydev.put_key_head.last,
|
||||
*tmpk1=ACAlloc(sizeof(CKeyDevEntry));
|
||||
tmpk1->put_key=fp_put_key;
|
||||
tmpk1->put_s=fp_puts;
|
||||
tmpk1->priority=priority;
|
||||
if (key_descs)
|
||||
tempp1->flags|=KDF_HAS_DESCS;
|
||||
while (tempp->priority>priority)
|
||||
tempp=tempp->last;
|
||||
QueIns(tempp1,tempp);
|
||||
if (tempp->priority==priority)
|
||||
KeyDevRem(tempp);
|
||||
return tempp1;
|
||||
tmpk1->flags|=KDF_HAS_DESCS;
|
||||
while (tmpk->priority>priority)
|
||||
tmpk=tmpk->last;
|
||||
QueIns(tmpk1,tmpk);
|
||||
if (tmpk->priority==priority)
|
||||
KeyDevRem(tmpk);
|
||||
return tmpk1;
|
||||
}
|
||||
|
||||
Bool KDRawPutKey(I64 ch,I64)
|
||||
@@ -137,7 +137,7 @@ U0 CtrlAltC(I64)
|
||||
|
||||
U0 CtrlAltD(I64)
|
||||
{
|
||||
if (!IsDbg) {
|
||||
if (!IsDbgMode) {
|
||||
if (Fs==Gs->idle_task)
|
||||
BptS(sys_winmgr_task->rip,sys_winmgr_task);
|
||||
else
|
||||
|
||||
+55
-55
@@ -1,55 +1,55 @@
|
||||
Bool Mem32DevIns(CMemRange *tempmr)
|
||||
Bool Mem32DevIns(CMemRange *tmpmr)
|
||||
{
|
||||
CMemRange *tempmr1=dev.mem32_head.next,*tempmr2;
|
||||
while (tempmr1!=&dev.mem32_head) {
|
||||
if (!tempmr1->type && tempmr->base>=tempmr1->base &&
|
||||
tempmr->base+tempmr->size<=tempmr1->base+tempmr1->size) {
|
||||
if (tempmr->base>tempmr1->base) {
|
||||
tempmr2=AMAlloc(sizeof(CMemRange));
|
||||
tempmr2->type=MRT_UNUSED;
|
||||
tempmr2->flags=0;
|
||||
tempmr2->base=tempmr1->base;
|
||||
tempmr2->size=tempmr->base-tempmr1->base;
|
||||
QueInsRev(tempmr2,tempmr1);
|
||||
CMemRange *tmpmr1=dev.mem32_head.next,*tmpmr2;
|
||||
while (tmpmr1!=&dev.mem32_head) {
|
||||
if (!tmpmr1->type && tmpmr->base>=tmpmr1->base &&
|
||||
tmpmr->base+tmpmr->size<=tmpmr1->base+tmpmr1->size) {
|
||||
if (tmpmr->base>tmpmr1->base) {
|
||||
tmpmr2=AMAlloc(sizeof(CMemRange));
|
||||
tmpmr2->type=MRT_UNUSED;
|
||||
tmpmr2->flags=0;
|
||||
tmpmr2->base=tmpmr1->base;
|
||||
tmpmr2->size=tmpmr->base-tmpmr1->base;
|
||||
QueInsRev(tmpmr2,tmpmr1);
|
||||
}
|
||||
QueInsRev(tempmr,tempmr1);
|
||||
tempmr1->size=tempmr1->base+tempmr1->size-
|
||||
(tempmr->base+tempmr->size);
|
||||
tempmr1->base=tempmr->base+tempmr->size;
|
||||
if (!tempmr1->size) {
|
||||
QueRem(tempmr1);
|
||||
Free(tempmr1);
|
||||
QueInsRev(tmpmr,tmpmr1);
|
||||
tmpmr1->size=tmpmr1->base+tmpmr1->size-
|
||||
(tmpmr->base+tmpmr->size);
|
||||
tmpmr1->base=tmpmr->base+tmpmr->size;
|
||||
if (!tmpmr1->size) {
|
||||
QueRem(tmpmr1);
|
||||
Free(tmpmr1);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
tempmr1=tempmr1->next;
|
||||
tmpmr1=tmpmr1->next;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
U0 Mem32DevInit()
|
||||
{
|
||||
CMemRange *tempmr;
|
||||
CMemRange *tmpmr;
|
||||
CMemE820 *m20=SYS_MEM_E820;
|
||||
|
||||
QueInit(&dev.mem32_head);
|
||||
tempmr=AMAlloc(sizeof(CMemRange));
|
||||
tempmr->type=MRT_UNUSED;
|
||||
tempmr->flags=0;
|
||||
tmpmr=AMAlloc(sizeof(CMemRange));
|
||||
tmpmr->type=MRT_UNUSED;
|
||||
tmpmr->flags=0;
|
||||
//Maybe !!! Change this to 0xF0000000 !!!
|
||||
tempmr->base=0xE0000000;
|
||||
tempmr->size=0x10000000;
|
||||
QueIns(tempmr,dev.mem32_head.last);
|
||||
tmpmr->base=0xE0000000;
|
||||
tmpmr->size=0x10000000;
|
||||
QueIns(tmpmr,dev.mem32_head.last);
|
||||
|
||||
if (m20->type) {
|
||||
while (m20->type) {
|
||||
tempmr=AMAlloc(sizeof(CMemRange));
|
||||
tempmr->type=m20->type;
|
||||
tempmr->flags=0;
|
||||
tempmr->base=m20->base;
|
||||
tempmr->size=m20->len;
|
||||
if (!Mem32DevIns(tempmr))
|
||||
Free(tempmr);
|
||||
tmpmr=AMAlloc(sizeof(CMemRange));
|
||||
tmpmr->type=m20->type;
|
||||
tmpmr->flags=0;
|
||||
tmpmr->base=m20->base;
|
||||
tmpmr->size=m20->len;
|
||||
if (!Mem32DevIns(tmpmr))
|
||||
Free(tmpmr);
|
||||
m20++;
|
||||
}
|
||||
}
|
||||
@@ -83,29 +83,29 @@ U8 *Mem32DevAlloc(I64 size,I64 alignment)
|
||||
//For this to work the BIOS E820 map must be searched for gaps in
|
||||
//the 32-bit range and the pool initialized to the gaps.
|
||||
U8 *base,*limit;
|
||||
CMemRange *tempmr,*tempmr1;
|
||||
CMemRange *tmpmr,*tmpmr1;
|
||||
while (LBts(&sys_semas[SYS_SEMA_DEV_MEM],0))
|
||||
Yield;
|
||||
tempmr1=dev.mem32_head.next;
|
||||
while (tempmr1!=&dev.mem32_head) {
|
||||
base=(tempmr1->base+alignment-1)&~(alignment-1);
|
||||
tmpmr1=dev.mem32_head.next;
|
||||
while (tmpmr1!=&dev.mem32_head) {
|
||||
base=(tmpmr1->base+alignment-1)&~(alignment-1);
|
||||
limit=base+size-1;
|
||||
if (!tempmr1->type &&
|
||||
limit<tempmr1->base+tempmr1->size) {
|
||||
tempmr=AMAlloc(sizeof(CMemRange));
|
||||
tempmr->type=MRT_DEV;
|
||||
tempmr->flags=0;
|
||||
tempmr->base=base;
|
||||
tempmr->size=size;
|
||||
if (!Mem32DevIns(tempmr)) {
|
||||
Free(tempmr);
|
||||
if (!tmpmr1->type &&
|
||||
limit<tmpmr1->base+tmpmr1->size) {
|
||||
tmpmr=AMAlloc(sizeof(CMemRange));
|
||||
tmpmr->type=MRT_DEV;
|
||||
tmpmr->flags=0;
|
||||
tmpmr->base=base;
|
||||
tmpmr->size=size;
|
||||
if (!Mem32DevIns(tmpmr)) {
|
||||
Free(tmpmr);
|
||||
LBtr(&sys_semas[SYS_SEMA_DEV_MEM],0);
|
||||
return NULL;
|
||||
}
|
||||
LBtr(&sys_semas[SYS_SEMA_DEV_MEM],0);
|
||||
return tempmr->base;
|
||||
return tmpmr->base;
|
||||
}
|
||||
tempmr1=tempmr1->next;
|
||||
tmpmr1=tmpmr1->next;
|
||||
}
|
||||
LBtr(&sys_semas[SYS_SEMA_DEV_MEM],0);
|
||||
return NULL;
|
||||
@@ -113,17 +113,17 @@ U8 *Mem32DevAlloc(I64 size,I64 alignment)
|
||||
|
||||
U0 Mem32DevFree(U8 *base)
|
||||
{//Free 32-bit device address space.
|
||||
CMemRange *tempmr;
|
||||
CMemRange *tmpmr;
|
||||
if (!base) return;
|
||||
while (LBts(&sys_semas[SYS_SEMA_DEV_MEM],0))
|
||||
Yield;
|
||||
tempmr=dev.mem32_head.next;
|
||||
while (tempmr!=&dev.mem32_head) {
|
||||
if (tempmr->base==base) {
|
||||
tempmr->type=MRT_UNUSED;
|
||||
tmpmr=dev.mem32_head.next;
|
||||
while (tmpmr!=&dev.mem32_head) {
|
||||
if (tmpmr->base==base) {
|
||||
tmpmr->type=MRT_UNUSED;
|
||||
break;
|
||||
}
|
||||
tempmr=tempmr->next;
|
||||
tmpmr=tmpmr->next;
|
||||
}
|
||||
LBtr(&sys_semas[SYS_SEMA_DEV_MEM],0);
|
||||
}
|
||||
|
||||
+20
-20
@@ -217,32 +217,32 @@ CSrvCmd *JobQue(I64 (*fp_addr)(U8 *data),U8 *data=NULL,
|
||||
//Set flags to zero if you wish to get the res.
|
||||
//See $LK,"::/Demo/MultiCore/Lock.HC"$
|
||||
CSrvCtrl *ctrl;
|
||||
CSrvCmd *tempc;
|
||||
CSrvCmd *tmpc;
|
||||
CTask *seth;
|
||||
if (!(0<=target_cpu<mp_cnt))
|
||||
throw('MultCore');
|
||||
tempc=ACAlloc(sizeof(CSrvCmd));
|
||||
tmpc=ACAlloc(sizeof(CSrvCmd));
|
||||
if (aux_str)
|
||||
tempc->aux_str=AStrNew(aux_str);
|
||||
tempc->cmd_code=cmd_code;
|
||||
tempc->addr=fp_addr;
|
||||
tempc->fun_arg=data;
|
||||
tempc->target_cpu=target_cpu;
|
||||
tempc->flags=flags;
|
||||
tempc->aux1=aux1;
|
||||
tempc->aux2=aux2;
|
||||
tmpc->aux_str=AStrNew(aux_str);
|
||||
tmpc->cmd_code=cmd_code;
|
||||
tmpc->addr=fp_addr;
|
||||
tmpc->fun_arg=data;
|
||||
tmpc->target_cpu=target_cpu;
|
||||
tmpc->flags=flags;
|
||||
tmpc->aux1=aux1;
|
||||
tmpc->aux2=aux2;
|
||||
seth=cpu_structs[target_cpu].seth_task;
|
||||
tempc->ctrl=ctrl=&seth->srv_ctrl;
|
||||
tmpc->ctrl=ctrl=&seth->srv_ctrl;
|
||||
PUSHFD
|
||||
CLI
|
||||
while (LBts(&ctrl->flags,SVCRf_LOCKED))
|
||||
Yield;
|
||||
if (ctrl->next_waiting==ctrl && LBtr(&seth->task_flags,TASKf_AWAITING_MSG))
|
||||
MPInt(I_WAKE,target_cpu);
|
||||
QueIns(tempc,ctrl->last_waiting);
|
||||
QueIns(tmpc,ctrl->last_waiting);
|
||||
LBtr(&ctrl->flags,SVCRf_LOCKED);
|
||||
POPFD
|
||||
return tempc;
|
||||
return tmpc;
|
||||
}
|
||||
|
||||
CTask *SpawnQue(U0 (*fp_addr)(U8 *data),U8 *data=NULL,U8 *task_name=NULL,
|
||||
@@ -250,26 +250,26 @@ CTask *SpawnQue(U0 (*fp_addr)(U8 *data),U8 *data=NULL,U8 *task_name=NULL,
|
||||
I64 stk_size=0,I64 flags=1<<SVCf_ADD_TO_QUE)
|
||||
{
|
||||
CTask *res;
|
||||
CSrvCmd *tempc=JobQue(fp_addr,data,target_cpu,
|
||||
CSrvCmd *tmpc=JobQue(fp_addr,data,target_cpu,
|
||||
flags,SVCT_SPAWN_TASK,task_name,parent,stk_size);
|
||||
CSrvCtrl *ctrl;
|
||||
|
||||
while (!Bt(&tempc->flags,SVCf_DONE)) {
|
||||
while (!Bt(&tmpc->flags,SVCf_DONE)) {
|
||||
LBts(&Fs->task_flags,TASKf_IDLE);
|
||||
Yield;
|
||||
}
|
||||
LBtr(&Fs->task_flags,TASKf_IDLE);
|
||||
|
||||
res=tempc->spawned_task;
|
||||
ctrl=tempc->ctrl;
|
||||
res=tmpc->spawned_task;
|
||||
ctrl=tmpc->ctrl;
|
||||
PUSHFD
|
||||
CLI
|
||||
while (LBts(&ctrl->flags,SVCRf_LOCKED))
|
||||
Yield;
|
||||
QueRem(tempc);
|
||||
QueRem(tmpc);
|
||||
LBtr(&ctrl->flags,SVCRf_LOCKED);
|
||||
POPFD
|
||||
SrvCmdDel(tempc);
|
||||
SrvCmdDel(tmpc);
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -378,7 +378,7 @@ U0 Core0Init()
|
||||
}
|
||||
|
||||
interrupt U0 IntMPCrash()
|
||||
{//Entering the debugger from another core causes an interrupt on core0
|
||||
{//Entering the debugger from another core causes an interrupt on Core0
|
||||
//Which calls this routine.
|
||||
*(dev.uncached_alias+LAPIC_EOI)(U32 *)=0;
|
||||
mp_cnt=1;
|
||||
|
||||
+10
-10
@@ -53,10 +53,10 @@ U0 QSort2a(U8 **base,I64 num,I64 (*fp_compare)(U8 **_e1,U8 **_e2))
|
||||
QSort2a(left,i,fp_compare);
|
||||
}
|
||||
U0 QSort2b(U8 *base,I64 num, I64 width,
|
||||
I64 (*fp_compare)(U8 *e1,U8 *e2),U8 *temp)
|
||||
I64 (*fp_compare)(U8 *e1,U8 *e2),U8 *tmp)
|
||||
{//Not public
|
||||
I64 i;
|
||||
U8 *left,*right,*pivot=temp+width;
|
||||
U8 *left,*right,*pivot=tmp+width;
|
||||
left =base;
|
||||
right=base+(num-1)*width;
|
||||
MemCpy(pivot,base+num/2*width,width);
|
||||
@@ -67,9 +67,9 @@ U0 QSort2b(U8 *base,I64 num, I64 width,
|
||||
right-=width;
|
||||
if (left<=right) {
|
||||
if (left!=right) {
|
||||
MemCpy(temp,right,width);
|
||||
MemCpy(tmp,right,width);
|
||||
MemCpy(right,left,width);
|
||||
MemCpy(left,temp,width);
|
||||
MemCpy(left,tmp,width);
|
||||
}
|
||||
left+=width;
|
||||
right-=width;
|
||||
@@ -77,10 +77,10 @@ U0 QSort2b(U8 *base,I64 num, I64 width,
|
||||
} while (left<=right);
|
||||
i=1+(right-base)/width;
|
||||
if (1<i<num)
|
||||
QSort2b(base,i,width,fp_compare,temp);
|
||||
QSort2b(base,i,width,fp_compare,tmp);
|
||||
i=num+(base-left)/width;
|
||||
if (1<i<num)
|
||||
QSort2b(left,i,width,fp_compare,temp);
|
||||
QSort2b(left,i,width,fp_compare,tmp);
|
||||
}
|
||||
U0 QSort(U8 *base,I64 num, I64 width, I64 (*fp_compare)(U8 *e1,U8 *e2))
|
||||
{/*Quick Sort: fp_compare() passes by ref.
|
||||
@@ -91,14 +91,14 @@ Don't return e1-e2 if numbers can overflow, return -1,0 or 1.
|
||||
|
||||
Maybe, look at $LK,"::/Demo/MultiCore/RadixSort.HC"$.
|
||||
*/
|
||||
U8 *temp;
|
||||
U8 *tmp;
|
||||
if (width && num>1) {
|
||||
if (width==sizeof(U8 *)) //assign instead of MemCpy for width 8
|
||||
QSort2a(base,num,fp_compare);
|
||||
else {
|
||||
temp=MAlloc(width*2);
|
||||
QSort2b(base,num,width,fp_compare,temp);
|
||||
Free(temp);
|
||||
tmp=MAlloc(width*2);
|
||||
QSort2b(base,num,width,fp_compare,tmp);
|
||||
Free(tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*On each core, tasks are linked in a
|
||||
circular doubly-linked list queue with
|
||||
the Seth task as the head. On core0,
|
||||
the Seth task as the head. On Core0,
|
||||
the queue order represents the front-to-back
|
||||
window stack order with the window mgr
|
||||
as the wallpaper.
|
||||
|
||||
+21
-21
@@ -1,6 +1,6 @@
|
||||
U0 InputFilterTask()
|
||||
{
|
||||
CSrvCmd *tempc,*tempc1;
|
||||
CSrvCmd *tmpc,*tmpc1;
|
||||
Bool old_filter;
|
||||
I64 old_flags=GetRFlags;
|
||||
Fs->win_inhibit=WIG_USER_TASK_DFT;
|
||||
@@ -10,19 +10,19 @@ U0 InputFilterTask()
|
||||
while (TRUE) {
|
||||
CLI
|
||||
SrvCmdsHandler(old_flags);
|
||||
tempc1=&Fs->srv_ctrl.next_waiting;
|
||||
tempc=tempc1->next;
|
||||
if (tempc==tempc1)
|
||||
tmpc1=&Fs->srv_ctrl.next_waiting;
|
||||
tmpc=tmpc1->next;
|
||||
if (tmpc==tmpc1)
|
||||
break;
|
||||
else {
|
||||
if (tempc->cmd_code==SVCT_TEXT_INPUT) {
|
||||
QueRem(tempc);
|
||||
if (tmpc->cmd_code==SVCT_TEXT_INPUT) {
|
||||
QueRem(tmpc);
|
||||
SetRFlags(old_flags);
|
||||
try
|
||||
ExePrint("%s",tempc->aux_str);
|
||||
ExePrint("%s",tmpc->aux_str);
|
||||
catch
|
||||
Fs->catch_except=TRUE;
|
||||
SrvCmdDel(tempc);
|
||||
SrvCmdDel(tmpc);
|
||||
} else
|
||||
break;
|
||||
}
|
||||
@@ -42,28 +42,28 @@ Remove desired message, return $LK,"msg_code",A="MN:MSG_CMD"$.
|
||||
Note: This delivers messages from parent down to pop-up.
|
||||
*/
|
||||
I64 res,old_flags;
|
||||
CSrvCmd *tempc,*tempc1;
|
||||
CSrvCmd *tmpc,*tmpc1;
|
||||
if (!task) task=Fs;
|
||||
old_flags=GetRFlags;
|
||||
tempc1=&task->srv_ctrl.next_waiting;
|
||||
tmpc1=&task->srv_ctrl.next_waiting;
|
||||
while (TRUE) {
|
||||
CLI
|
||||
if (task==Fs)
|
||||
SrvCmdsHandler(old_flags);
|
||||
tempc=tempc1->next;
|
||||
if (tempc==tempc1)
|
||||
tmpc=tmpc1->next;
|
||||
if (tmpc==tmpc1)
|
||||
break;
|
||||
else {
|
||||
if (tempc->cmd_code==SVCT_MSG) {
|
||||
QueRem(tempc);
|
||||
if (tmpc->cmd_code==SVCT_MSG) {
|
||||
QueRem(tmpc);
|
||||
SetRFlags(old_flags);
|
||||
res=tempc->msg_code;
|
||||
res=tmpc->msg_code;
|
||||
if (_a1)
|
||||
*_a1=tempc->aux1;
|
||||
*_a1=tmpc->aux1;
|
||||
if (_a2)
|
||||
*_a2=tempc->aux2;
|
||||
SrvCmdDel(tempc);
|
||||
if ((res!=MSG_KEY_DOWN || !(tempc->aux2&SCF_KEY_DESC) ||
|
||||
*_a2=tmpc->aux2;
|
||||
SrvCmdDel(tmpc);
|
||||
if ((res!=MSG_KEY_DOWN || !(tmpc->aux2&SCF_KEY_DESC) ||
|
||||
!Bt(&task->win_inhibit,WIf_SELF_KEY_DESC)) && Bt(&mask,res))
|
||||
goto sm_done;
|
||||
}
|
||||
@@ -156,7 +156,7 @@ I64 GetKey(I64 *_scan_code=NULL,Bool echo=FALSE,Bool raw_cursor=FALSE)
|
||||
}
|
||||
}
|
||||
LBts(&Fs->task_flags,TASKf_IDLE);
|
||||
if (IsDbg) {
|
||||
if (IsDbgMode) {
|
||||
//We don't want interrupt-driven keyboard when in debugger
|
||||
//because that could have side-effects or crash, so we poll
|
||||
//keyboard when in debugger with interrupts off.
|
||||
@@ -222,7 +222,7 @@ I64 GetS(U8 *buf,I64 size,Bool allow_ext=TRUE)
|
||||
Free(st);
|
||||
} else {
|
||||
while (TRUE) {
|
||||
ch=GetChar(,FALSE,IsDbg);
|
||||
ch=GetChar(,FALSE,IsDbgMode);
|
||||
if (ch=='\n') {
|
||||
'' ch;
|
||||
break;
|
||||
|
||||
@@ -108,11 +108,11 @@ Bool MouseRst()
|
||||
|
||||
U0 MouseSpeedSet()
|
||||
{
|
||||
I64 dd,temp;
|
||||
I64 dd,tmp;
|
||||
if ((dd=SqrI64(mouse_last.pos.x-mouse.pos.x)
|
||||
+SqrI64(mouse_last.pos.y-mouse.pos.y)) &&
|
||||
(temp=mouse.timestamp-mouse_last.timestamp))
|
||||
mouse.speed=Sqrt(dd)*cnts.time_stamp_freq/temp;
|
||||
(tmp=mouse.timestamp-mouse_last.timestamp))
|
||||
mouse.speed=Sqrt(dd)*cnts.time_stamp_freq/tmp;
|
||||
mouse_last.timestamp=mouse.timestamp;
|
||||
}
|
||||
|
||||
|
||||
+83
-82
@@ -1,17 +1,17 @@
|
||||
U0 SrvCmdDel(CSrvCmd *tempc)
|
||||
U0 SrvCmdDel(CSrvCmd *tmpc)
|
||||
{//Free one cmd node.
|
||||
Free(tempc->aux_str);
|
||||
Free(tempc);
|
||||
Free(tmpc->aux_str);
|
||||
Free(tmpc);
|
||||
}
|
||||
|
||||
U0 SrvCmdQueDel(CSrvCmd *head)
|
||||
{
|
||||
CSrvCmd *tempc=head->next,*tempc1;
|
||||
while (tempc!=head) {
|
||||
tempc1=tempc->next;
|
||||
QueRem(tempc);
|
||||
SrvCmdDel(tempc);
|
||||
tempc=tempc1;
|
||||
CSrvCmd *tmpc=head->next,*tmpc1;
|
||||
while (tmpc!=head) {
|
||||
tmpc1=tmpc->next;
|
||||
QueRem(tmpc);
|
||||
SrvCmdDel(tmpc);
|
||||
tmpc=tmpc1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,51 +119,51 @@ CSrvCmd *TaskText(CTask *srv,CTask *master,U8 *data,I64 flags)
|
||||
CSrvCmd *TaskMsg(CTask *_srv,CTask *master,I64 msg_code,I64 a1,I64 a2,I64 flags)
|
||||
{//Post message to servant task. Tell who the master task is.
|
||||
//See $LK,"flags",A="MN:SVCf_WAKE_MASTER"$ and $LK,"msg_code",A="MN:MSG_CMD"$.
|
||||
CSrvCmd *tempc1,*tempc;
|
||||
CSrvCmd *tmpc1,*tmpc;
|
||||
CTask *srv=_srv;
|
||||
if (!TaskValidate(srv) || master && !TaskValidate(master)||
|
||||
srv->popup_task && !Bt(&srv->task_flags,TASKf_FILTER_INPUT))
|
||||
return NULL;
|
||||
tempc=ACAlloc(sizeof(CSrvCmd));
|
||||
tempc->master_task=master;
|
||||
tempc->cmd_code=SVCT_MSG;
|
||||
tempc->msg_code=AbsI64(msg_code); //negative means do a down and up
|
||||
tempc->aux1=a1;
|
||||
tempc->aux2=a2;
|
||||
tempc->flags=flags;
|
||||
tmpc=ACAlloc(sizeof(CSrvCmd));
|
||||
tmpc->master_task=master;
|
||||
tmpc->cmd_code=SVCT_MSG;
|
||||
tmpc->msg_code=AbsI64(msg_code); //negative means do a down and up
|
||||
tmpc->aux1=a1;
|
||||
tmpc->aux2=a2;
|
||||
tmpc->flags=flags;
|
||||
PUSHFD
|
||||
if (Bt(&sys_semas[SYS_SEMA_RECORD_MACRO],0) &&
|
||||
srv!=sys_macro_task && msg_code==MSG_KEY_DOWN) {
|
||||
tempc1=AMAllocIdent(tempc);
|
||||
tmpc1=AMAllocIdent(tmpc);
|
||||
CLI
|
||||
QueIns(tempc1,sys_macro_head.last);
|
||||
QueIns(tmpc1,sys_macro_head.last);
|
||||
}
|
||||
CLI
|
||||
while (Bt(&srv->task_flags,TASKf_FILTER_INPUT) &&
|
||||
!Bt(&flags,SVCf_DONT_FILTER))
|
||||
srv=srv->next_input_filter_task;
|
||||
tempc->ctrl=&srv->srv_ctrl;
|
||||
tmpc->ctrl=&srv->srv_ctrl;
|
||||
while (LBts(&srv->srv_ctrl.flags,SVCRf_LOCKED))
|
||||
PAUSE
|
||||
if (!TaskValidate(srv)) {
|
||||
SrvCmdDel(tempc);
|
||||
tempc=NULL;
|
||||
SrvCmdDel(tmpc);
|
||||
tmpc=NULL;
|
||||
} else {
|
||||
LBtr(&srv->task_flags,TASKf_IDLE);
|
||||
TaskRstAwaitingMsg(srv);
|
||||
QueIns(tempc,srv->srv_ctrl.last_waiting);
|
||||
QueIns(tmpc,srv->srv_ctrl.last_waiting);
|
||||
LBtr(&srv->srv_ctrl.flags,SVCRf_LOCKED);
|
||||
}
|
||||
POPFD
|
||||
if (msg_code<0) //Down-Up
|
||||
TaskMsg(_srv,master,-msg_code+1,a1,a2,flags);
|
||||
return tempc;
|
||||
return tmpc;
|
||||
}
|
||||
|
||||
Bool JobResScan(CSrvCmd *rqst=NULL,I64 *_res=NULL)
|
||||
{//Check rqst complete, return with or without.
|
||||
CSrvCtrl *ctrl;
|
||||
CSrvCmd *tempc,*tempc1;
|
||||
CSrvCmd *tmpc,*tmpc1;
|
||||
if (!rqst || Bt(&rqst->flags,SVCf_DONE)) {
|
||||
if (!rqst || rqst->master_task)
|
||||
ctrl=&Fs->srv_ctrl;
|
||||
@@ -173,19 +173,19 @@ Bool JobResScan(CSrvCmd *rqst=NULL,I64 *_res=NULL)
|
||||
CLI
|
||||
while (LBts(&ctrl->flags,SVCRf_LOCKED))
|
||||
PAUSE
|
||||
tempc1=&ctrl->next_done;
|
||||
tempc=tempc1->next;
|
||||
while (tempc!=tempc1) {
|
||||
if (!rqst || rqst==tempc) {
|
||||
QueRem(tempc);
|
||||
tmpc1=&ctrl->next_done;
|
||||
tmpc=tmpc1->next;
|
||||
while (tmpc!=tmpc1) {
|
||||
if (!rqst || rqst==tmpc) {
|
||||
QueRem(tmpc);
|
||||
LBtr(&ctrl->flags,SVCRf_LOCKED);
|
||||
POPFD
|
||||
if (_res)
|
||||
*_res=tempc->res;
|
||||
SrvCmdDel(tempc);
|
||||
*_res=tmpc->res;
|
||||
SrvCmdDel(tmpc);
|
||||
return TRUE;
|
||||
}
|
||||
tempc=tempc->next;
|
||||
tmpc=tmpc->next;
|
||||
}
|
||||
LBtr(&ctrl->flags,SVCRf_LOCKED);
|
||||
POPFD
|
||||
@@ -198,10 +198,10 @@ Bool JobResScan(CSrvCmd *rqst=NULL,I64 *_res=NULL)
|
||||
I64 JobResGet(CSrvCmd *rqst=NULL)
|
||||
{//See $LK,"::/Demo/MultiCore/Lock.HC"$
|
||||
I64 res;
|
||||
CSrvCmd *tempc1;
|
||||
CSrvCmd *tmpc1;
|
||||
if (!rqst) {
|
||||
tempc1=&Fs->srv_ctrl.next_done;
|
||||
while (tempc1==tempc1->next) {
|
||||
tmpc1=&Fs->srv_ctrl.next_done;
|
||||
while (tmpc1==tmpc1->next) {
|
||||
LBts(&Fs->task_flags,TASKf_IDLE);
|
||||
Yield;
|
||||
}
|
||||
@@ -217,19 +217,20 @@ I64 JobResGet(CSrvCmd *rqst=NULL)
|
||||
return res;
|
||||
}
|
||||
|
||||
U0 TaskWait(CTask *task=NULL)
|
||||
U0 TaskWait(CTask *task=NULL,Bool cmd_line_pmt=FALSE)
|
||||
{//Wait for idle.
|
||||
CTask *task1;
|
||||
CSrvCmd *tempc1;
|
||||
CSrvCmd *tmpc1;
|
||||
if (!task) task=Fs;
|
||||
if (TaskValidate(task)) {
|
||||
PUSHFD
|
||||
CLI
|
||||
while (TRUE) {
|
||||
task1=task->last_input_filter_task;
|
||||
tempc1=&task1->srv_ctrl.next_waiting;
|
||||
tmpc1=&task1->srv_ctrl.next_waiting;
|
||||
if (task1==Fs || !TaskValidate(task1) ||
|
||||
tempc1==tempc1->next && Bt(&task1->task_flags,TASKf_IDLE))
|
||||
tmpc1==tmpc1->next && Bt(&task1->task_flags,TASKf_IDLE) &&
|
||||
(!cmd_line_pmt || Bt(&task1->task_flags,TASKf_CMD_LINE_PMT)))
|
||||
break;
|
||||
Yield;
|
||||
}
|
||||
@@ -266,48 +267,48 @@ U0 Msg(I64 msg_code,I64 a1,I64 a2,I64 flags=0)
|
||||
|
||||
I64 SrvCmdRunOne(I64 run_flags,CSrvCtrl *ctrl)
|
||||
{//Called with ctrl->flags,SVCRf_LOCKED.
|
||||
CSrvCmd *tempc=ctrl->next_waiting;
|
||||
CSrvCmd *tmpc=ctrl->next_waiting;
|
||||
CTask *master;
|
||||
I64 res,flags=tempc->flags,old_flags=GetRFlags;
|
||||
I64 res,flags=tmpc->flags,old_flags=GetRFlags;
|
||||
if (Bt(&flags,SVCf_EXIT_ON_COMPLETE))
|
||||
res=SCR_EXIT;
|
||||
else
|
||||
res=SCR_CONT;
|
||||
switch (tempc->cmd_code) {
|
||||
switch (tmpc->cmd_code) {
|
||||
case SVCT_SPAWN_TASK:
|
||||
QueRem(tempc);
|
||||
LBts(&tempc->flags,SVCf_DISPATCHED);
|
||||
tempc->servant_cpu_num=Gs->num;
|
||||
QueRem(tmpc);
|
||||
LBts(&tmpc->flags,SVCf_DISPATCHED);
|
||||
tmpc->servant_cpu_num=Gs->num;
|
||||
LBtr(&ctrl->flags,SVCRf_LOCKED);
|
||||
if (tempc->aux_str)
|
||||
tempc->spawned_task=Spawn(tempc->addr,tempc->fun_arg,
|
||||
tempc->aux_str,,tempc->aux1,tempc->aux2,tempc->flags);
|
||||
if (tmpc->aux_str)
|
||||
tmpc->spawned_task=Spawn(tmpc->addr,tmpc->fun_arg,
|
||||
tmpc->aux_str,,tmpc->aux1,tmpc->aux2,tmpc->flags);
|
||||
else
|
||||
tempc->spawned_task=Spawn(tempc->addr,tempc->fun_arg,
|
||||
"Unnamed",,tempc->aux1,tempc->aux2,tempc->flags);
|
||||
tmpc->spawned_task=Spawn(tmpc->addr,tmpc->fun_arg,
|
||||
"Unnamed",,tmpc->aux1,tmpc->aux2,tmpc->flags);
|
||||
break;
|
||||
case SVCT_CALL:
|
||||
QueRem(tempc);
|
||||
LBts(&tempc->flags,SVCf_DISPATCHED);
|
||||
tempc->servant_cpu_num=Gs->num;
|
||||
QueRem(tmpc);
|
||||
LBts(&tmpc->flags,SVCf_DISPATCHED);
|
||||
tmpc->servant_cpu_num=Gs->num;
|
||||
LBtr(&ctrl->flags,SVCRf_LOCKED);
|
||||
SetRFlags(run_flags);
|
||||
LBtr(&Fs->task_flags,TASKf_IDLE);
|
||||
try
|
||||
tempc->res=(*tempc->addr)(tempc->fun_arg);
|
||||
tmpc->res=(*tmpc->addr)(tmpc->fun_arg);
|
||||
catch
|
||||
Fs->catch_except=TRUE;
|
||||
SetRFlags(old_flags);
|
||||
break;
|
||||
case SVCT_EXE_STR:
|
||||
QueRem(tempc);
|
||||
LBts(&tempc->flags,SVCf_DISPATCHED);
|
||||
tempc->servant_cpu_num=Gs->num;
|
||||
QueRem(tmpc);
|
||||
LBts(&tmpc->flags,SVCf_DISPATCHED);
|
||||
tmpc->servant_cpu_num=Gs->num;
|
||||
LBtr(&ctrl->flags,SVCRf_LOCKED);
|
||||
SetRFlags(run_flags);
|
||||
LBtr(&Fs->task_flags,TASKf_IDLE);
|
||||
try
|
||||
tempc->res=ExePrint("%s",tempc->aux_str);
|
||||
tmpc->res=ExePrint("%s",tmpc->aux_str);
|
||||
catch
|
||||
Fs->catch_except=TRUE;
|
||||
SetRFlags(old_flags);
|
||||
@@ -316,13 +317,13 @@ I64 SrvCmdRunOne(I64 run_flags,CSrvCtrl *ctrl)
|
||||
res=SCR_DONE;
|
||||
}
|
||||
if (res) {
|
||||
if (master=tempc->master_task) {
|
||||
if (master=tmpc->master_task) {
|
||||
if (!Bt(&flags,SVCf_FREE_ON_COMPLETE)) {
|
||||
CLI
|
||||
while (LBts(&master->srv_ctrl.flags,SVCRf_LOCKED))
|
||||
PAUSE
|
||||
QueIns(tempc,master->srv_ctrl.last_done);
|
||||
LBts(&tempc->flags,SVCf_DONE);
|
||||
QueIns(tmpc,master->srv_ctrl.last_done);
|
||||
LBts(&tmpc->flags,SVCf_DONE);
|
||||
LBtr(&master->srv_ctrl.flags,SVCRf_LOCKED);
|
||||
SetRFlags(old_flags);
|
||||
}
|
||||
@@ -333,13 +334,13 @@ I64 SrvCmdRunOne(I64 run_flags,CSrvCtrl *ctrl)
|
||||
Suspend(master,FALSE);
|
||||
}
|
||||
if (Bt(&flags,SVCf_FREE_ON_COMPLETE))
|
||||
SrvCmdDel(tempc);
|
||||
SrvCmdDel(tmpc);
|
||||
else if (!master) {
|
||||
CLI
|
||||
while (LBts(&ctrl->flags,SVCRf_LOCKED))
|
||||
Yield;
|
||||
QueIns(tempc,ctrl->last_done);
|
||||
LBts(&tempc->flags,SVCf_DONE);
|
||||
QueIns(tmpc,ctrl->last_done);
|
||||
LBts(&tmpc->flags,SVCf_DONE);
|
||||
LBtr(&ctrl->flags,SVCRf_LOCKED);
|
||||
SetRFlags(old_flags);
|
||||
}
|
||||
@@ -377,7 +378,7 @@ sch_done:
|
||||
I64 PopUp(U8 *buf,CTask *parent=NULL,CTask **_pu_task=NULL)
|
||||
{//Execute code in $LK,"PopUp",A="MN:PopUp"$ task.
|
||||
I64 res;
|
||||
CSrvCmd *tempc;
|
||||
CSrvCmd *tmpc;
|
||||
CTask *task=Spawn(&SrvCmdLine,NULL,"Servant",,parent);
|
||||
if (!parent) {
|
||||
TaskExe(task,parent,buf,1<<SVCf_EXIT_ON_COMPLETE|1<<SVCf_FREE_ON_COMPLETE);
|
||||
@@ -385,9 +386,9 @@ I64 PopUp(U8 *buf,CTask *parent=NULL,CTask **_pu_task=NULL)
|
||||
return 0;
|
||||
} else {
|
||||
Fs->popup_task=task;
|
||||
tempc=TaskExe(task,parent,buf,1<<SVCf_WAKE_MASTER|1<<SVCf_FOCUS_MASTER);
|
||||
tmpc=TaskExe(task,parent,buf,1<<SVCf_WAKE_MASTER|1<<SVCf_FOCUS_MASTER);
|
||||
if (_pu_task) *_pu_task=task;
|
||||
JobResScan(tempc,&res);
|
||||
JobResScan(tmpc,&res);
|
||||
Fs->popup_task=NULL;
|
||||
Kill(task);
|
||||
if (_pu_task) *_pu_task=NULL;
|
||||
@@ -408,15 +409,15 @@ I64 Adam(U8 *fmt,...)
|
||||
{//Make adam_task execute code.
|
||||
I64 res;
|
||||
U8 *buf=StrPrintJoin(NULL,fmt,argc,argv);
|
||||
CSrvCmd *tempc;
|
||||
CSrvCmd *tmpc;
|
||||
if (Fs==adam_task) {
|
||||
tempc=TaskExe(adam_task,Fs,buf,0);
|
||||
tmpc=TaskExe(adam_task,Fs,buf,0);
|
||||
SrvCmdsHandler(GetRFlags);
|
||||
} else {
|
||||
TaskWait(adam_task);
|
||||
tempc=TaskExe(adam_task,Fs,buf,1<<SVCf_WAKE_MASTER);
|
||||
tmpc=TaskExe(adam_task,Fs,buf,1<<SVCf_WAKE_MASTER);
|
||||
}
|
||||
JobResScan(tempc,&res);
|
||||
JobResScan(tmpc,&res);
|
||||
Free(buf);
|
||||
return res;
|
||||
}
|
||||
@@ -462,8 +463,8 @@ U0 XTalkWait(CTask *task,U8 *fmt,...)
|
||||
TaskWait(task);
|
||||
}
|
||||
|
||||
U0 AutoStr(U8 *fmt,...)
|
||||
{//Send AutoFile code to self.
|
||||
U0 InStr(U8 *fmt,...)
|
||||
{//Send InFile code to self.
|
||||
U8 *buf=StrPrintJoin(NULL,fmt,argc,argv);
|
||||
if (Bt(&Fs->task_flags,TASKf_INPUT_FILTER_TASK))
|
||||
ExePrint("%s",buf);
|
||||
@@ -472,30 +473,30 @@ U0 AutoStr(U8 *fmt,...)
|
||||
Free(buf);
|
||||
}
|
||||
|
||||
U0 AutoFile(U8 *filename)
|
||||
{//Send AutoFile code file to self.
|
||||
U8 *name=DftExt(filename,"AUT.Z");
|
||||
AutoStr("Cd(\"%C:%s\");;#include \"%s\"",
|
||||
U0 InFile(U8 *filename)
|
||||
{//Send InFile code file to self.
|
||||
U8 *name=DftExt(filename,"IN.Z");
|
||||
InStr("Cd(\"%C:%s\");;#include \"%s\"",
|
||||
Drv2Let(Fs->cur_dv),Fs->cur_dir,name);
|
||||
Free(name);
|
||||
}
|
||||
|
||||
U0 Auto(U8 *fmt,...)
|
||||
U0 In(U8 *fmt,...)
|
||||
{//Send text to own input buffer. See $LK,"::/Demo/AcctExample/TOSDistro.HC"$.
|
||||
U8 *buf=StrPrintJoin(NULL,fmt,argc,argv),*st=AStrNew(buf);
|
||||
AutoStr("\"%%s\",%d;Free(%d);",st,st);
|
||||
InStr("\"%%s\",%d;Free(%d);",st,st);
|
||||
Free(buf);
|
||||
}
|
||||
|
||||
U0 XTalkStr(CTask *task,U8 *fmt,...)
|
||||
{//Send AutoFile code to other task.
|
||||
{//Send InFile code to other task.
|
||||
U8 *buf=StrPrintJoin(NULL,fmt,argc,argv);
|
||||
TaskText(task,NULL,buf,0);
|
||||
Free(buf);
|
||||
}
|
||||
|
||||
U0 XTalkStrWait(CTask *task,U8 *fmt,...)
|
||||
{//Send AutoFile code to other task and wait for it to idle.
|
||||
{//Send InFile code to other task and wait for it to idle.
|
||||
U8 *buf=StrPrintJoin(NULL,fmt,argc,argv);
|
||||
TaskText(task,NULL,buf,0);
|
||||
Free(buf);
|
||||
|
||||
+11
-11
@@ -1,29 +1,29 @@
|
||||
U8 *Tabs2Spaces(U8 *src)
|
||||
{//MAlloc str with tabs to spaces.
|
||||
I64 ch,i,j,l=StrLen(src)<<1+2,col=0;
|
||||
U8 *dst=MAlloc(l),*temp;
|
||||
U8 *dst=MAlloc(l),*tmp;
|
||||
while (ch=*src++) {
|
||||
if (ch=='\t') {
|
||||
j=(col+8) & ~7;
|
||||
for (i=col;i<j;i++) {
|
||||
dst[i]=CH_SPACE;
|
||||
if (i>=l-2) {
|
||||
temp=MAlloc(l<<1);
|
||||
MemCpy(temp,dst,i+1);
|
||||
tmp=MAlloc(l<<1);
|
||||
MemCpy(tmp,dst,i+1);
|
||||
Free(dst);
|
||||
l<<=1;
|
||||
dst=temp;
|
||||
dst=tmp;
|
||||
}
|
||||
}
|
||||
col=j;
|
||||
} else {
|
||||
dst[col]=ch;
|
||||
if (col>=l-2) {
|
||||
temp=MAlloc(l<<1);
|
||||
MemCpy(temp,dst,col+1);
|
||||
tmp=MAlloc(l<<1);
|
||||
MemCpy(tmp,dst,col+1);
|
||||
Free(dst);
|
||||
l<<=1;
|
||||
dst=temp;
|
||||
dst=tmp;
|
||||
}
|
||||
col++;
|
||||
}
|
||||
@@ -57,12 +57,12 @@ U8 *ScaleIndent(U8 *src,F64 indent_scale_factor)
|
||||
|
||||
U8 *MStrUtil(U8 *src,I64 flags,F64 indent_scale_factor=0)
|
||||
{//MAlloc $LK,"StrUtil",A="MN:StrUtil"$().
|
||||
U8 *dst=StrNew(src),*dst2,*temp;
|
||||
U8 *dst=StrNew(src),*dst2,*tmp;
|
||||
StrUtil(dst,flags);
|
||||
if (flags & SUF_T2S) {
|
||||
temp=Tabs2Spaces(dst);
|
||||
tmp=Tabs2Spaces(dst);
|
||||
Free(dst);
|
||||
dst=temp;
|
||||
dst=tmp;
|
||||
}
|
||||
if (flags & SUF_SCALE_INDENT)
|
||||
dst2=ScaleIndent(dst,indent_scale_factor);
|
||||
@@ -114,7 +114,7 @@ Bool AreYouSure()
|
||||
|
||||
U0 Help()
|
||||
{//Dbg help or master help index file.
|
||||
if (IsDbg)
|
||||
if (IsDbgMode)
|
||||
DbgHelp;
|
||||
else
|
||||
PopUp("Type(\"::/Doc/HelpIndex.DD\");DocTop;View;");
|
||||
|
||||
+127
-127
@@ -24,9 +24,9 @@ U0 OutStr(U8 *ptr,U8 **_buf,U8 **_dst,I64 len,I64 flags)
|
||||
i=0;
|
||||
else
|
||||
i=StrLen(ptr);
|
||||
if (flags&SPF_TRUNCATE && i>len)
|
||||
if (flags&PRTF_TRUNCATE && i>len)
|
||||
i=len;
|
||||
if (flags&SPF_LEFT_JUSTIFY) {
|
||||
if (flags&PRTF_LEFT_JUSTIFY) {
|
||||
for (j=0;j<i;j++)
|
||||
SPutChar(_dst,*ptr++,_buf);
|
||||
for (j=0;j<len-i;j++)
|
||||
@@ -65,7 +65,7 @@ U8 *MPrintQ(U8 *ptr,I64 flags)
|
||||
while (ch=*ptr++) {
|
||||
switch (ch) {
|
||||
case '$$':
|
||||
if (flags&SPF_DOLLAR) {
|
||||
if (flags&PRTF_DOLLAR) {
|
||||
SPutChar(_dst,'\\',_buf);
|
||||
SPutChar(_dst,'d',_buf);
|
||||
} else {
|
||||
@@ -75,7 +75,7 @@ U8 *MPrintQ(U8 *ptr,I64 flags)
|
||||
break;
|
||||
case '%':
|
||||
SPutChar(_dst,ch,_buf);
|
||||
if (flags&SPF_SLASH)
|
||||
if (flags&PRTF_SLASH)
|
||||
SPutChar(_dst,ch,_buf);
|
||||
break;
|
||||
case '\n':
|
||||
@@ -186,7 +186,7 @@ U8 *MPrintq(U8 *ptr,I64 flags)
|
||||
break;
|
||||
case '%':
|
||||
SPutChar(_dst,ch,_buf);
|
||||
if (flags&SPF_SLASH && ch1=='%')
|
||||
if (flags&PRTF_SLASH && ch1=='%')
|
||||
ptr++;
|
||||
break;
|
||||
default:
|
||||
@@ -202,7 +202,7 @@ U8 *sys_pos_pows_lets=" KMGTPEZY",
|
||||
*sys_pos_pows_lst="kilo\0mega\0giga\0tera\0peta\0exa\0zetta\0yotta\0",
|
||||
*sys_neg_pows_lst="milli\0micro\0nano\0pico\0femto\0atto\0zepto\0yocto\0";
|
||||
|
||||
#define TEMP_BUF_LEN 256
|
||||
#define TMP_BUF_LEN 256
|
||||
#define SLOP 8
|
||||
|
||||
U8 *StrPrintJoin(U8 *dst,U8 *fmt,I64 argc,I64 *argv)
|
||||
@@ -219,7 +219,7 @@ to avoid this.
|
||||
U64 m;
|
||||
F64 d,d1;
|
||||
CDoc *doc;
|
||||
U8 *ptr,**_buf,*buf,**_dst,temp_buf[TEMP_BUF_LEN],temp_buf2[TEMP_BUF_LEN*2];
|
||||
U8 *ptr,**_buf,*buf,**_dst,tmp_buf[TMP_BUF_LEN],tmp_buf2[TMP_BUF_LEN*2];
|
||||
|
||||
if (!fmt)
|
||||
throw('StrPrint');
|
||||
@@ -237,11 +237,11 @@ to avoid this.
|
||||
if (ch=='%') {
|
||||
flags=0;
|
||||
if (*fmt=='-') {
|
||||
flags|=SPF_LEFT_JUSTIFY;
|
||||
flags|=PRTF_LEFT_JUSTIFY;
|
||||
fmt++;
|
||||
}
|
||||
if (*fmt=='0') {
|
||||
flags|=SPF_PAD_ZERO;
|
||||
flags|=PRTF_PAD_ZERO;
|
||||
fmt++;
|
||||
}
|
||||
len=0;
|
||||
@@ -264,7 +264,7 @@ to avoid this.
|
||||
throw('StrPrint');
|
||||
dec_len=argv[cur_arg++];
|
||||
}
|
||||
flags|=SPF_DECIMAL;
|
||||
flags|=PRTF_DECIMAL;
|
||||
}
|
||||
|
||||
aux_fmt_num=0;
|
||||
@@ -272,16 +272,16 @@ to avoid this.
|
||||
switch (*fmt) {
|
||||
start:
|
||||
case '$$':
|
||||
flags|=SPF_DOLLAR;
|
||||
flags|=PRTF_DOLLAR;
|
||||
break;
|
||||
case '/':
|
||||
flags|=SPF_SLASH;
|
||||
flags|=PRTF_SLASH;
|
||||
break;
|
||||
case ',':
|
||||
flags|=SPF_COMMA;
|
||||
flags|=PRTF_COMMA;
|
||||
break;
|
||||
case 't':
|
||||
flags|=SPF_TRUNCATE;
|
||||
flags|=PRTF_TRUNCATE;
|
||||
break;
|
||||
case 'l': //harmless
|
||||
break;
|
||||
@@ -291,10 +291,10 @@ to avoid this.
|
||||
|
||||
case 'h':
|
||||
fmt++;
|
||||
flags|=SPF_AUX_FMT_NUM;
|
||||
flags|=PRTF_AUX_FMT_NUM;
|
||||
if (*fmt=='?') {
|
||||
fmt++;
|
||||
flags|=SPF_QUESTION;
|
||||
flags|=PRTF_QUESTION;
|
||||
} else {
|
||||
if (*fmt=='*') {
|
||||
fmt++;
|
||||
@@ -304,11 +304,11 @@ to avoid this.
|
||||
} else {
|
||||
if (*fmt=='-') {
|
||||
fmt++;
|
||||
flags|=SPF_NEG_AUX_FMT_NUM;
|
||||
flags|=PRTF_NEG_AUX_FMT_NUM;
|
||||
}
|
||||
while ('0'<=*fmt<='9')
|
||||
aux_fmt_num=aux_fmt_num*10+ *fmt++ -'0';
|
||||
if (flags&SPF_NEG_AUX_FMT_NUM)
|
||||
if (flags&PRTF_NEG_AUX_FMT_NUM)
|
||||
aux_fmt_num=-aux_fmt_num;
|
||||
}
|
||||
}
|
||||
@@ -325,7 +325,7 @@ to avoid this.
|
||||
case 'F':
|
||||
if (cur_arg>=argc)
|
||||
throw('StrPrint');
|
||||
if (flags&SPF_DOLLAR) {
|
||||
if (flags&PRTF_DOLLAR) {
|
||||
doc=argv[cur_arg++];
|
||||
old_flags=doc->flags;
|
||||
doc->flags|=DOCF_NO_CURSOR;
|
||||
@@ -390,43 +390,43 @@ to avoid this.
|
||||
case 'c':
|
||||
if (cur_arg>=argc)
|
||||
throw('StrPrint');
|
||||
temp_buf[0](I64)=argv[cur_arg++];
|
||||
temp_buf[8]=0;
|
||||
tmp_buf[0](I64)=argv[cur_arg++];
|
||||
tmp_buf[8]=0;
|
||||
break;
|
||||
case 'C':
|
||||
if (cur_arg>=argc)
|
||||
throw('StrPrint');
|
||||
temp_buf[0](I64)=argv[cur_arg++];
|
||||
temp_buf[8]=0;
|
||||
ptr=temp_buf;
|
||||
tmp_buf[0](I64)=argv[cur_arg++];
|
||||
tmp_buf[8]=0;
|
||||
ptr=tmp_buf;
|
||||
while (*ptr) {
|
||||
*ptr=ToUpper(*ptr);
|
||||
ptr++;
|
||||
}
|
||||
break;
|
||||
end:
|
||||
if (!(flags&SPF_AUX_FMT_NUM))
|
||||
if (!(flags&PRTF_AUX_FMT_NUM))
|
||||
aux_fmt_num=1;
|
||||
while (aux_fmt_num-->0)
|
||||
OutStr(temp_buf,_buf,_dst,len,flags);
|
||||
OutStr(tmp_buf,_buf,_dst,len,flags);
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
if (cur_arg>=argc)
|
||||
throw('StrPrint');
|
||||
StrPrintFunSeg(temp_buf,argv[cur_arg++],len,flags);
|
||||
OutStr(temp_buf,_buf,_dst,len,flags);
|
||||
StrPrintFunSeg(tmp_buf,argv[cur_arg++],len,flags);
|
||||
OutStr(tmp_buf,_buf,_dst,len,flags);
|
||||
break;
|
||||
case 'P':
|
||||
if (cur_arg>=argc)
|
||||
throw('StrPrint');
|
||||
StrPrintFunSeg(temp_buf,argv[cur_arg],len,flags);
|
||||
StrPrintFunSeg(tmp_buf,argv[cur_arg],len,flags);
|
||||
if (!IsRaw || !_buf) {
|
||||
StrPrint(temp_buf2,"$$LK,\"%s\",A=\"AD:0x%X\"$$",
|
||||
temp_buf,argv[cur_arg]);
|
||||
OutStr(temp_buf2,_buf,_dst,len,flags);
|
||||
StrPrint(tmp_buf2,"$$LK,\"%s\",A=\"AD:0x%X\"$$",
|
||||
tmp_buf,argv[cur_arg]);
|
||||
OutStr(tmp_buf2,_buf,_dst,len,flags);
|
||||
} else
|
||||
OutStr(temp_buf,_buf,_dst,len,flags);
|
||||
OutStr(tmp_buf,_buf,_dst,len,flags);
|
||||
cur_arg++;
|
||||
break;
|
||||
case 'd':
|
||||
@@ -434,38 +434,38 @@ to avoid this.
|
||||
throw('StrPrint');
|
||||
m=argv[cur_arg++];
|
||||
if (m(I64)<0) {
|
||||
flags|=SPF_NEG;
|
||||
flags|=PRTF_NEG;
|
||||
m=-m;
|
||||
}
|
||||
sp_out_dec:
|
||||
if (flags&SPF_AUX_FMT_NUM) {
|
||||
if (flags&PRTF_AUX_FMT_NUM) {
|
||||
if (!len) len=12;
|
||||
d=m;
|
||||
goto sp_out_eng;
|
||||
}
|
||||
if (flags&SPF_COMMA) {
|
||||
if (flags&PRTF_COMMA) {
|
||||
comma_fmt_cnt=comma_cnt=3;
|
||||
do {
|
||||
temp_buf[k++]=ModU64(&m,10)+'0';
|
||||
tmp_buf[k++]=ModU64(&m,10)+'0';
|
||||
if (!m) break;
|
||||
if (!--comma_cnt) {
|
||||
temp_buf[k++]=',';
|
||||
tmp_buf[k++]=',';
|
||||
comma_cnt=3;
|
||||
}
|
||||
} while (k<TEMP_BUF_LEN-SLOP);
|
||||
} while (k<TMP_BUF_LEN-SLOP);
|
||||
sp_out_comma_num:
|
||||
if (flags&SPF_NEG)
|
||||
if (flags&PRTF_NEG)
|
||||
i=1;
|
||||
else
|
||||
i=0;
|
||||
if (len<0)
|
||||
len=0;
|
||||
if (flags&SPF_TRUNCATE && k+i>len)
|
||||
if (flags&PRTF_TRUNCATE && k+i>len)
|
||||
k=len-i;
|
||||
if (k<0)
|
||||
k=0;
|
||||
if (flags&SPF_PAD_ZERO) {
|
||||
if (flags&SPF_NEG)
|
||||
if (flags&PRTF_PAD_ZERO) {
|
||||
if (flags&PRTF_NEG)
|
||||
SPutChar(_dst,'-',_buf);
|
||||
comma_cnt=(len-k-i+comma_fmt_cnt-comma_cnt+1)
|
||||
%(comma_fmt_cnt+1)+1;
|
||||
@@ -481,39 +481,39 @@ sp_out_comma_num:
|
||||
} else {
|
||||
for (;i<len-k;i++)
|
||||
SPutChar(_dst,CH_SPACE,_buf);
|
||||
if (flags&SPF_NEG)
|
||||
if (flags&PRTF_NEG)
|
||||
SPutChar(_dst,'-',_buf);
|
||||
}
|
||||
} else {
|
||||
do {
|
||||
temp_buf[k++]=ModU64(&m,10)+'0';
|
||||
tmp_buf[k++]=ModU64(&m,10)+'0';
|
||||
if (!m) break;
|
||||
} while (k<TEMP_BUF_LEN-SLOP);
|
||||
} while (k<TMP_BUF_LEN-SLOP);
|
||||
sp_out_num:
|
||||
if (flags&SPF_NEG)
|
||||
if (flags&PRTF_NEG)
|
||||
i=1;
|
||||
else
|
||||
i=0;
|
||||
if (len<0)
|
||||
len=0;
|
||||
if (flags&SPF_TRUNCATE && k+i>len)
|
||||
if (flags&PRTF_TRUNCATE && k+i>len)
|
||||
k=len-i;
|
||||
if (k<0)
|
||||
k=0;
|
||||
if (flags&SPF_PAD_ZERO) {
|
||||
if (flags&SPF_NEG)
|
||||
if (flags&PRTF_PAD_ZERO) {
|
||||
if (flags&PRTF_NEG)
|
||||
SPutChar(_dst,'-',_buf);
|
||||
for (;i<len-k;i++)
|
||||
SPutChar(_dst,'0',_buf);
|
||||
} else {
|
||||
for (;i<len-k;i++)
|
||||
SPutChar(_dst,CH_SPACE,_buf);
|
||||
if (flags&SPF_NEG)
|
||||
if (flags&PRTF_NEG)
|
||||
SPutChar(_dst,'-',_buf);
|
||||
}
|
||||
}
|
||||
for (i=k-1;i>=0;i--)
|
||||
SPutChar(_dst,temp_buf[i],_buf);
|
||||
SPutChar(_dst,tmp_buf[i],_buf);
|
||||
break;
|
||||
case 'u':
|
||||
if (cur_arg>=argc)
|
||||
@@ -525,26 +525,26 @@ sp_out_num:
|
||||
throw('StrPrint');
|
||||
d=argv[cur_arg++](F64);
|
||||
if (d<0) {
|
||||
flags|=SPF_NEG;
|
||||
flags|=PRTF_NEG;
|
||||
d=-d;
|
||||
}
|
||||
|
||||
if (d==ì) {
|
||||
sp_out_inf:
|
||||
if (flags&SPF_NEG)
|
||||
if (flags&PRTF_NEG)
|
||||
i=1;
|
||||
else
|
||||
i=0;
|
||||
k=1;
|
||||
if (len<0)
|
||||
len=0;
|
||||
if (flags&SPF_TRUNCATE && k+i>len)
|
||||
if (flags&PRTF_TRUNCATE && k+i>len)
|
||||
k=len-i;
|
||||
if (k<0)
|
||||
k=0;
|
||||
for (;i<len-k;i++)
|
||||
SPutChar(_dst,CH_SPACE,_buf);
|
||||
if (flags&SPF_NEG)
|
||||
if (flags&PRTF_NEG)
|
||||
SPutChar(_dst,'-',_buf);
|
||||
for (i=0;i<k;i++)
|
||||
SPutChar(_dst,'ì',_buf);
|
||||
@@ -556,7 +556,7 @@ sp_out_inf:
|
||||
dec_len=0;
|
||||
n=Log10(d);
|
||||
if (i=dec_len) {
|
||||
if (flags&SPF_COMMA)
|
||||
if (flags&PRTF_COMMA)
|
||||
i=i-i/4;
|
||||
if (n+i>17) {
|
||||
n+=i-17;
|
||||
@@ -573,66 +573,66 @@ sp_out_inf:
|
||||
n=0;
|
||||
|
||||
m=Round(d);
|
||||
if (flags&SPF_COMMA) {
|
||||
if (flags&PRTF_COMMA) {
|
||||
comma_cnt=i&3;
|
||||
while (i-- && k<TEMP_BUF_LEN-SLOP) {
|
||||
while (i-- && k<TMP_BUF_LEN-SLOP) {
|
||||
if (i>2 && !comma_cnt--) {
|
||||
temp_buf[k++]=',';
|
||||
tmp_buf[k++]=',';
|
||||
comma_cnt=2;
|
||||
if (!--i) break;
|
||||
}
|
||||
if (n) {
|
||||
n--;
|
||||
temp_buf[k++]='0';
|
||||
tmp_buf[k++]='0';
|
||||
} else
|
||||
temp_buf[k++]=ModU64(&m,10)+'0';
|
||||
tmp_buf[k++]=ModU64(&m,10)+'0';
|
||||
if (!i) break;
|
||||
}
|
||||
} else {
|
||||
while (i-- && k<TEMP_BUF_LEN-SLOP) {
|
||||
while (i-- && k<TMP_BUF_LEN-SLOP) {
|
||||
if (n) {
|
||||
n--;
|
||||
temp_buf[k++]='0';
|
||||
tmp_buf[k++]='0';
|
||||
} else
|
||||
temp_buf[k++]=ModU64(&m,10)+'0';
|
||||
tmp_buf[k++]=ModU64(&m,10)+'0';
|
||||
}
|
||||
}
|
||||
if (dec_len)
|
||||
temp_buf[k++]='.';
|
||||
if (flags&SPF_COMMA) {
|
||||
tmp_buf[k++]='.';
|
||||
if (flags&PRTF_COMMA) {
|
||||
comma_cnt=3;
|
||||
do {
|
||||
if (n) {
|
||||
n--;
|
||||
temp_buf[k++]='0';
|
||||
tmp_buf[k++]='0';
|
||||
} else
|
||||
temp_buf[k++]=ModU64(&m,10)+'0';
|
||||
tmp_buf[k++]=ModU64(&m,10)+'0';
|
||||
if (!m) break;
|
||||
if (!--comma_cnt) {
|
||||
temp_buf[k++]=',';
|
||||
tmp_buf[k++]=',';
|
||||
comma_cnt=3;
|
||||
}
|
||||
} while (k<TEMP_BUF_LEN-SLOP);
|
||||
} while (k<TMP_BUF_LEN-SLOP);
|
||||
} else {
|
||||
do {
|
||||
if (n) {
|
||||
n--;
|
||||
temp_buf[k++]='0';
|
||||
tmp_buf[k++]='0';
|
||||
} else
|
||||
temp_buf[k++]=ModU64(&m,10)+'0';
|
||||
tmp_buf[k++]=ModU64(&m,10)+'0';
|
||||
if (!m) break;
|
||||
} while (k<TEMP_BUF_LEN-SLOP);
|
||||
} while (k<TMP_BUF_LEN-SLOP);
|
||||
}
|
||||
goto sp_out_num;
|
||||
case 'e':
|
||||
if (!len) len=12;
|
||||
flags|=SPF_TRUNCATE;
|
||||
flags|=PRTF_TRUNCATE;
|
||||
|
||||
if (cur_arg>=argc)
|
||||
throw('StrPrint');
|
||||
d=argv[cur_arg++](F64);
|
||||
if (d<0) {
|
||||
flags|=SPF_NEG;
|
||||
flags|=PRTF_NEG;
|
||||
d=-d;
|
||||
}
|
||||
if (d==ì) goto sp_out_inf;
|
||||
@@ -649,18 +649,18 @@ sp_out_e:
|
||||
n0=n;
|
||||
if (n<0) {
|
||||
n=-n;
|
||||
flags|=SPF_NEG_E;
|
||||
flags|=PRTF_NEG_E;
|
||||
} else
|
||||
flags&=~SPF_NEG_E;
|
||||
flags&=~PRTF_NEG_E;
|
||||
|
||||
i=3;
|
||||
do temp_buf[k++]=ModU64(&n,10)+'0';
|
||||
do tmp_buf[k++]=ModU64(&n,10)+'0';
|
||||
while (n && i--);
|
||||
if (flags&SPF_NEG_E)
|
||||
temp_buf[k++]='-';
|
||||
temp_buf[k++]='e';
|
||||
if (flags&PRTF_NEG_E)
|
||||
tmp_buf[k++]='-';
|
||||
tmp_buf[k++]='e';
|
||||
dec_len=len-k-2;
|
||||
if (flags&SPF_NEG)
|
||||
if (flags&PRTF_NEG)
|
||||
dec_len--;
|
||||
|
||||
if (d) {
|
||||
@@ -682,12 +682,12 @@ sp_out_e:
|
||||
goto sp_out_f;
|
||||
case 'g':
|
||||
if (!len) len=12;
|
||||
flags|=SPF_TRUNCATE;
|
||||
flags|=PRTF_TRUNCATE;
|
||||
if (cur_arg>=argc)
|
||||
throw('StrPrint');
|
||||
d=argv[cur_arg++](F64);
|
||||
if (d<0) {
|
||||
flags|=SPF_NEG;
|
||||
flags|=PRTF_NEG;
|
||||
d=-d;
|
||||
}
|
||||
if (d==ì) goto sp_out_inf;
|
||||
@@ -701,12 +701,12 @@ sp_out_e:
|
||||
goto sp_out_f;
|
||||
case 'n':
|
||||
if (!len) len=12;
|
||||
flags|=SPF_TRUNCATE;
|
||||
flags|=PRTF_TRUNCATE;
|
||||
if (cur_arg>=argc)
|
||||
throw('StrPrint');
|
||||
d=argv[cur_arg++](F64);
|
||||
if (d<0) {
|
||||
flags|=SPF_NEG;
|
||||
flags|=PRTF_NEG;
|
||||
d=-d;
|
||||
}
|
||||
sp_out_eng: //Engineering notation
|
||||
@@ -719,17 +719,17 @@ sp_out_eng: //Engineering notation
|
||||
|
||||
if (n<0) {
|
||||
n=-n;
|
||||
flags|=SPF_NEG_E;
|
||||
flags|=PRTF_NEG_E;
|
||||
}
|
||||
if (flags&SPF_AUX_FMT_NUM && -24<=n<=24) {
|
||||
if (flags&SPF_QUESTION) {
|
||||
if (flags&SPF_NEG_E)
|
||||
if (flags&PRTF_AUX_FMT_NUM && -24<=n<=24) {
|
||||
if (flags&PRTF_QUESTION) {
|
||||
if (flags&PRTF_NEG_E)
|
||||
i=-n/3;
|
||||
else
|
||||
i=n/3;
|
||||
j=0;
|
||||
} else {
|
||||
if (flags&SPF_NEG_E)
|
||||
if (flags&PRTF_NEG_E)
|
||||
j=-n-aux_fmt_num;
|
||||
else
|
||||
j=n-aux_fmt_num;
|
||||
@@ -737,17 +737,17 @@ sp_out_eng: //Engineering notation
|
||||
i=aux_fmt_num/3;
|
||||
}
|
||||
if (i<0)
|
||||
temp_buf[k++]=sys_neg_pows_lets[-i];
|
||||
tmp_buf[k++]=sys_neg_pows_lets[-i];
|
||||
else if (i>0)
|
||||
temp_buf[k++]=sys_pos_pows_lets[i];
|
||||
tmp_buf[k++]=sys_pos_pows_lets[i];
|
||||
else if (len!=0)
|
||||
temp_buf[k++]=CH_SPACE;
|
||||
if (!(flags&SPF_DECIMAL)) {
|
||||
tmp_buf[k++]=CH_SPACE;
|
||||
if (!(flags&PRTF_DECIMAL)) {
|
||||
dec_len=len-k-2;
|
||||
if (flags&SPF_NEG)
|
||||
if (flags&PRTF_NEG)
|
||||
dec_len--;
|
||||
if (j>0) {
|
||||
if (flags&SPF_COMMA)
|
||||
if (flags&PRTF_COMMA)
|
||||
dec_len-=4*j/3;
|
||||
else
|
||||
dec_len-=j;
|
||||
@@ -761,14 +761,14 @@ sp_out_eng: //Engineering notation
|
||||
}
|
||||
} else {
|
||||
i=3;
|
||||
do temp_buf[k++]=ModU64(&n,10)+'0';
|
||||
do tmp_buf[k++]=ModU64(&n,10)+'0';
|
||||
while (n && i--);
|
||||
if (flags&SPF_NEG_E)
|
||||
temp_buf[k++]='-';
|
||||
temp_buf[k++]='e';
|
||||
if (flags&PRTF_NEG_E)
|
||||
tmp_buf[k++]='-';
|
||||
tmp_buf[k++]='e';
|
||||
if (!dec_len) {
|
||||
dec_len=len-k-2;
|
||||
if (flags&SPF_NEG)
|
||||
if (flags&PRTF_NEG)
|
||||
dec_len--;
|
||||
d1=d+Pow10I64(-dec_len+1)/2;
|
||||
if (d1>=10) {
|
||||
@@ -778,9 +778,9 @@ sp_out_eng: //Engineering notation
|
||||
}
|
||||
}
|
||||
}
|
||||
if (flags&SPF_COMMA) {
|
||||
if (flags&PRTF_COMMA) {
|
||||
if (len && dec_len>0 && !(dec_len&3))
|
||||
temp_buf[k++]=',';
|
||||
tmp_buf[k++]=',';
|
||||
dec_len-=dec_len/4;
|
||||
}
|
||||
goto sp_out_f;
|
||||
@@ -788,54 +788,54 @@ sp_out_eng: //Engineering notation
|
||||
if (cur_arg>=argc)
|
||||
throw('StrPrint');
|
||||
m=argv[cur_arg++];
|
||||
if (flags&SPF_COMMA) {
|
||||
if (flags&PRTF_COMMA) {
|
||||
comma_fmt_cnt=comma_cnt=4;
|
||||
do {
|
||||
temp_buf[k]= m&15 +'0';
|
||||
if (temp_buf[k]>'9') temp_buf[k]+='A'-0x3A;
|
||||
tmp_buf[k]= m&15 +'0';
|
||||
if (tmp_buf[k]>'9') tmp_buf[k]+='A'-0x3A;
|
||||
k++;
|
||||
m>>=4;
|
||||
if (!m) break;
|
||||
if (!--comma_cnt) {
|
||||
temp_buf[k++]=',';
|
||||
tmp_buf[k++]=',';
|
||||
comma_cnt=4;
|
||||
}
|
||||
} while (k<TEMP_BUF_LEN-SLOP);
|
||||
} while (k<TMP_BUF_LEN-SLOP);
|
||||
goto sp_out_comma_num;
|
||||
} else {
|
||||
do {
|
||||
temp_buf[k]= m&15 +'0';
|
||||
if (temp_buf[k]>'9') temp_buf[k]+='A'-0x3A;
|
||||
tmp_buf[k]= m&15 +'0';
|
||||
if (tmp_buf[k]>'9') tmp_buf[k]+='A'-0x3A;
|
||||
k++;
|
||||
m>>=4;
|
||||
} while (m && k<TEMP_BUF_LEN-SLOP);
|
||||
} while (m && k<TMP_BUF_LEN-SLOP);
|
||||
goto sp_out_num;
|
||||
}
|
||||
case 'x':
|
||||
if (cur_arg>=argc)
|
||||
throw('StrPrint');
|
||||
m=argv[cur_arg++];
|
||||
if (flags&SPF_COMMA) {
|
||||
if (flags&PRTF_COMMA) {
|
||||
comma_fmt_cnt=comma_cnt=4;
|
||||
do {
|
||||
temp_buf[k]= m&15 +'0';
|
||||
if (temp_buf[k]>'9') temp_buf[k]+='a'-0x3A;
|
||||
tmp_buf[k]= m&15 +'0';
|
||||
if (tmp_buf[k]>'9') tmp_buf[k]+='a'-0x3A;
|
||||
k++;
|
||||
m>>=4;
|
||||
if (!m) break;
|
||||
if (!--comma_cnt) {
|
||||
temp_buf[k++]=',';
|
||||
tmp_buf[k++]=',';
|
||||
comma_cnt=4;
|
||||
}
|
||||
} while (k<TEMP_BUF_LEN-SLOP);
|
||||
} while (k<TMP_BUF_LEN-SLOP);
|
||||
goto sp_out_comma_num;
|
||||
} else {
|
||||
do {
|
||||
temp_buf[k]= m&15 +'0';
|
||||
if (temp_buf[k]>'9') temp_buf[k]+='a'-0x3A;
|
||||
tmp_buf[k]= m&15 +'0';
|
||||
if (tmp_buf[k]>'9') tmp_buf[k]+='a'-0x3A;
|
||||
k++;
|
||||
m>>=4;
|
||||
} while (m && k<TEMP_BUF_LEN-SLOP);
|
||||
} while (m && k<TMP_BUF_LEN-SLOP);
|
||||
goto sp_out_num;
|
||||
}
|
||||
case 'b':
|
||||
@@ -843,23 +843,23 @@ sp_out_eng: //Engineering notation
|
||||
if (cur_arg>=argc)
|
||||
throw('StrPrint');
|
||||
m=argv[cur_arg++];
|
||||
if (flags&SPF_COMMA) {
|
||||
if (flags&PRTF_COMMA) {
|
||||
comma_fmt_cnt=comma_cnt=4;
|
||||
do {
|
||||
temp_buf[k++]= m&1 +'0';
|
||||
tmp_buf[k++]= m&1 +'0';
|
||||
m>>=1;
|
||||
if (!m) break;
|
||||
if (!--comma_cnt) {
|
||||
temp_buf[k++]=',';
|
||||
tmp_buf[k++]=',';
|
||||
comma_cnt=4;
|
||||
}
|
||||
} while (k<TEMP_BUF_LEN-SLOP);
|
||||
} while (k<TMP_BUF_LEN-SLOP);
|
||||
goto sp_out_comma_num;
|
||||
} else {
|
||||
do {
|
||||
temp_buf[k++]= m&1 +'0';
|
||||
tmp_buf[k++]= m&1 +'0';
|
||||
m>>=1;
|
||||
} while (m && k<TEMP_BUF_LEN-SLOP);
|
||||
} while (m && k<TMP_BUF_LEN-SLOP);
|
||||
goto sp_out_num;
|
||||
}
|
||||
case '%':
|
||||
|
||||
Reference in new issue
Block a user