; ****************************************************************************
; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.0) - UNINITIALIZED DATA : trdoskx.s
; ----------------------------------------------------------------------------
; Last Update: 28/02/2016
; ----------------------------------------------------------------------------
; Beginning: 04/01/2016
; ----------------------------------------------------------------------------
; Assembler: NASM version 2.11 (trdos386.s)
; ----------------------------------------------------------------------------
; Derived from TRDOS Operating System v1.0 (8086) source code by Erdogan Tan
; TRDOS2.ASM (09/11/2011)
; ****************************************************************************
; DRV_INIT.ASM [26/09/2009] Last Update: 07/08/2011
; MAINPROG.ASM [17/01/2004] Last Update: 09/11/2011
; DIR.ASM      [17/01/2004] Last Update: 09/10/2011
; CMD_INTR.ASM [29/01/2005] Last update: 09/11/2011
; DRV_FAT.ASM  [07/07/2009] Last update: 21/08/2011

alignb 4

MainProgCfg_FileSize:   resw 1
MainProgCfg_LineOffset: resw 1 

Current_VolSerial: resd 1

Current_Dir_FCluster: resd 1

Current_Dir_Level: resb 1
Current_FATType: resb 1
Current_Drv: resb 1
Current_Dir_Drv:   resb 1 ; '?'
                   resb 1 ; ':'
Current_Dir_Root:  resb 1 ; '/' 
Current_Directory: resb 90
End_Of_Current_Dir_Str: resb 1
Current_Dir_StrLen: resb 1   

CursorColumn: 	resb 1
CmdArgStart:    resb 1

Remark: ; 03/02/2016
		resb 78

CommandBuffer: 	resb 80

TextBuffer: resb 256

MasterBootBuff:
MasterBootCode: resb 1BEh
PartitionTable: resb 64
MBIDCode: resw 1

PTable_Buffer:
PTable_hd0: resb 64
PTable_hd1: resb 64
PTable_hd2: resb 64
PTable_hd3: resb 64
PTable_ep0: resb 64
PTable_ep1: resb 64
PTable_ep2: resb 64
PTable_ep3: resb 64

HD_LBA_yes: resb 1
PP_Counter: resb 1
EP_Counter: resb 1

EP_StartSector: resd 1
                resd 1
                resd 1
                resd 1

DOSBootSectorBuff: resb 512

FAT_BuffDescriptor:
FAT_CurrentCluster: resd 1
FAT_BuffValidData: resb 1
FAT_BuffDrvName: resb 1
FAT_BuffOffset: resw 1
FAT_BuffSector: resd 1

FAT_ClusterCounter: resd 1
LastCluster: resd 1

resb 1

Dir_BuffDescriptor:
DirBuff_DRV: resb 1
DirBuff_FATType: resb 1
DirBuff_ValidData: resb 1
DirBuff_CurrentEntry: resw 1
DirBuff_LastEntry: resw 1
DirBuff_Cluster: resd 1 
DirBuffer_Size: resw 1
;DirBuff_EntryCounter: resw 1

; 01/02/2016
; these are on (real mode) segment 8000h and later
; FAT_Buffer:	resb 1536 ; 3 sectors
; Dir_Buffer:	resb 512*32
; Logical_DOSDisks:  resb 6656 ; 26 * 256 bytes

; 18/01/2016

FreeClusterCount: resd 1

VolSize_Unit1:   resd 1
VolSize_Unit2:   resd 1

Vol_Tot_Sec_Str_Start:	    resd 1
Vol_Tot_Sec_Str: 	    resb 10
Vol_Tot_Sec_Str_End:	    resb 1
resb 1
Vol_Free_Sectors_Str_Start: resd 1
Vol_Free_Sectors_Str:	    resb 10				
Vol_Free_Sectors_Str_End:   resb 1

; 10/02/2016
RUN_CDRV: resb 1 ; CMD_INTR.ASM  ; 09/11/2011

; 24/01/2016
PATH_Array:     resb 128 ; DIR.ASM ; 09/10/2011
; 06/02/2016
CCD_DriveDT:	resd 1 ; DIR.ASM ; (word)
CCD_Level:	resb 1 ; DIR.ASM
Last_Dir_Level:	resb 1 ; DIR.ASM
;
CDLF_AttributesMask: resw 1 ; DIR.ASM
CDLF_FNAddress:	resd 1 ; DIR.ASM (word)
CDLF_DEType:	resw 1 ; DIR.ASM
;
CD_COMMAND:	resb 1 ; DIR.ASM

alignb 4

; 29/01/2016
Program_Exit:	resb 1 ; CMD_INTR.ASM  ; 09/11/2011

;alignb 4
; 23/02/2016
disk_rw_op:	resb 1 ;  0 = disk read, 1 = disk write
;disk_rw_spt:	resb 1 ; sectors per track (<= 63) /// (<256)
; 31/01/2016
retry_count: 	resb 1 ; DISK_IO.ASM ; 20/07/2011 (CHS_RetryCount)
disk_rw_err: 	resb 1 ; DISK_IO.ASM ; (Disk_IO_err_code)
sector_count:	resd 1 ; DISK_IO.ASM ; (Disk_RW_SectorCount)

; 06/02/2016 (long name)
FDE_AttrMask:	   resw 1 ; DIR.ASM
AmbiguousFileName: resw 1 ; DIR.ASM
PreviousAttr:	   resb 1 ; DIR.ASM
;	
LongNameFound:   resb 1	  ; DIR.ASM
LFN_EntryLength: resb 1   ; DIR.ASM
LFN_CheckSum:    resb 1   ; DIR.ASM
LongFileName:    resb 132 ; DIR.ASM

;PATH_Array_Ptr: resw 1 ; DIR.ASM
PATH_CDLevel:	 resb 1 ; DIR.ASM
PATH_Level:	 resb 1 ; DIR.ASM

; 07/02/2016
Dir_File_Name:	resb 13 ; DIR.ASM ; 09/10/2011

; 10/02/2016
Dir_Entry_Name:
		resb 13 ; DIR.ASM

alignb 2

AttributesMask: resw 1 ; CMD_INTR.ASM ; 09/11/2011

; 10/02/2016 (128 bytes -> 126 bytes)
; 08/02/2016
;FFF Structure (128 bytes) ; DIR.ASM ; 09/10/2011
FindFile_Drv:		  resb 1
FindFile_Directory:	  resb 65
FindFile_Name:		  resb 13
FindFile_LongNameEntryLength:
FindFile_LongNameYes: 	  resb 1 ; Sign for longname procedures
;Above 80 bytes form
;TR-DOS Source/Destination File FullName Format/Structure
FindFile_AttributesMask:  resw 1
FindFile_DirEntry:	  resb 32
FindFile_DirFirstCluster: resd 1
FindFile_DirCluster:	  resd 1
FindFile_DirEntryNumber:  resw 1
FindFile_MatchCounter:	  resw 1
;FindFile_Reserved:	  resw 1

First_Path_Pos: resd 1	; DIR.ASM ; 09/10/2011
Last_Slash_Pos: resd 1	; DIR.ASM 

; 10/02/2016
File_Count:     resw 1 	; DIR.ASM ; 09/10/2011
Dir_Count:      resw 1
Total_FSize:    resd 1
TFS_Dec_Begin:  resd 1
                resb 10
TFS_Dec_End:    resb 1

PrintDir_RowCounter: resb 1

alignb 4
; 15/02/2015 ('show' command variables)
Show_FDT:	resd 1
Show_LDDDT:	resd 1
Show_Cluster:	resd 1
Show_FileSize:	resd 1
Show_FilePointer: resd 1
Show_ClusterPointer: resw 1
Show_ClusterSize: resw 1
Show_RowCount:	resb 1

alignb 4
; 21/02/2016
DelFile_FNPointer:	resd 1 ; ; CMD_INTR.ASM (word) ; 09/11/2011
; 27/02/2016
; DIR.ASM (09/10/2011)
DelFile_FCluster:	resd 1
DelFile_EntryCounter:	resw 1
DelFile_LNEL:		resb 1
resb 1

; DIR.ASM
mkdir_DirName_Offset: 	resd 1
mkdir_FFCluster:	resd 1
mkdir_LastDirCluster:	resd 1
mkdir_FreeSectors:	resd 1
mkdir_attrib:		resw 1 
mkdir_SecPerClust:	resb 1
mkdir_add_new_cluster:	resb 1
mkdir_Name:		resb 13
; 27/02/2016
RmDir_MultiClusters:	resb 1  
RmDir_DirEntryOffset:	resw 1
RmDir_ParentDirCluster: resd 1
RmDir_DirLastCluster:   resd 1
RmDir_PreviousCluster:  resd 1

; 22/02/2016
UPDLMDT_CDirLevel:	resb 1
UPDLMDT_CDirFCluster:	resd 1
	
alignb 4
; DRV_FAT.ASM ; 21/08/2011
gffc_next_free_cluster:  resd 1
gffc_first_free_cluster: resd 1
gffc_last_free_cluster:  resd 1

; 22/02/2016
ClusterValue:	resd 1
resb 1
CFS_error:  resb 1
CFS_OPType: resb 1
CFS_Drv:    resb 1
CFS_CC:	    resd 1
CFS_FAT32FSINFOSEC: resd 1
CFS_FAT32FC: resd 1

; 27/02/2016
;alignb 4
glc_prevcluster: resd 1 ; DRV_FAT.ASM (21/08/2011)

; DIR.ASM
DLN_EntryNumber: resw 1
DLN_40h:	 resb 1
; 28/02/2016
TCC_FATErr:	 resb 1 ; DRV_FAT.ASM

alignb 4
; DIR.ASM (09/10/2011)
LCDE_EntryIndex: resw 1 ; LCDE_EntryOffset
LCDE_ClusterSN:  resw 1
LCDE_Cluster: 	 resd 1
LCDE_ByteOffset: resd 1