TempleOSTS_130707.ISO
This commit is contained in:
1 parent
17b71f1a2d
commit
1343005a29
617 files changed
+14399
-25130
No files matched your search
+277
-298
@@ -1,10 +1,10 @@
|
||||
//This is the main TempleOS header file
|
||||
//for data structures and vals.
|
||||
//for data structures and classes.
|
||||
//There is no code in this file.
|
||||
|
||||
//The internal types are U16i,I32i, etc.
|
||||
//They are defined $LK,"internal_types_table","MN:internal_types_table"$.
|
||||
//TempleOS C+ has a feat where a
|
||||
//Holy C has a feature where a
|
||||
//union structure is treated as a
|
||||
//whole if no member is specified.
|
||||
//See $LK-A,"::/TempleOS/Demo/SubIntAccess.CPP"$.
|
||||
@@ -140,7 +140,6 @@ public class CQue
|
||||
|
||||
#define INVALID_PTR MAX_I64
|
||||
#define INVALID_CLUSTER -1
|
||||
#define ALL_MASK -1
|
||||
|
||||
//x86 opcodes
|
||||
#define OC_OP_SIZE_PREFIX 0x66
|
||||
@@ -149,6 +148,7 @@ public class CQue
|
||||
#define OC_NOP 0x90
|
||||
#define OC_BPT 0xCC
|
||||
#define OC_CALL 0xE8
|
||||
#define OC_JMP_REL8 0xEB
|
||||
|
||||
//Function Stack Frame
|
||||
#define SF_RBP 0x00
|
||||
@@ -171,7 +171,7 @@ extern class CExeImportExport;
|
||||
extern class CHeapCtrl;
|
||||
extern class CExeHeapGlbl;
|
||||
extern class CDC;
|
||||
extern class CMPCmdCtrl;
|
||||
extern class CSrvCtrl;
|
||||
extern class CIntermediateCode;
|
||||
|
||||
#define QUE_VECT_U8_CNT 512
|
||||
@@ -304,7 +304,6 @@ public class CMass
|
||||
F64 mass,drag_profile_factor;
|
||||
U0 saved_state;
|
||||
F64 x,y,z,DxDt,DyDt,DzDt;
|
||||
I64 user_data;
|
||||
U0 end_saved_area;
|
||||
};
|
||||
|
||||
@@ -321,7 +320,6 @@ public class CSpring
|
||||
U32 flags,num,
|
||||
end1_num,end2_num;
|
||||
F64 constant,rest_len;
|
||||
I64 user_data;
|
||||
U0 end_saved_area;
|
||||
};
|
||||
|
||||
@@ -368,7 +366,7 @@ public class CMathODE
|
||||
|
||||
class CBinFile
|
||||
{
|
||||
/* See $LK,"Bin File Header Generation","FF:::/TempleOS/Compiler/CmpMain.CPP,NATIVE_XSUM"$ by compiler.
|
||||
/* See $LK,"Bin File Header Generation","FF:::/TempleOS/Compiler/CmpMain.CPP,TEMPLEOS_XSUM"$ by compiler.
|
||||
|
||||
Bin files have this 16-byte header,
|
||||
followed by code,
|
||||
@@ -477,7 +475,6 @@ class CMemE820
|
||||
#define GDT_CS64_RING3_SEL 0x50 //$LK,"Ring3","FI:::/TempleOS/Demo/Lectures/Ring3.CPP"$, in case you want to play around.
|
||||
#define GDT_ZERO_DS_SEL 0x60
|
||||
#define GDT_ZERO_DS_RING3_SEL 0x70
|
||||
#define GDT_END1 0x80
|
||||
#define GDT_CPU_TR_SELS 0x80
|
||||
#define GDT_CPU_TR_RING3_SELS (GDT_CPU_TR_SELS +MP_MAX_PROCESSORS*16)
|
||||
#define GDT_SIZE (GDT_CPU_TR_RING3_SELS+MP_MAX_PROCESSORS*16)
|
||||
@@ -573,7 +570,7 @@ class CKernel
|
||||
#define LAPIC_LVT_LINT1 (LAPIC_BASE+0x360)
|
||||
#define LAPIC_LVT_ERR (LAPIC_BASE+0x370)
|
||||
|
||||
#define MPN_VECT 0x7F
|
||||
#define MPN_VECT 0x97
|
||||
#define MP_VECT_ADDR (MPN_VECT*0x1000)
|
||||
|
||||
//I/O APIC Memory mapped window
|
||||
@@ -737,12 +734,6 @@ class CDbgInfo
|
||||
U8 *body[1];
|
||||
};
|
||||
|
||||
class CIndentInfo
|
||||
{
|
||||
U32 min_line,max_line;
|
||||
I8 body[1];
|
||||
};
|
||||
|
||||
public class CHash
|
||||
{
|
||||
//Hash entries are not normally ever removed. Normally, a new
|
||||
@@ -772,7 +763,6 @@ public class CHashSrcSym:CHash
|
||||
U8 *src_link;
|
||||
U8 *index;
|
||||
CDbgInfo *debug;
|
||||
CIndentInfo *indent;
|
||||
U8 *import_name;
|
||||
CExeImportExport *ie_lst;
|
||||
};
|
||||
@@ -790,12 +780,12 @@ public class CHashGeneric:CHash
|
||||
#define REGT_FSTK 5
|
||||
#define REGT_MM 6
|
||||
#define REGT_XMM 7
|
||||
|
||||
public class CHashReg:CHash
|
||||
{
|
||||
U8 reg_num,reg_type;
|
||||
};
|
||||
|
||||
|
||||
public class CHashTable
|
||||
{
|
||||
CHashTable *next;
|
||||
@@ -976,57 +966,52 @@ public class CHashGlblVar:CHashSrcSym
|
||||
#define ARf_CSPRITE_PTS_RECTANGLES 9
|
||||
#define ARf_MANAGE_SLIDER 10
|
||||
|
||||
#define TASKCf_WAKE_MASTER 0
|
||||
#define TASKCf_FOCUS_MASTER 1
|
||||
#define TASKCf_EXIT_ON_COMPLETE 2
|
||||
#define TASKCf_DONT_FILTER 3
|
||||
#define TASKCf_HIGHEST_PRIORITY 4
|
||||
#define SVCf_WAKE_MASTER 0
|
||||
#define SVCf_FOCUS_MASTER 1
|
||||
#define SVCf_EXIT_ON_COMPLETE 2
|
||||
#define SVCf_DONT_FILTER 3
|
||||
#define SVCf_HIGHEST_PRIORITY 4
|
||||
//MP flags
|
||||
#define SVCf_DONE 5
|
||||
#define SVCf_DISPATCHED 6
|
||||
#define SVCf_FREE_ON_COMPLETE 7
|
||||
#define SVCf_ADD_TO_QUE 8
|
||||
|
||||
#define TASKCT_TEXT_INPUT 0
|
||||
#define TASKCT_MSG 1
|
||||
#define TASKCT_EXECUTE_STR 2
|
||||
#define TASKCT_EXECUTE_FILE 3
|
||||
#define SVCT_TEXT_INPUT 0
|
||||
#define SVCT_MSG 1
|
||||
#define SVCT_EXE_STR 2
|
||||
//MP cmds
|
||||
#define SVCT_CALL 3
|
||||
#define SVCT_SPAWN_TASK 4
|
||||
|
||||
class CTaskCmd
|
||||
class CSrvCmd
|
||||
{
|
||||
CTaskCmd *next,*last;
|
||||
CSrvCmd *next,*last;
|
||||
CSrvCtrl *ctrl;
|
||||
I64 cmd_code;
|
||||
I64 msg_code;
|
||||
I64 p1,p2;
|
||||
I64 flags;
|
||||
U8 *data;
|
||||
|
||||
I64 target_cpu;
|
||||
I64 servant_cpu_num;
|
||||
|
||||
I64 msg_code;
|
||||
|
||||
I64 (*add)(U8 *fun_arg);
|
||||
U8 *fun_arg;
|
||||
|
||||
U8 *aux_str;
|
||||
I64 aux1,aux2;
|
||||
I64 result;
|
||||
|
||||
CTask *spawned_task;
|
||||
CTask *master_task;
|
||||
};
|
||||
|
||||
|
||||
#define MPCf_DONE 0
|
||||
#define MPCf_DISPATCHED 1
|
||||
#define MPCf_FREE_ON_COMPLETE 2
|
||||
|
||||
#define MPCT_CALL 1
|
||||
#define MPCT_SPAWN_TASK 2
|
||||
|
||||
class CMPCmd
|
||||
#define SVCRf_LOCKED 0
|
||||
class CSrvCtrl
|
||||
{
|
||||
CMPCmd *next,*last;
|
||||
CMPCmdCtrl *ctrl;
|
||||
I64 cmd_code;
|
||||
I64 flags;
|
||||
I64 (*add)(U8 *data);
|
||||
U8 *data;
|
||||
U8 *desc;
|
||||
I64 target_cpu_mask;
|
||||
CTask *task; //spawned task
|
||||
I64 handler_cpu; //CPU accepting job
|
||||
I64 result;
|
||||
};
|
||||
|
||||
#define MPCCf_LOCKED 0
|
||||
class CMPCmdCtrl
|
||||
{
|
||||
CMPCmd *next_waiting,*last_waiting;
|
||||
CMPCmd *next_done,*last_done;
|
||||
CSrvCmd *next_waiting,*last_waiting;
|
||||
CSrvCmd *next_done,*last_done;
|
||||
I64 flags;
|
||||
};
|
||||
|
||||
@@ -1067,50 +1052,39 @@ class CBpt
|
||||
#define DOCT_BACKGROUND 15
|
||||
#define DOCT_DFT_FOREGROUND 16
|
||||
#define DOCT_DFT_BACKGROUND 17
|
||||
#define DOCT_ALT_FOREGROUND 18
|
||||
#define DOCT_LINK_FOREGROUND 19
|
||||
#define DOCT_MACRO_FOREGROUND 20
|
||||
#define DOCT_ANCHOR_FOREGROUND 21
|
||||
#define DOCT_HIDDEN_FOREGROUND 22
|
||||
#define DOCT_TREE_FOREGROUND 23
|
||||
#define DOCT_USER_FOREGROUND 24
|
||||
#define DOCT_BINARY_FOREGROUND 25
|
||||
#define DOCT_KEYWORD_FOREGROUND 26
|
||||
#define DOCT_KEYWORD2_FOREGROUND 27
|
||||
#define DOCT_COMMENT_FOREGROUND 28
|
||||
#define DOCT_QUOTE_FOREGROUND 29
|
||||
#define DOCT_WORD_WRAP 30
|
||||
#define DOCT_UNDERLINE 31
|
||||
#define DOCT_INVERT 32
|
||||
#define DOCT_BLINK 33
|
||||
#define DOCT_SHIFTED_X 34
|
||||
#define DOCT_SHIFTED_Y 35
|
||||
#define DOCT_CURSOR_MOVEMENT 36
|
||||
#define DOCT_ANCHOR 37
|
||||
#define DOCT_LINK 38
|
||||
#define DOCT_BUTTON 39
|
||||
#define DOCT_CHECK_BOX 40
|
||||
#define DOCT_MACRO 41
|
||||
#define DOCT_MENU_VAL 42
|
||||
#define DOCT_HEX_ED 43
|
||||
#define DOCT_HIDE_START 44
|
||||
#define DOCT_HIDE_END 45
|
||||
#define DOCT_TREE 46
|
||||
#define DOCT_SPRITE 47
|
||||
#define DOCT_INS_BINARY 48
|
||||
#define DOCT_INS_BINARY_TYPE 49
|
||||
#define DOCT_INS_BINARY_SIZE 50
|
||||
#define DOCT_BPT 51
|
||||
#define DOCT_SONG 52
|
||||
#define DOCT_HIGHLIGHT 53
|
||||
#define DOCT_LOCK_TO_PAGE 54
|
||||
#define DOCT_LOCK_TO_CENTER 55
|
||||
#define DOCT_HTML_IMG 56
|
||||
#define DOCT_HTML_VIDEO 57
|
||||
#define DOCT_HTML_CODE 58
|
||||
#define DOCT_ERROR 59
|
||||
#define DOCT_PMT 18
|
||||
#define DOCT_WORD_WRAP 19
|
||||
#define DOCT_UNDERLINE 20
|
||||
#define DOCT_INVERT 21
|
||||
#define DOCT_BLINK 22
|
||||
#define DOCT_SHIFTED_X 23
|
||||
#define DOCT_SHIFTED_Y 24
|
||||
#define DOCT_CURSOR_MOVEMENT 25
|
||||
#define DOCT_ANCHOR 26
|
||||
#define DOCT_LINK 27
|
||||
#define DOCT_BUTTON 28
|
||||
#define DOCT_CHECK_BOX 29
|
||||
#define DOCT_MACRO 30
|
||||
#define DOCT_MENU_VAL 31
|
||||
#define DOCT_HEX_ED 32
|
||||
#define DOCT_HIDE_START 33
|
||||
#define DOCT_HIDE_END 34
|
||||
#define DOCT_TREE 35
|
||||
#define DOCT_SPRITE 36
|
||||
#define DOCT_INS_BINARY 37
|
||||
#define DOCT_INS_BINARY_TYPE 38
|
||||
#define DOCT_INS_BINARY_SIZE 39
|
||||
#define DOCT_BPT 40
|
||||
#define DOCT_SONG 41
|
||||
#define DOCT_HIGHLIGHT 42
|
||||
#define DOCT_LOCK_TO_PAGE 43
|
||||
#define DOCT_LOCK_TO_CENTER 44
|
||||
#define DOCT_HTML_IMG 45
|
||||
#define DOCT_HTML_VIDEO 46
|
||||
#define DOCT_HTML_CODE 47
|
||||
#define DOCT_ERROR 48
|
||||
|
||||
#define DOCT_NUM_TYPES 60
|
||||
#define DOCT_NUM_TYPES 49
|
||||
|
||||
//CDocEntry.type flags upper bits
|
||||
#define DOCET_BLINK ATTRF_BLINK
|
||||
@@ -1124,9 +1098,9 @@ class CBpt
|
||||
#define DOCEt_UNDERLINE ATTRf_UNDERLINE
|
||||
|
||||
#define DOCG_DBL_BUF_FLAGS (DOCF_OVERSTRIKE|DOCF_PLAIN_TEXT|DOCF_PLAIN_TEXT_WITH_TABS| \
|
||||
DOCF_MIN_SIZE|DOCF_NO_CURSOR|DOCF_FORM|DOCF_ATTR_BY_PRT| \
|
||||
DOCF_ATTR_BY_FILENAME|DOCF_DBL_DOLLARS|DOCF_DONT_SWAP_OUT| \
|
||||
DOCF_DO_FULL_REFRESH|DOCF_AUX_DOC|DOCF_HIDE_CURSOR|DOCF_CARRIAGE_RETURN)
|
||||
DOCF_MIN_SIZE|DOCF_NO_CURSOR|DOCF_FORM| \
|
||||
DOCF_DBL_DOLLARS|DOCF_DONT_SWAP_OUT| \
|
||||
DOCF_DO_FULL_REFRESH|DOCF_BORDER_DOC|DOCF_HIDE_CURSOR|DOCF_CARRIAGE_RETURN)
|
||||
|
||||
//CDocEntry.flag flags
|
||||
#define DOCEF1_AUX_STR 1
|
||||
@@ -1275,7 +1249,6 @@ class CBpt
|
||||
#define DOCBT_GENERIC_DATA 1
|
||||
#define DOCBT_CSPRITE 2
|
||||
#define DOCBT_DEBUG_LINES 3
|
||||
#define DOCBT_INDENTS 4
|
||||
|
||||
public class CDocBin
|
||||
{
|
||||
@@ -1297,18 +1270,32 @@ public class CDocBin
|
||||
|
||||
#define DOCSSF_BPT 8
|
||||
|
||||
#define TERM_ATTR_TEXT WHITE<<4+BLUE
|
||||
#define TERM_ATTR_BORDER WHITE<<4+LTBLUE
|
||||
#define DOC_ATTR_DFT_TEXT WHITE<<4+BLACK
|
||||
|
||||
#define DOC_COLOR_ALT_TEXT LTGRAY
|
||||
#define DOC_COLOR_LINK RED
|
||||
#define DOC_COLOR_MACRO LTBLUE
|
||||
#define DOC_COLOR_ANCHOR DKGRAY
|
||||
#define DOC_COLOR_HIDDEN DKGRAY
|
||||
#define DOC_COLOR_TREE PURPLE
|
||||
#define DOC_COLOR_PMT GREEN
|
||||
#define DOC_COLOR_BIN CYAN
|
||||
#define DOC_COLOR_KEYWORD BLUE
|
||||
#define DOC_COLOR_KEYWORD2 LTRED
|
||||
#define DOC_COLOR_COMMENT GREEN
|
||||
#define DOC_COLOR_QUOTE BROWN
|
||||
|
||||
public class CDocSettings
|
||||
{
|
||||
CDocSettings *next,*last;
|
||||
U0 start;
|
||||
I16 left_margin,right_margin,indent;
|
||||
U16 page_len,header,footer;
|
||||
I8 shifted_x,shifted_y,pad[2];
|
||||
I8 shifted_x,shifted_y;
|
||||
U8 state,comment_depth,paren_depth,brace_depth;
|
||||
U8 cur_text_attr,dft_text_attr,alt_text_attr,link_attr,
|
||||
macro_attr,anchor_attr,hidden_attr,tree_attr,
|
||||
user_attr,bin_attr,keyword_attr,
|
||||
keyword2_attr,comment_attr,quote_attr,pad[2];
|
||||
U8 cur_text_attr,dft_text_attr;
|
||||
};
|
||||
|
||||
#define DOC_DFT MIN_I32
|
||||
@@ -1319,6 +1306,7 @@ public class CDocEntryBase
|
||||
//cmds like the text cmd which
|
||||
//don't require the full CDocEntry structure.
|
||||
CDocEntryBase *next,*last;
|
||||
U8 *tag;
|
||||
union {
|
||||
U8 type_u8; //this stores the code
|
||||
U32 type; //these store attr flags
|
||||
@@ -1333,7 +1321,6 @@ public class CDocEntryBase
|
||||
//these, you do not know the current state.
|
||||
//Margins will change to allow multiple columns
|
||||
//of text on the same page. (cursor move back up the page.)
|
||||
|
||||
CDocSettings *settings;
|
||||
|
||||
I64 user_data;
|
||||
@@ -1341,11 +1328,6 @@ public class CDocEntryBase
|
||||
|
||||
public class CDocEntry:CDocEntryBase
|
||||
{
|
||||
union {
|
||||
U8 *tag;
|
||||
I64 hex_ed_width;
|
||||
};
|
||||
|
||||
union {
|
||||
I64 attr;
|
||||
I64 cursor_x_offset;
|
||||
@@ -1368,6 +1350,7 @@ public class CDocEntry:CDocEntryBase
|
||||
U8 *bin_ptr_link;
|
||||
U8 *html_link;
|
||||
U8 *my_fmt_data;
|
||||
I64 hex_ed_width;
|
||||
union {
|
||||
I32 scroll_len;
|
||||
I32 width;
|
||||
@@ -1388,6 +1371,7 @@ public class CDocEntry:CDocEntryBase
|
||||
#define DOF_INTERCEPT_TASK_END 2
|
||||
#define DOF_DONT_HOME 4
|
||||
#define DOF_WIN_MAX 8
|
||||
#define DOF_DONT_TEXT_ATTR 16
|
||||
|
||||
class CEdFindText
|
||||
{
|
||||
@@ -1427,22 +1411,21 @@ class CEdFileName
|
||||
#define DOCF_IN_DOLLAR 0x20
|
||||
#define DOCF_MORE 0x40
|
||||
#define DOCF_FORM 0x80
|
||||
#define DOCF_ATTR_BY_PRT 0x100
|
||||
#define DOCF_ATTR_BY_FILENAME 0x200
|
||||
#define DOCF_DBL_DOLLARS 0x400
|
||||
#define DOCF_NULL_GRAB_SCROLL 0x800
|
||||
#define DOCF_BACKWARD_MOVEMENT 0x1000
|
||||
#define DOCF_HAS_SONG 0x2000
|
||||
#define DOCF_UNDO_DIRTY 0x4000
|
||||
#define DOCF_ALLOW_UNDO 0x8000
|
||||
#define DOCF_SUPERSCRIPT_MODE 0x10000
|
||||
#define DOCF_SUBSCRIPT_MODE 0x20000
|
||||
#define DOCF_DONT_SWAP_OUT 0x40000
|
||||
#define DOCF_DONT_SHOW 0x80000
|
||||
#define DOCF_DO_FULL_REFRESH 0x100000
|
||||
#define DOCF_BREAK_UNLOCKED 0x200000
|
||||
#define DOCF_AUX_DOC 0x400000
|
||||
#define DOCF_HIDE_CURSOR 0x800000 //use $LK,"DocCursor","MN:DocCursor"$
|
||||
#define DOCF_DBL_DOLLARS 0x100
|
||||
#define DOCF_NULL_GRAB_SCROLL 0x200
|
||||
#define DOCF_BACKWARD_MOVEMENT 0x400
|
||||
#define DOCF_HAS_SONG 0x800
|
||||
#define DOCF_UNDO_DIRTY 0x1000
|
||||
#define DOCF_ALLOW_UNDO 0x2000
|
||||
#define DOCF_SUPERSCRIPT_MODE 0x4000
|
||||
#define DOCF_SUBSCRIPT_MODE 0x8000
|
||||
#define DOCF_DONT_SWAP_OUT 0x10000
|
||||
#define DOCF_DONT_SHOW 0x20000
|
||||
#define DOCF_DO_FULL_REFRESH 0x40000
|
||||
#define DOCF_BREAK_UNLOCKED 0x80000
|
||||
#define DOCF_BORDER_DOC 0x100000
|
||||
#define DOCF_HIDE_CURSOR 0x200000 //use $LK,"DocCursor","MN:DocCursor"$
|
||||
//2 unused flags
|
||||
|
||||
#define DOCF_HIGHLIGHT DOCEF1_HIGHLIGHT
|
||||
#define DOCF_LOCK_TO_PAGE DOCEF1_LOCK_TO_PAGE
|
||||
@@ -1464,22 +1447,21 @@ class CEdFileName
|
||||
#define DOCf_IN_DOLLAR 5
|
||||
#define DOCf_MORE 6
|
||||
#define DOCf_FORM 7
|
||||
#define DOCf_ATTR_BY_PRT 8
|
||||
#define DOCf_ATTR_BY_FILENAME 9
|
||||
#define DOCf_DBL_DOLLARS 10
|
||||
#define DOCf_NULL_GRAB_SCROLL 11
|
||||
#define DOCf_BACKWARD_MOVEMENT 12
|
||||
#define DOCf_HAS_SONG 13
|
||||
#define DOCf_UNDO_DIRTY 14
|
||||
#define DOCf_ALLOW_UNDO 15
|
||||
#define DOCf_SUPERSCRIPT_MODE 16
|
||||
#define DOCf_SUBSCRIPT_MODE 17
|
||||
#define DOCf_DONT_SWAP_OUT 18
|
||||
#define DOCf_DONT_SHOW 19
|
||||
#define DOCf_DO_FULL_REFRESH 20
|
||||
#define DOCf_BREAK_UNLOCKED 21
|
||||
#define DOCf_AUX_DOC 22
|
||||
#define DOCf_HIDE_CURSOR 23 //use $LK,"DocCursor","MN:DocCursor"$
|
||||
#define DOCf_DBL_DOLLARS 8
|
||||
#define DOCf_NULL_GRAB_SCROLL 9
|
||||
#define DOCf_BACKWARD_MOVEMENT 10
|
||||
#define DOCf_HAS_SONG 11
|
||||
#define DOCf_UNDO_DIRTY 12
|
||||
#define DOCf_ALLOW_UNDO 13
|
||||
#define DOCf_SUPERSCRIPT_MODE 14
|
||||
#define DOCf_SUBSCRIPT_MODE 15
|
||||
#define DOCf_DONT_SWAP_OUT 16
|
||||
#define DOCf_DONT_SHOW 17
|
||||
#define DOCf_DO_FULL_REFRESH 18
|
||||
#define DOCf_BREAK_UNLOCKED 19
|
||||
#define DOCf_BORDER_DOC 20
|
||||
#define DOCf_HIDE_CURSOR 21 //use $LK,"DocCursor","MN:DocCursor"$
|
||||
//2 unused flags
|
||||
|
||||
#define DOCf_HIGHLIGHT DOCEf1_HIGHLIGHT
|
||||
#define DOCf_LOCK_TO_PAGE DOCEf1_LOCK_TO_PAGE
|
||||
@@ -1508,7 +1490,6 @@ class CDocUndo
|
||||
#define DOCM_CANCEL (-1)
|
||||
|
||||
#define DOC_SIGNATURE_VAL 'DocS'
|
||||
#define DOC_IN_QUE_SIGNATURE_VAL 'DocQ'
|
||||
|
||||
#define DOC_RECALC_ALL 0
|
||||
#define DOC_RECALC_PARTIAL 1
|
||||
@@ -1529,18 +1510,18 @@ public class CDoc //Linked Text File header
|
||||
U8 *dollar_buf;
|
||||
CTask *win_task,*mem_task;
|
||||
CDocEntry *recalc_start;
|
||||
U32 start_text_attr;
|
||||
I32 page_line_num;
|
||||
I32 x,y,min_x,max_x,min_y,max_y;
|
||||
I64 undo_cnt;
|
||||
I32 undo_cnt;
|
||||
I64 line,col,best_d;
|
||||
I64 old_win_top,old_win_bottom,
|
||||
old_win_left,old_win_right;
|
||||
|
||||
I64 cmd_U8;
|
||||
U32 doc_signature,doc_in_que_signature;
|
||||
|
||||
I32 max_entries,ww_lines_back,cur_bin_num,pad;
|
||||
U32 doc_signature;
|
||||
I32 max_entries,ww_lines_back,cur_bin_num;
|
||||
|
||||
I64 refresh_cnt;
|
||||
CTask *owning_task;
|
||||
CEdFindText *find_replace;
|
||||
@@ -1560,16 +1541,15 @@ public class CDoc //Linked Text File header
|
||||
Bool (*user_put_key)(CDoc *doc,U8 *data,I64 ch,I64 sc);
|
||||
Bool (*user_put_s)(CDoc *doc,U8 *data,U8 *st);
|
||||
|
||||
CDoc *next_doc,*last_doc;
|
||||
CDoc *parent_doc;
|
||||
U8 desc[8]; //Be careful -- only 7 characters and terminator
|
||||
|
||||
CDocBin bin_root;
|
||||
CDocSettings settings_root;
|
||||
CDocBin bin_root; //size & 7 ==4
|
||||
CDocSettings settings_root; //size & 7 ==4
|
||||
CDocUndo undo_root;
|
||||
|
||||
I64 user_data;
|
||||
#assert !($$&7)
|
||||
U0 pad;#assert !($$&7) //(compiler lags one token)
|
||||
};
|
||||
|
||||
//MGetS flags
|
||||
@@ -1627,42 +1607,39 @@ class CLexUndef
|
||||
CHashExport *hash;
|
||||
};
|
||||
|
||||
#define ICF_R_TO_F64 0x0000000001
|
||||
#define ICF_R_TO_INT 0x0000000002
|
||||
#define ICF_P1_TO_F64 0x0000000004
|
||||
#define ICF_P1_TO_INT 0x0000000008
|
||||
#define ICF_P2_TO_F64 0x0000000010
|
||||
#define ICF_P2_TO_INT 0x0000000020
|
||||
#define ICF_P3_TO_F64 0x0000000040
|
||||
#define ICF_P3_TO_INT 0x0000000080
|
||||
#define ICF_USE_F64 0x0000000100
|
||||
#define ICF_USE_UNSIGNED 0x0000000200
|
||||
#define ICF_USE_INT 0x0000000400 //highest priority
|
||||
#define ICF_NO_DEPEND_RESULT 0x0000000800
|
||||
#define ICF_CODE_FINAL 0x0000001000
|
||||
#define ICF_NOT_ADDR 0x0000002000
|
||||
#define ICF_SHORT_JMP 0x0000004000
|
||||
#define ICF_P1_FIRST 0x0000008000
|
||||
#define ICF_PUSH_RESULT 0x0000010000
|
||||
#define ICF_TRACE 0x0000020000
|
||||
#define ICF_R_WAS_STK 0x0000040000
|
||||
#define ICF_P1_WAS_STK 0x0000080000
|
||||
#define ICF_P2_WAS_STK 0x0000100000
|
||||
#define ICF_P3_WAS_STK 0x0000200000
|
||||
#define ICF_PUSH_CMP 0x0000400000 //for 50<i<j<=100 expressions
|
||||
#define ICF_POP_CMP 0x0000800000 //for 50<i<j<=100 expressions
|
||||
#define ICF_DEPEND_RESULT 0x0001000000
|
||||
#define ICF_SWAP 0x0002000000
|
||||
#define ICf_DONT_PUSH_FLOAT0 26 // 4 bits
|
||||
#define ICf_DONT_POP_FLOAT0 30 // 4 bits
|
||||
#define ICF_ALTERNATE_TEMPLATE 0x0400000000
|
||||
#define ICF_LOCK 0x0800000000
|
||||
#define ICf_LOCK 35
|
||||
#define ICF_NO_RIP 0x1000000000
|
||||
#define ICF_DEL_PREVIOUS_INS 0x2000000000
|
||||
#define ICF_PREVIOUS_DELETED 0x4000000000
|
||||
#define ICF_DONT_RESTORE 0x8000000000
|
||||
#define ICF_NO_CVT_MASK 0xFFFFFFFF00
|
||||
#define ICF_R_TO_F64 0x000000001
|
||||
#define ICF_R_TO_INT 0x000000002
|
||||
#define ICF_P1_TO_F64 0x000000004
|
||||
#define ICF_P1_TO_INT 0x000000008
|
||||
#define ICF_P2_TO_F64 0x000000010
|
||||
#define ICF_P2_TO_INT 0x000000020
|
||||
#define ICF_USE_F64 0x000000040
|
||||
#define ICF_USE_UNSIGNED 0x000000080
|
||||
#define ICF_USE_INT 0x000000100 //highest priority
|
||||
#define ICF_NO_DEPEND_RESULT 0x000000200
|
||||
#define ICF_CODE_FINAL 0x000000400
|
||||
#define ICF_NOT_ADDR 0x000000800
|
||||
#define ICF_SHORT_JMP 0x000001000
|
||||
#define ICF_P1_FIRST 0x000002000
|
||||
#define ICF_PUSH_RESULT 0x000004000
|
||||
#define ICF_TRACE 0x000008000
|
||||
#define ICF_R_WAS_STK 0x000010000
|
||||
#define ICF_P1_WAS_STK 0x000020000
|
||||
#define ICF_P2_WAS_STK 0x000040000
|
||||
#define ICF_PUSH_CMP 0x000080000 //for 50<i<j<=100 expressions
|
||||
#define ICF_POP_CMP 0x000100000 //for 50<i<j<=100 expressions
|
||||
#define ICF_DEPEND_RESULT 0x000200000
|
||||
#define ICF_SWAP 0x000400000
|
||||
#define ICf_DONT_PUSH_FLOAT0 23 // 3bits
|
||||
#define ICf_DONT_POP_FLOAT0 26 // 3bits
|
||||
#define ICF_ALTERNATE_TEMPLATE 0x020000000
|
||||
#define ICF_LOCK 0x040000000
|
||||
#define ICf_LOCK 30
|
||||
#define ICF_NO_RIP 0x080000000
|
||||
#define ICF_DEL_PREVIOUS_INS 0x100000000
|
||||
#define ICF_PREVIOUS_DELETED 0x200000000
|
||||
#define ICF_DONT_RESTORE 0x400000000
|
||||
#define ICF_NO_CVT_MASK 0x7FFFFFF00
|
||||
|
||||
#define IC_BODY_SIZE 48
|
||||
|
||||
@@ -1678,8 +1655,9 @@ class CICArg
|
||||
|
||||
class CICTreeLinks
|
||||
{
|
||||
CHashClass *p1c,*p2c,*p3c;
|
||||
CIntermediateCode *p1t,*p2t,*p3t;
|
||||
CHashClass *p1c,*p2c;
|
||||
CIntermediateCode *p1t,*p2t;
|
||||
CHashClass *class2;
|
||||
};
|
||||
|
||||
class CIntermediateCode
|
||||
@@ -1697,14 +1675,24 @@ class CIntermediateCode
|
||||
CHashClass *ic_class2;
|
||||
|
||||
U32 ic_line;
|
||||
I8 ic_indent_level,pad[3];
|
||||
CICArg p1,p2,p3,r;
|
||||
CICArg p1,p2,r;
|
||||
|
||||
U8 *ic_ext_body;
|
||||
union {
|
||||
U8 ic_body[IC_BODY_SIZE];
|
||||
|
||||
//Tree Links are created in OptPass012. An ADD opcode, for exmaple,
|
||||
//points back to its two earlier addend instructions -- not MAlloced,
|
||||
//just pointers to previous CIntermediate codes in the array.
|
||||
|
||||
//Tree links get destroyed during Pass789A when they get overwrites
|
||||
//by machine code. (Saves room to union the output machine code buffer
|
||||
//with these links, since they are not needed after pass4.
|
||||
|
||||
//Tree links are mostly used during 012 and 3 for determining types.
|
||||
CICTreeLinks t;
|
||||
};
|
||||
U0 pad;#assert !($$&7) //(compiler lags one token)
|
||||
};
|
||||
|
||||
class CPrsStk
|
||||
@@ -1871,7 +1859,7 @@ class CAsmUnresolvedRef
|
||||
//reserved
|
||||
#define EIE_ABS_ADDR 32
|
||||
#define EIE_HEAP_GLBL 33
|
||||
//See $LK,"::/TempleOS/Adam/BinRep.CPP","FL:::/TempleOS/Adam/BinRep.CPP"$
|
||||
//See $LK,"::/TempleOS/Adam/Utils/BinRep.CPP","FL:::/TempleOS/Adam/Utils/BinRep.CPP"$
|
||||
|
||||
class CExeImportExport
|
||||
{
|
||||
@@ -1922,7 +1910,6 @@ class CExe
|
||||
CExeHeapGlbl *heap_glbls;
|
||||
};
|
||||
|
||||
|
||||
//Opcode Modifier
|
||||
#define OM_NO 0
|
||||
#define OM_CB 1
|
||||
@@ -2080,14 +2067,13 @@ class CExe
|
||||
#define LF_RAX 0x0080000000
|
||||
#define LF_USE_LAST_U16 0x0100000000
|
||||
#define LF_LAST_WAS_DOT 0x0200000000
|
||||
#define LF_INSIDE_EXPRESSION 0x0400000000
|
||||
#define LF_AOT_COMPILE 0x0800000000
|
||||
#define Lf_AOT_COMPILE 35
|
||||
#define LF_NO_ABSS 0x1000000000
|
||||
#define LF_PAREN 0x2000000000
|
||||
#define Lf_PAREN 37
|
||||
#define LF_CLASS_IP 0x4000000000
|
||||
#define LF_DONT_MAKE_RESULT 0x8000000000
|
||||
#define LF_AOT_COMPILE 0x0400000000
|
||||
#define Lf_AOT_COMPILE 34
|
||||
#define LF_NO_ABSS 0x0800000000
|
||||
#define LF_PAREN 0x1000000000
|
||||
#define Lf_PAREN 36
|
||||
#define LF_CLASS_IP 0x2000000000
|
||||
#define LF_DONT_MAKE_RESULT 0x4000000000
|
||||
#define LEX_MAX_IDENT 134 //Max is 132
|
||||
#define LFN_CNT 8
|
||||
#define LFN_STK_CNT 32
|
||||
@@ -2131,6 +2117,18 @@ class CLexCodeBlkCtrl
|
||||
|
||||
#define NUM_REGS 16
|
||||
|
||||
class CLexHashTableContext
|
||||
{
|
||||
CLexHashTableContext *next;
|
||||
I64 old_flags;
|
||||
I64 hash_mask;
|
||||
CHashFun *local_var_lst;
|
||||
CHashTable *hash_table_lst;
|
||||
CHashTable *define_hash_table;
|
||||
CHashTable *local_hash_table;
|
||||
CHashTable *glbl_hash_table;
|
||||
};
|
||||
|
||||
public class CLex
|
||||
{
|
||||
CLex *next,*last;
|
||||
@@ -2146,23 +2144,14 @@ public class CLex
|
||||
U8 *cur_index;
|
||||
I64 last_U16;
|
||||
I64 min_line,max_line,last_line_num;
|
||||
I64 expression_start_line_num;
|
||||
I64 indent_level,temp_indent_level;
|
||||
I64 braces_cnt;
|
||||
I64 statement_cnt;
|
||||
I64 lock_cnt;
|
||||
U32 *alpha_numeric_bitmap;
|
||||
CQueVectU8 *indent_que_vect;
|
||||
CHashTable *define_hash_table;
|
||||
CHashTable *local_hash_table;
|
||||
CHashTable *glbl_hash_table;
|
||||
CHashTable *stream_parent_glbl_hash_table;
|
||||
I64 hash_mask;
|
||||
CHashTable *hash_table_lst;
|
||||
CLexHashTableContext htc;
|
||||
CHashGeneric *hash_entry;
|
||||
CAbsCntsI64 abs_cnts;
|
||||
CLexUndef *undef_hash_entry;
|
||||
CHashFun *local_var_lst;
|
||||
CMemberLst *local_var_entry;
|
||||
CCodeBlkMisc *lb_leave;
|
||||
U8 *cur_buf_ptr;
|
||||
@@ -2189,7 +2178,7 @@ public class CLex
|
||||
U0 end_of_zeroed_members;
|
||||
CLexFile lfns[LFN_CNT];
|
||||
CLexFile stk[LFN_STK_CNT];
|
||||
#assert !($$&7)
|
||||
U0 pad;#assert !($$&7) //(compiler lags one token)
|
||||
};
|
||||
|
||||
|
||||
@@ -2202,7 +2191,7 @@ class CPCIDev
|
||||
U8 *vendor_str,*dev_id_str;
|
||||
};
|
||||
|
||||
#define NATIVE_XSUM 0xA5CF3796
|
||||
#define TEMPLEOS_XSUM 0xA5CF3796
|
||||
#define FILENAME_MASK_JIT "*.CPP*;*.HPP*"
|
||||
#define FILENAME_MASK_AOT "*.CPP*;*.HPP*;*.PRJ*"
|
||||
#define FILENAME_MASK_SRC "*.CPP*;*.HPP*;*.AUT*;*.PRJ*"
|
||||
@@ -2233,7 +2222,7 @@ public class CMasterBoot
|
||||
public class CBootStruct
|
||||
{
|
||||
U8 jump_and_nop[3];
|
||||
U8 signature; //MBR_PT_NATIVE=0x88
|
||||
U8 signature; //MBR_PT_REDSEA=0x88
|
||||
U16 U8s_per_sect;
|
||||
U16 sects_per_cluster;
|
||||
I64 sects;
|
||||
@@ -2534,7 +2523,7 @@ class CATARep
|
||||
|
||||
//See $LK,"ST_PRT_TYPES","MN:ST_PRT_TYPES"$
|
||||
#define PT_NULL 0
|
||||
#define PT_NATIVE 1 //Supported
|
||||
#define PT_REDSEA 1 //Supported
|
||||
#define PT_FAT32 2 //Supported except for short names, to some degree
|
||||
#define PT_ISO9660 3 //Supported (CD-ROM)
|
||||
#define PT_ISO13490 4 //Not Supported (CD-ROM)
|
||||
@@ -2553,7 +2542,7 @@ class CATARep
|
||||
#define MBR_PT_FAT32e 0x8B
|
||||
#define MBR_PT_FAT32f 0x8C
|
||||
#define MBR_PT_NTFS 0x07
|
||||
#define MBR_PT_NATIVE 0x88
|
||||
#define MBR_PT_REDSEA 0x88
|
||||
|
||||
public class CFreeLst
|
||||
{
|
||||
@@ -2565,7 +2554,7 @@ public class CFreeLst
|
||||
|
||||
#define PRT_SIGNATURE_VAL 'PTSV'
|
||||
public class CPrt
|
||||
{//Native Partition
|
||||
{
|
||||
//Don't access ->drive directly in case a drive has been remapped.
|
||||
//Use $LK,"Prt2Drv","MN:Prt2Drv"$().
|
||||
I64 locked_flags;
|
||||
@@ -2694,9 +2683,28 @@ class CMemUsedAllocated
|
||||
#endif
|
||||
|
||||
|
||||
//TempleOS does not mess with page tables
|
||||
//after boot $LK,"SYS_INIT_MEM","MN:SYS_INIT_MEM"$ identity maps.
|
||||
//PAGE_SIZE is arbitrary, not related to CPU hardware.
|
||||
//TempleOS does not mess with page tables after it
|
||||
//identity-maps them during boot -- $LK,"SYS_INIT_MEM","MN:SYS_INIT_MEM"$.
|
||||
//$LK,"PAGE_SIZE","MN:PAGE_SIZE"$ is arbitrary, and is not related to CPU hardware.
|
||||
//I need some unit for memory allocation so I invented "$LK,"PAGE_SIZE","MN:PAGE_SIZE"$".
|
||||
//
|
||||
//All virtual addresses are identical to physical, always.
|
||||
//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 use except the first 2 Meg.
|
||||
//0xA0000-0xBFFFF must be write thru. Hardware pages
|
||||
//don't matter except the caching bit. Remember, it is ring-0-only
|
||||
//and identity-mapped! Do I need to repeat?
|
||||
//Ring-0-only and 100% identity-mapped, all the time.
|
||||
//
|
||||
//All code is placed in just the lowest 2 Gig, so the CALL REL32
|
||||
//instruction 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.
|
||||
|
||||
#define PAGE_BITS 9
|
||||
#define PAGE_SIZE (1<<PAGE_BITS)
|
||||
|
||||
@@ -2902,6 +2910,7 @@ public class CSnap
|
||||
};
|
||||
|
||||
#define TSF_SAME_SONG 1
|
||||
#define TASK_TITLE_LEN 127
|
||||
|
||||
class CTaskSettings
|
||||
{
|
||||
@@ -2913,18 +2922,18 @@ class CTaskSettings
|
||||
F64 win_max_refresh;
|
||||
I64 scroll_x,scroll_y,scroll_z;
|
||||
CSnap snap;
|
||||
U32 win_inhibit;
|
||||
U8 text_attr;
|
||||
U8 border_attr;
|
||||
U8 doc_cur_attr;
|
||||
U8 doc_aux_attr;
|
||||
CBGR palette4[16];
|
||||
U32 win_inhibit;;
|
||||
U8 text_attr, title_src;
|
||||
U8 border_attr,border_src;
|
||||
U8 task_title[TASK_TITLE_LEN+1];
|
||||
Bool border;
|
||||
Bool preempt;
|
||||
Bool cursor;
|
||||
Bool scroll;
|
||||
Bool wordstat;
|
||||
U8 pad[3];
|
||||
U0 pad;#assert !($$&7) //(compiler lags one token)
|
||||
};
|
||||
|
||||
#define NUM_PROGRESS_BARS 4
|
||||
@@ -2935,6 +2944,18 @@ class CProgress
|
||||
U8 desc[PROGRESS_DESC_LEN+1];
|
||||
};
|
||||
|
||||
//Border ATTR src
|
||||
#define BDS_CONST 0
|
||||
#define BDS_CUR_PRT 1
|
||||
#define BDS_ED_FILENAME_PRT 2
|
||||
|
||||
//Task title src
|
||||
#define TTS_CONST 0
|
||||
#define TTS_LOCKED_CONST 1 //This is not strictly enforced
|
||||
#define TTS_TASK_NAME 2
|
||||
#define TTS_ED_FILENAME 3
|
||||
#define TTS_CUR_LEX 4
|
||||
|
||||
// TASK task flags
|
||||
#define TASKf_KILL_TASK 0
|
||||
#define TASKf_SUSPENDED 1
|
||||
@@ -2945,15 +2966,14 @@ class CProgress
|
||||
#define TASKf_FILTER_INPUT 6
|
||||
#define TASKf_HAS_SONG 7
|
||||
#define TASKf_NOT_RAW 8
|
||||
#define TASKf_LOCK_TITLE 9
|
||||
#define TASKf_DISABLE_BPTS 10
|
||||
#define TASKf_AWAITING_MSG 11
|
||||
#define TASKf_CURRENTLY_RUNNING 12
|
||||
#define TASKf_BREAK_LOCKED 13
|
||||
#define TASKf_PENDING_BREAK 14
|
||||
#define TASKf_BREAK_TO_SHIFT_ESC 15
|
||||
#define TASKf_INIT_EXT 16
|
||||
#define TASKf_KILL_AFTER_DBG 17
|
||||
#define TASKf_DISABLE_BPTS 9
|
||||
#define TASKf_AWAITING_MSG 10
|
||||
#define TASKf_CURRENTLY_RUNNING 11
|
||||
#define TASKf_BREAK_LOCKED 12
|
||||
#define TASKf_PENDING_BREAK 13
|
||||
#define TASKf_BREAK_TO_SHIFT_ESC 14
|
||||
#define TASKf_INIT_EXT 15
|
||||
#define TASKf_KILL_AFTER_DBG 16
|
||||
|
||||
//locked flags
|
||||
#define TASKLf_TASK_LOCK 0
|
||||
@@ -2965,15 +2985,11 @@ class CProgress
|
||||
#define DISPLAYf_WIN_ON_TOP 4
|
||||
#define DISPLAYf_CHILDREN_NOT_ON_TOP 5
|
||||
#define DISPLAYf_HAS_BEEN_RESIZED 6
|
||||
#define DISPLAYf_USER_HAS_BEEN_RESIZED 7
|
||||
|
||||
#define SPAWNF_ADD_TO_QUE 1
|
||||
|
||||
#define TASK_SIGNATURE_VAL 'TskS'
|
||||
#define TASK_IN_QUE_SIGNATURE_VAL 'TskQ'
|
||||
#define TASK_COMBINED_SIGNATURE_VAL (TASK_SIGNATURE_VAL+TASK_IN_QUE_SIGNATURE_VAL<<32)
|
||||
|
||||
#define TASK_TITLE_LEN 127
|
||||
#define TASK_NAME_LEN 31
|
||||
#define TASK_WALLPAPER_DATA_SIZE 128
|
||||
class CTaskStk
|
||||
@@ -2994,7 +3010,8 @@ public class CTask //The Fs segment register points to current CTask
|
||||
|
||||
CHeapCtrl *code_heap,*data_heap;
|
||||
|
||||
CDoc *next_doc,*last_doc;
|
||||
CDoc *put_doc,*display_doc, //When double buffering, these two differ.
|
||||
*border_doc;
|
||||
I64 win_left;
|
||||
I64 win_right;
|
||||
I64 win_top;
|
||||
@@ -3060,10 +3077,11 @@ public class CTask //The Fs segment register points to current CTask
|
||||
U8 task_title[TASK_TITLE_LEN+1];
|
||||
U8 task_name[TASK_NAME_LEN+1];
|
||||
U8 wallpaper_data[TASK_WALLPAPER_DATA_SIZE];
|
||||
|
||||
|
||||
U8 title_src;
|
||||
U8 text_attr;
|
||||
U8 border_attr;
|
||||
U16 win_z_num,pad[2];
|
||||
U8 border_attr,border_src;
|
||||
U16 win_z_num,pad;
|
||||
|
||||
CTaskStk *stk;
|
||||
|
||||
@@ -3111,9 +3129,7 @@ public class CTask //The Fs segment register points to current CTask
|
||||
|
||||
#define MSGF_ALLOW_KEY_DESC 63
|
||||
|
||||
CTaskCmd *next_servant_cmd,*last_servant_cmd;
|
||||
CTaskCmd *next_master_cmd,*last_master_cmd;
|
||||
|
||||
CSrvCtrl srv_ctrl;
|
||||
CLex *next_lex,*last_lex;
|
||||
|
||||
I64 win_old_left;
|
||||
@@ -3132,7 +3148,7 @@ public class CTask //The Fs segment register points to current CTask
|
||||
|
||||
I64 user_data0,user_data1,
|
||||
user_data2,user_data3;
|
||||
#assert !($$&7)
|
||||
U0 pad;#assert !($$&7) //(compiler lags one token)
|
||||
};
|
||||
|
||||
class CTSS
|
||||
@@ -3193,7 +3209,6 @@ class CTSS
|
||||
#define CH_CURSOR 0x05
|
||||
#define CH_BACKSPACE 0x08
|
||||
#define CH_FORM_FEED 0x0C
|
||||
#define CH_CARRIAGE_RETURN 0x0D
|
||||
#define CH_ESC 0x1B
|
||||
#define CH_SHIFT_ESC 0x1C
|
||||
#define CH_SHIFT_SPACE 0x1F
|
||||
@@ -3236,7 +3251,7 @@ class CTSS
|
||||
#define SC_ESC 0x01
|
||||
#define SC_BACKSPACE 0x0E
|
||||
#define SC_TAB 0x0F
|
||||
#define SC_CARRIAGE_RETURN 0x1C
|
||||
#define SC_ENTER 0x1C
|
||||
#define SC_SHIFT 0x2A
|
||||
#define SC_CTRL 0x1D
|
||||
#define SC_ALT 0x38
|
||||
@@ -3303,7 +3318,7 @@ class CTSS
|
||||
#define DCF_SYMMETRY 0x200
|
||||
|
||||
//Must be used with DCF_SYMMETRY set also.
|
||||
//See $LK-A,"::/TempleOS/Demo/GameStarters/BigGuns.CPP"$
|
||||
//See $LK-A,"::/TempleOS/Demo/Games/BigGuns.CPP"$
|
||||
#define DCF_JUST_MIRROR 0x400
|
||||
|
||||
#define DCF_LOCATE_NEAREST 0x800
|
||||
@@ -3394,23 +3409,6 @@ public class CDC
|
||||
I64 db_z; //private
|
||||
};
|
||||
|
||||
public class CGrVectMap
|
||||
{
|
||||
U0 start_saved_area;
|
||||
I32 width,height;
|
||||
U8 r_bits,poly_line_cnt_bits,pad,pad;
|
||||
U32 rect_cnt;
|
||||
U0 end_saved_area;
|
||||
|
||||
CColorROPU32 bkcolor,pad;
|
||||
|
||||
//Array of bit numbers for rectangle starts
|
||||
//Can be regenerated with $LK,"VectMapRectStartBits","MN:VectMapRectStartBits"$()
|
||||
U32 *rect_start_bits;
|
||||
|
||||
U8 *body;
|
||||
};
|
||||
|
||||
class CRAXRBCRCXRDX
|
||||
{
|
||||
I64 rax,rbx,rcx,rdx;
|
||||
@@ -3620,7 +3618,6 @@ public class CCPU //The Gs segment register points to current CCPU
|
||||
F64 idle_factor;
|
||||
I64 total_jiffies;
|
||||
CTask *seth_task,*idle_task;
|
||||
CMPCmdCtrl cmd_ctrl;
|
||||
I64 tr; //task register
|
||||
I64 swap_cnter;
|
||||
U0 (*timer_irq_chain)(CTask *task);
|
||||
@@ -3628,7 +3625,7 @@ public class CCPU //The Gs segment register points to current CCPU
|
||||
CTSS *tss;
|
||||
U8 wallpaper_data[CPU_WALLPAPER_DATA_SIZE]; //doubles as start-up stk
|
||||
I64 start_stk[8];
|
||||
#assert !($$&7)
|
||||
U0 pad;#assert !($$&7) //(compiler lags one token)
|
||||
};
|
||||
|
||||
#define KDF_HAS_DESCS 1
|
||||
@@ -3698,30 +3695,12 @@ POP R8 POP RDI POP RSI POP RBP POP RBX POP RDX POP RCX POP RAX
|
||||
#define ST_ERR_ST "$$FG,LTRED$$$$BK,1$$ERROR:$$FG$$$$BK,0$$ "
|
||||
#define ST_WARN_ST "$$FG,RED$$$$BK,1$$WARNING:$$FG$$$$BK,0$$ "
|
||||
|
||||
//snd devs
|
||||
#define SD_PC_SPEAKER 0
|
||||
#define SD_HD_AUDIO 1
|
||||
|
||||
#define SND_SAMPLE_RATE 48000
|
||||
#define SND_SAMPLE_BITS 24
|
||||
#define SND_OCHANNELS 2
|
||||
#define SND_ICHANNELS 2
|
||||
#define SND_OUT_CONTAINER I32
|
||||
#define SND_IN_CONTAINER I16
|
||||
#define SND_BUF_LEN 0x400
|
||||
#define SND_BUF_TIME_mS (SND_BUF_LEN/SND_OCHANNELS*1000.0/SND_SAMPLE_RATE)
|
||||
//buffer byte size is SND_BUF_LEN*sizeof(I32).
|
||||
//It's 24 bit packed in 32 bit containers
|
||||
//There are 2 channels for stereo, so half as many blocks.
|
||||
|
||||
#define WF_NULL 0
|
||||
#define WF_SQUARE 1
|
||||
#define WF_SINE 2
|
||||
#define WF_TRIANGLE 3
|
||||
#define WF_SAWTOOTH 4
|
||||
#define WF_NOISE 5
|
||||
|
||||
#define WF_NUM_WAVEFORMS 6
|
||||
class CSndData
|
||||
{
|
||||
CSndData *next,*last;
|
||||
F64 freq; //Hz
|
||||
F64 time_stamp;
|
||||
};
|
||||
|
||||
//sys_raw_dc_flags flags
|
||||
#define RDCF_IN_DOLLAR 1
|
||||
|
||||
+19
-19
@@ -3,7 +3,7 @@ In this file, syms defined Kernel assembly
|
||||
files are given C+ definitions. This file
|
||||
is included when you compile the kernel, after
|
||||
the assembly files have been assembled, making
|
||||
the C+ definitions available for the C+ Kernel
|
||||
the Holy C definitions available for the Holy C Kernel
|
||||
files. It is also included as part of booting.
|
||||
|
||||
The assembly global labels are stored as HTT_EXPORT_SYS_SYM
|
||||
@@ -58,13 +58,13 @@ public _intern IC_BT Bool Bt(U8 *bit_field,I64 bit);
|
||||
public _intern IC_BTS Bool Bts(U8 *bit_field,I64 bit);
|
||||
public _intern IC_BTR Bool Btr(U8 *bit_field,I64 bit);
|
||||
public _intern IC_BTC Bool Btc(U8 *bit_field,I64 bit);
|
||||
public _intern IC_BEQU Bool BEqu(U8 *bit_field,I64 bit,Bool val);
|
||||
public _extern _BEQU Bool BEqu(U8 *bit_field,I64 bit,Bool val);
|
||||
|
||||
//Locked for (for multitple CPU's)
|
||||
public _intern IC_LBTS Bool LBts(U8 *bit_field,I64 bit);
|
||||
public _intern IC_LBTR Bool LBtr(U8 *bit_field,I64 bit);
|
||||
public _intern IC_LBTC Bool LBtc(U8 *bit_field,I64 bit);
|
||||
public _intern IC_LBEQU Bool LBEqu(U8 *bit_field,I64 bit,Bool val);
|
||||
public _extern _LBEQU Bool LBEqu(U8 *bit_field,I64 bit,Bool val);
|
||||
|
||||
//Scan I64 sized item fwd for first set bit, starting at lowest.
|
||||
//Return -1 if not found.
|
||||
@@ -79,7 +79,7 @@ public _extern _BIT_FIELD_OR_U32 U0 BFieldOrU32(
|
||||
public _extern _BIT_FIELD_EXTRACT_U32 U32 BFieldExtU32(
|
||||
U8 *bit_field,I64 bit,I64 size);
|
||||
|
||||
#help_index "Circular Queue"
|
||||
#help_index "Data Types/Circular Queue"
|
||||
#help_file "::/TempleOS/Doc/Que"
|
||||
public _intern IC_QUE_INIT U0 QueInit(CQue *root);
|
||||
//Ins item into que after predicessor.
|
||||
@@ -94,12 +94,12 @@ public _intern IC_QUE_REM U0 QueRem(CQue *entry);
|
||||
public _intern IC_PREEMPT Bool Preempt(Bool val);
|
||||
|
||||
#help_index "I/O;Processor/IO Port"
|
||||
public _intern IC_INU8 I64 InU8(I64 port);
|
||||
public _intern IC_INU16 I64 InU16(I64 port);
|
||||
public _intern IC_INU32 I64 InU32(I64 port);
|
||||
public _intern IC_OUTU8 U0 OutU8(I64 port, I64 val);
|
||||
public _intern IC_OUTU16 U0 OutU16(I64 port, I64 val);
|
||||
public _intern IC_OUTU32 U0 OutU32(I64 port, I64 val);
|
||||
public _intern IC_IN_U8 I64 InU8(I64 port);
|
||||
public _intern IC_IN_U16 I64 InU16(I64 port);
|
||||
public _intern IC_IN_U32 I64 InU32(I64 port);
|
||||
public _intern IC_OUT_U8 U0 OutU8(I64 port, I64 val);
|
||||
public _intern IC_OUT_U16 U0 OutU16(I64 port, I64 val);
|
||||
public _intern IC_OUT_U32 U0 OutU32(I64 port, I64 val);
|
||||
public _extern _REP_IN_U8 U0 RepInU8(U8 *buf,I64 cnt,I64 port);
|
||||
public _extern _REP_IN_U16 U0 RepInU16(U8 *buf,I64 cnt,I64 port);
|
||||
public _extern _REP_IN_U32 U0 RepInU32(U8 *buf,I64 cnt,I64 port);
|
||||
@@ -108,14 +108,14 @@ public _extern _REP_OUT_U16 U0 RepOutU16(U8 *buf,I64 cnt,I64 port);
|
||||
public _extern _REP_OUT_U32 U0 RepOutU32(U8 *buf,I64 cnt,I64 port);
|
||||
|
||||
#help_index "Memory"
|
||||
|
||||
//Only goes fwd.
|
||||
public _intern IC_MEMCPY U0 MemCpy(U8 *dst,U8 *src,I64 cnt);
|
||||
public _intern IC_MEMSET U8 *MemSet(U8 *dst,I64 val,I64 cnt);
|
||||
public _intern IC_MEMSET U8 *MemSetU8(U8 *dst,I64 val,I64 U8cnt);
|
||||
public _intern IC_MEMSET_U16 U16 *MemSetU16(U8 *dst,I64 val,I64 U16cnt);
|
||||
public _intern IC_MEMSET_U32 U32 *MemSetU32(U8 *dst,I64 val,I64 U32cnt);
|
||||
public _intern IC_MEMSET_U64 U64 *MemSetU64(U8 *dst,I64 val,I64 U64cnt);
|
||||
public _extern _MEMCPY U8 *MemCpy(U8 *dst,U8 *src,I64 cnt);
|
||||
public _extern _MEMCMP I64 MemCmp(U8 *ptr1,U8 *ptr2,I64 cnt);
|
||||
public _extern _MEMSET U8 *MemSet(U8 *dst,I64 val,I64 cnt);
|
||||
public _extern _MEMSET U8 *MemSetU8(U8 *dst,I64 val,I64 U8cnt);
|
||||
public _extern _MEMSET_U16 U16 *MemSetU16(U16 *dst,I64 val,I64 U16cnt);
|
||||
public _extern _MEMSET_U32 U32 *MemSetU32(U32 *dst,I64 val,I64 U32cnt);
|
||||
public _extern _MEMSET_U64 U64 *MemSetU64(U64 *dst,I64 val,I64 U64cnt);
|
||||
public _extern SYS_CODE_BP CBlkPool *sys_code_bp;
|
||||
public _extern SYS_DATA_BP CBlkPool *sys_data_bp;
|
||||
public _extern SYS_HEAP_BASE U32 sys_heap_base;
|
||||
@@ -211,8 +211,8 @@ public _intern IC_TO_I64 I64 ToI64(F64 d); //This truncates
|
||||
public _intern IC_TO_F64 F64 ToF64(I64 i);
|
||||
public _intern IC_TO_BOOL Bool ToBool(I64 i);
|
||||
public _intern IC_ABS_I64 I64 AbsI64(I64 i);
|
||||
public _intern IC_LIMIT_I64 I64 LimitI64(I64 p,I64 lo,I64 hi);
|
||||
public _intern IC_LIMIT_U64 U64 LimitU64(U64 p,U64 lo,U64 hi);
|
||||
public _extern _LIMIT_I64 I64 LimitI64(I64 p,I64 lo,I64 hi);
|
||||
public _extern _LIMIT_U64 U64 LimitU64(U64 p,U64 lo,U64 hi);
|
||||
public _intern IC_SIGN_I64 I64 SignI64(I64 i);
|
||||
public _intern IC_SQR_I64 I64 SqrI64(I64 i);
|
||||
public _intern IC_SQR_U64 U64 SqrU64(U64 i);
|
||||
|
||||
+81
-88
@@ -1,13 +1,8 @@
|
||||
#help_index "Time/CDate"
|
||||
#help_file "::/TempleOS/Doc/TimeDate"
|
||||
public extern CDate local_time_offset;
|
||||
|
||||
#help_index "Time/Jiffies"
|
||||
//18.33333*65536Hz (SYS_TIMER_FREQ)
|
||||
public extern I64 SysTimerRead();
|
||||
|
||||
#help_index "Task"
|
||||
extern U8 *sys_acct;
|
||||
extern CTask *sys_winmgr_task,*sys_task_being_screen_updated;
|
||||
public extern CTask *adam_task;
|
||||
public extern I64 sys_num_spawned_users,sys_num_task_inits;
|
||||
@@ -37,22 +32,14 @@ public extern F64 tS(); //From SysTimerFreq.
|
||||
public extern Bool Blink(F64 Hz=2.5);
|
||||
|
||||
#help_index "Snd"
|
||||
#help_file "::/TempleOS/Doc/Snd"
|
||||
public extern I64 snd_dev;
|
||||
public extern F64 snd_vol,snd_reverb_intensity,snd_reverb_delay;
|
||||
public extern U0 Snd(F64 freq,I64 waveform=WF_SQUARE,F64 amp=1.0);
|
||||
public extern U0 Snd(F64 freq);
|
||||
public extern Bool Mute(Bool val);
|
||||
public extern Bool IsMute();
|
||||
public extern F64 snd_freq;
|
||||
public extern U0 Beep(I64 freq=500,Bool busy=FALSE);
|
||||
public extern Bool IOSnd(Bool val);
|
||||
#help_index "Snd/Snd Files"
|
||||
public extern Bool snd_record;
|
||||
extern U0 (*fp_snd_record)(F64 freq,I64 waveform,F64 amp);
|
||||
#help_index "Snd/HDAudio"
|
||||
public extern U0 (*fp_snd)(F64 freq,I64 waveform,F64 amp);
|
||||
public extern U0 (*fp_snd_fill_buf)(SND_OUT_CONTAINER *buf,I64 buf_num);
|
||||
public extern U0 (*fp_snd_copy_buf)(SND_IN_CONTAINER *buf,I64 buf_num);
|
||||
extern CSndData snd_record_root;
|
||||
|
||||
#help_index "Processor"
|
||||
extern U8 *sys_fault_handlers_code;
|
||||
@@ -82,6 +69,7 @@ public extern Bool IsSysDeterministic();
|
||||
public extern Bool SysDbg(Bool val);
|
||||
public extern Bool SysDeterministic(Bool val);
|
||||
public extern Bool ChkPtr(U8 *ptr);
|
||||
public extern Bool ChkCodePtr(U8 *ptr);
|
||||
public extern Bool ChkOnStk(U8 *ptr,CTask *task=NULL);
|
||||
public extern I64 UnusedStk(CTask *task=NULL);
|
||||
public extern U8 *Caller(I64 num=1);
|
||||
@@ -133,7 +121,7 @@ extern U0 (**fp_ctrl_alt_let_cbs)(I64 sc);
|
||||
extern I64 ctrl_alt_let_in_irq_flags;
|
||||
extern U8 **ctrl_alt_let_descs;
|
||||
extern I64 **ctrl_alt_let_ret_addr; //addr of ret add on stack in kbd irq
|
||||
extern CTaskCmd sys_macro_root;
|
||||
extern CSrvCmd sys_macro_root;
|
||||
extern CKeyDev sys_put_key_root;
|
||||
extern CTask *sys_macro_util_task;
|
||||
extern I64 sys_raw_dc_col,sys_raw_dc_flags;
|
||||
@@ -164,7 +152,7 @@ public extern U0 Spaces(I64 cnt=1);
|
||||
public extern U0 PutErr(U8 *st=NULL);
|
||||
public extern U0 PutWarn(U8 *st=NULL);
|
||||
public extern U0 PutKey(I64 ch,I64 scancode);
|
||||
public extern U0 PutChar(I64 ch);
|
||||
public extern U0 PutChar(U64 ch);
|
||||
public extern U0 PutS(U8 *st);
|
||||
public extern U8 *Bin2Hex(U8 *dst,I64 n;I64 width);
|
||||
public extern U0 PutHex(I64 n,I64 width);
|
||||
@@ -180,7 +168,6 @@ extern I64 mouse_pkt_size;
|
||||
public extern I64 kbd_evt_time;
|
||||
extern Bool kbd_irqs_working;
|
||||
public extern Bool PressAKey();
|
||||
public extern Bool ExitAllApplications();
|
||||
public extern Bool AreYouSure();
|
||||
public extern I64 GetKey(I64 *_scancode=NULL,Bool echo=FALSE,Bool raw_cursor=FALSE);
|
||||
public extern I64 GetChar(I64 *_scancode=NULL,Bool echo=TRUE,Bool raw_cursor=FALSE);
|
||||
@@ -231,7 +218,6 @@ public extern I64 DefineMatch(U8 *src,U8 *lst_name,I64 flags=0,I64 *_ambiguity_o
|
||||
|
||||
#help_index "Memory"
|
||||
#help_file "::/TempleOS/Doc/Mem"
|
||||
public _extern _MEMCMP I64 MemCmp(U8 *ptr1,U8 *ptr2,I64 cnt);
|
||||
public extern I64 MemPageSize(U8 *a)
|
||||
public extern Bool MemPagePresentMark(U8 *a,Bool val);
|
||||
public extern Bool MemLowPagesProtect(Bool val);
|
||||
@@ -240,7 +226,7 @@ public extern U8 *MemBlksUncachedAlloc(I64 *_pages2Meg,CBlkPool *bp=NULL);
|
||||
public extern U8 *MemBlksWriteThroughAlloc(I64 *_pages2Meg,CBlkPool *bp=NULL);
|
||||
public extern U0 MemBlks2MegFree(CMemBlk *m,I64 pages2Meg,CBlkPool *bp=NULL);
|
||||
public extern U8 *MemBlksNonTaskAlloc(I64 *_pages512,CBlkPool *bp=NULL);
|
||||
public extern I64 *MemPtAtPageTableEntry(U8 *a);
|
||||
public extern I64 *MemPageTable(U8 *a);
|
||||
public extern U0 MemBlksNonTaskFree(CMemBlk *m,I64 pages512,CBlkPool *bp=NULL);
|
||||
public _extern _MALLOC U8 *MAlloc(I64 size,CTask *mem_task=NULL);
|
||||
public _extern _FREE U0 Free(U8 *add);
|
||||
@@ -251,16 +237,7 @@ public extern U8 *CAlloc(I64 size,CTask *mem_task=NULL);
|
||||
public extern U8 *MAllocIdentical(U8 *src,CTask *mem_task=NULL);
|
||||
public extern U8 *MAllocAligned(I64 size,I64 alignment,CTask *mem_task=NULL,I64 misalignment=0);
|
||||
public extern U8 *CAllocAligned(I64 size,I64 alignment,CTask *mem_task=NULL,I64 misalignment=0);
|
||||
public extern U0 LinkedLstDel(U8 **_lst);
|
||||
public extern U8 *LinkedLstCopy(U8 **_lst,CTask *mem_task=NULL);
|
||||
public extern I64 LinkedLstCnt(U8 **_lst);
|
||||
public extern I64 LinkedLstSize(U8 **_lst);
|
||||
public extern I64 Scale2Mem(I64 min,I64 max,I64 limit=2*1024*1024*1024);
|
||||
#help_index "Memory;Circular Queue"
|
||||
public extern U0 QueDel(CQue *root,Bool querem=FALSE);
|
||||
public extern CQue *QueCopy(CQue *root,CTask *mem_task=NULL);
|
||||
public extern I64 QueCnt(CQue *root);
|
||||
public extern I64 QueSize(CQue *root);
|
||||
#help_index "Memory/Heap Ctrl"
|
||||
public extern U0 BlkPoolAdd(CBlkPool *bp,CMemBlk *m,I64 pages512);
|
||||
public extern U0 BlkPoolInit(CBlkPool *bp,I64 pages512);
|
||||
@@ -290,10 +267,6 @@ public extern U0 Kill(CTask *task,Bool wait=TRUE);
|
||||
public extern Bool Suspend(CTask *task=NULL,Bool state=TRUE);
|
||||
public extern Bool IsSuspended(CTask *task=NULL);
|
||||
public extern Bool TaskValidate(CTask *task);
|
||||
public extern CTask *Spawn(U0 (*fp_add)(U8 *data),U8 *data=NULL,
|
||||
U8 *task_name=NULL,
|
||||
CTask *parent=NULL, //NULL means adam
|
||||
I64 stk_size=0,I64 flags=SPAWNF_ADD_TO_QUE);
|
||||
public extern U0 TaskQueIns(CTask *task,CTask *pred=NULL);
|
||||
public extern U0 TaskQueRem(CTask *task);
|
||||
public extern U0 TaskWait(CTask *task=NULL);
|
||||
@@ -305,27 +278,31 @@ extern U0 (*fp_update_ctrls)(CTask *task);
|
||||
public extern CTask *SpawnUser(U8 *fmt=NULL,...);
|
||||
extern U0 TaskFinishOff(CTask *task);
|
||||
public extern U0 OverRideSingleUserSwap();
|
||||
#help_index "Task;MultiCore"
|
||||
public extern CTask *Spawn(U0 (*fp_add)(U8 *data),U8 *data=NULL,
|
||||
U8 *task_name=NULL,
|
||||
I64 target_cpu=-1, //-1 means current CPU
|
||||
CTask *parent=NULL, //NULL means adam
|
||||
I64 stk_size=0,I64 flags=1<<SVCf_ADD_TO_QUE);
|
||||
|
||||
#help_index "Task/Requests"
|
||||
public extern U0 SrvCmdDel(CSrvCmd *tempc);
|
||||
public extern U0 TaskRstAwaitingMsg(CTask *task=NULL);
|
||||
public extern CTaskCmd *
|
||||
TaskRqstQue(CTask *servant,CTask *master,
|
||||
U8 *data,I64 flags);
|
||||
public extern I64 ServantCmdsHandler(CTask *task=NULL);
|
||||
public extern I64 ServantUser(U8 *fmt,...);
|
||||
extern U0 ServantUserCmdLine();
|
||||
public extern Bool GetRqstResult(CTaskCmd *rqst=NULL,I64 *_result=NULL);
|
||||
public extern U0 ServantTaskCont();
|
||||
public extern CSrvCmd *TaskExeStrQue(CTask *srv,CTask *master,U8 *data,I64 flags);
|
||||
public extern I64 SrvCmdsHandler(CTask *task=NULL);
|
||||
public extern I64 SrvUser(U8 *fmt,...);
|
||||
extern U0 SrvUserCmdLine();
|
||||
public extern U0 SrvTaskCont();
|
||||
public extern I64 Adam(U8 *fmt,...);
|
||||
public extern U0 AdamLogExcept(I64 argc,I64 *argv);
|
||||
public extern U0 AdamLog(U8 *fmt,...);
|
||||
public extern U0 AdamErr(U8 *fmt,...);
|
||||
#help_index "Task/Text Input"
|
||||
public extern CTaskCmd *
|
||||
TextInputQue(CTask *servant,CTask *master,
|
||||
public extern CSrvCmd *
|
||||
TaskTextInputQue(CTask *srv,CTask *master,
|
||||
U8 *data,I64 flags);
|
||||
#help_index "Task/Text Input;Messages"
|
||||
public extern CTaskCmd *QueMsg(CTask *servant,CTask *master,
|
||||
public extern CSrvCmd *TaskMsgQue(CTask *srv,CTask *master,
|
||||
I64 msg_code,I64 p1,I64 p2,I64 flags);
|
||||
public extern U0 PostMsg(CTask *task,I64 msg_code,I64 p1,I64 p2,I64 flags=0);
|
||||
public extern U0 SendMsg(CTask *task,I64 msg_code,I64 p1,I64 p2,I64 flags=0);
|
||||
@@ -410,44 +387,41 @@ public extern U8 *reverse_bits_table,*set_bits_table;
|
||||
#help_index "Doc/Clipboard"
|
||||
public extern CDoc *sys_clipboard_doc;
|
||||
|
||||
#help_index "Time/CDate"
|
||||
#help_index "Time/Date;Date"
|
||||
#help_file "::/TempleOS/Doc/TimeDate"
|
||||
public extern CDate local_time_offset;
|
||||
public extern U16 mon_start_days1[12];
|
||||
public extern U16 mon_start_days2[12];
|
||||
public extern I64 YearStartDate(I64 year);
|
||||
public extern CDate CDateStruct2CDate(CDateStruct *_ds);
|
||||
public extern U0 CDate2CDateStruct(CDateStruct *_ds,CDate spdt);
|
||||
public extern CDate DateStruct2Date(CDateStruct *_ds);
|
||||
public extern U0 Date2DateStruct(CDateStruct *_ds,CDate cdt);
|
||||
public extern I64 FirstDayOfMon(I64 i);
|
||||
public extern I64 LastDayOfMon(I64 i);
|
||||
public extern I64 FirstDayOfYear(I64 i);
|
||||
public extern I64 LastDayOfYear(I64 i);
|
||||
public extern I64 DayOfWeek(I64 i);
|
||||
public extern CDate GetCurTimeCDate();
|
||||
public extern U0 CDate2ISO1(CISO1Date *dst,CDate spdt);
|
||||
public extern CDate GetCurTimeDate();
|
||||
public extern U0 Date2ISO1(CISO1Date *dst,CDate cdt);
|
||||
public extern U8 *date_fmt_map,*time_fmt_map;
|
||||
public extern U0 DateTimeFmtMapsRst();
|
||||
|
||||
#help_index "File/System"
|
||||
extern U8 sys_temp_filename[136];
|
||||
extern I64 sys_dsk_reads,sys_dsk_writes;
|
||||
|
||||
#help_index "File/System/Cache"
|
||||
extern CCacheBlk *sys_dsk_cache_base,*sys_dsk_cache_ctrl;
|
||||
extern CCacheBlk **sys_dsk_cache_hash_table;
|
||||
extern I64 sys_dsk_cache_size;
|
||||
|
||||
extern U0 DskCacheInit(I64 size_in_U8s);
|
||||
public extern U0 DskCacheInvalidate(CPrt *p);
|
||||
|
||||
#help_index "File/System/BlkDev"
|
||||
public extern CBlkDev *sys_blkdevs;
|
||||
|
||||
#help_index "File/System/Partitions"
|
||||
public extern CPrt *sys_prts;
|
||||
extern CPrt *drv_to_prt[32];
|
||||
|
||||
#help_index "PCI;Info;File/System/Hardware;Device"
|
||||
#help_index "PCI;Info;File/System;Device"
|
||||
public extern I64 ATARep(Bool pmt=TRUE,Bool just_ide=FALSE,CATARep **_root=NULL);
|
||||
|
||||
#help_index "File/System/Hardware"
|
||||
public extern CATARep *ATAIDDrvs(CATARep *root,U8 _dft_drv,CATARep **_ata_drv,CATARep **_atapi_drv);
|
||||
#help_index "File/System"
|
||||
public extern CATARep *ATAIDDrvs(CATARep *root,U8 _sys_acct_drv,CATARep **_ata_drv,CATARep **_atapi_drv);
|
||||
extern CBlkDev *ATAMount(U8 first_drv_let,I64 type,I64 base0,I64 base1,I64 unit);
|
||||
public extern I64 sys_auto_mount_ide_cnt;
|
||||
public extern I64 AutoMountIDE();
|
||||
@@ -467,7 +441,7 @@ public extern U0 Dir(U8 *wild="*",Bool full=FALSE);
|
||||
public extern I64 Del(U8 *wild,Bool print_msg=TRUE);
|
||||
public extern Bool MkDir(U8 *filename);
|
||||
|
||||
#help_index "Info;File/Cmd Line (Typically);Cmd Line (Typically);File/Install Related;Install"
|
||||
#help_index "Info;File/Cmd Line (Typically);Cmd Line (Typically);Install"
|
||||
public extern U0 PrtRep();
|
||||
|
||||
#help_index "File/Program Routines/Low Level"
|
||||
@@ -476,7 +450,7 @@ extern I64 SysDel(U8 *wild,Bool make_mask); //this is dangerous
|
||||
extern Bool CopySingle(U8 *f1,U8 *f2); //Just one file
|
||||
extern U0 CleanMAPBuf(CPrt *p);
|
||||
extern U0 FAT32FreeClusters(CPrt *p,I64 c);
|
||||
extern U0 NativeFSFreeClusters(CPrt *p,I64 c,I64 cnt);
|
||||
extern U0 RedSeaFSFreeClusters(CPrt *p,I64 c,I64 cnt);
|
||||
public extern Bool BlkDevLock(CBlkDev *bdev);
|
||||
public extern Bool PrtLock(CPrt *p);
|
||||
public extern Bool BlkDevUnlock(CBlkDev *bdev,Bool rst=FALSE);
|
||||
@@ -519,6 +493,7 @@ public extern U0 CDImageWrite(U8 cd_drv_let,U8 *in_name=NULL,I64 media_type=MT_C
|
||||
public extern U8 *sys_dft_iso_name;
|
||||
|
||||
#help_index "File/FileNames"
|
||||
public extern U8 *sys_acct;
|
||||
public extern Bool FilesFindMatch(U8 *files_find_mask,U8 *filename,I64 fuf_flags=0);
|
||||
public extern Bool IsDotZ(U8 *filename);
|
||||
public extern Bool IsDotC(U8 *filename);
|
||||
@@ -536,7 +511,8 @@ public extern U8 *ChgExt(U8 *filename,U8 *extension);
|
||||
public extern U8 *DftExt(U8 *filename,U8 *extension);
|
||||
public extern Bool IsDir(U8 *dir_name);
|
||||
public extern Bool IsDrvWritable(U8 drv_let=0);
|
||||
extern CDirEntry *CdDir(CDirEntry *tempm,U8 *abs_name);
|
||||
extern CDirEntry *Cd2DirEntry(CDirEntry *tempm,U8 *abs_name);
|
||||
public extern U0 ToFileLine(U8 *_fl_file_line,U8 **_filename,I64 *_linenum);
|
||||
|
||||
#help_index "File/Program Routines/Utils"
|
||||
public extern U0 GetFFlags(U8 *f,U8 *lst,U8 *st);
|
||||
@@ -558,19 +534,20 @@ 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,Bool raw=FALSE);
|
||||
public extern U8 *TextFileRead(U8 *filename,I64 *_attr=NULL);
|
||||
public extern I64 FileWrite(U8 *filename,U8 *fbuf,
|
||||
I64 size,CDate spdt=0,I64 attr=0,Bool raw=FALSE);
|
||||
I64 size,CDate cdt=0,I64 attr=0,Bool raw=FALSE);
|
||||
public extern U0 TextFileWrite(U8 *filename,U8 *st,I64 attr=0);
|
||||
|
||||
#help_index "Install;File/Install Related;File/Cmd Line (Typically);Cmd Line (Typically);"
|
||||
#help_index "Install;File/Cmd Line (Typically);Cmd Line (Typically);"
|
||||
public extern U0 Mount(Bool repartition=FALSE);
|
||||
public extern U0 Fmt(U8 drv_let,Bool quick=TRUE,Bool confirm=TRUE,I64 type=PT_FAT32);
|
||||
|
||||
#help_index "Install;File/Install Related"
|
||||
#help_index "Install"
|
||||
#help_file "::/TempleOS/Doc/Install"
|
||||
extern CATARep *ATARepFind(CATARep *root,I64 num);
|
||||
public extern Bool DrvEnable(U8 drv_let,Bool val);
|
||||
public extern U0 Fmt(U8 drv_let,Bool quick=TRUE,Bool confirm=TRUE,I64 type=PT_FAT32);
|
||||
extern U0 DrvDftSelect();
|
||||
public extern U8 dft_drv,sys_first_hd_drv_let,sys_first_cd_drv_let;
|
||||
extern Bool boot_drv_pmt;
|
||||
public extern U8 sys_first_hd_drv_let,sys_first_cd_drv_let;
|
||||
extern Bool boot_drv_pmt,cdrom_boot_is_good;
|
||||
|
||||
#help_index "Hash"
|
||||
#help_file "::/TempleOS/Doc/Hash"
|
||||
@@ -611,27 +588,31 @@ extern I64 sys_num_installed_compilers;
|
||||
extern U0 (*fp_prs_stream_blk)(CLex *lx);
|
||||
|
||||
#help_index "Boot"
|
||||
#help_file "::/TempleOS/Doc/Boot"
|
||||
public extern U0 Reboot();
|
||||
|
||||
#help_index "MultiCore;Task/Requests"
|
||||
public extern CSrvCmd *JobQue(I64 (*fp_add)(U8 *data),U8 *data=NULL,
|
||||
I64 target_cpu=1,I64 flags=1<<SVCf_FREE_ON_COMPLETE,
|
||||
I64 cmd_code=SVCT_CALL,U8 *aux_str=NULL,I64 aux1=0,I64 aux2=0);
|
||||
#help_index "MultiCore"
|
||||
extern CMPCmdCtrl *mp_ctrl;
|
||||
extern U8 mp_apic_ids[MP_MAX_PROCESSORS];
|
||||
extern CMPCrash *mp_crash;
|
||||
public extern U0 MPInt(U8 num,I64 cpu_num=1);
|
||||
public extern U0 IntEOI(); //signal end of interrupt
|
||||
public extern U0 MPIntAll(U8 num);
|
||||
public extern U0 MPWake(I64 target_cpu_mask);
|
||||
public extern U0 MPWake(I64 target_cpu);
|
||||
extern U0 MPSethServerTask();
|
||||
extern CMPCmd *MPQueJob(I64 (*fp_add)(U8 *data),U8 *data=NULL,
|
||||
U8 *desc=NULL,
|
||||
I64 flags=1<<MPCf_FREE_ON_COMPLETE,
|
||||
Bool spawn=FALSE,I64 target_cpu_mask=ALL_MASK);
|
||||
public extern CMPCmd *MPJob(I64 (*fp_add)(U8 *data),U8 *data=NULL,
|
||||
I64 target_cpu=1,I64 flags=1<<MPCf_FREE_ON_COMPLETE);
|
||||
public extern I64 MPJobResult(CMPCmd *tempm);
|
||||
public extern CTask *MPSpawn(U0 (*fp_add)(U8 *data),U8 *data=NULL,U8 *name=NULL,I64 target_cpu=1);
|
||||
extern CTask *SpawnQue(U0 (*fp_add)(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);
|
||||
public extern U0 MPNMInt();
|
||||
public extern U0 MPStart();
|
||||
#help_index "Task/Requests;MultiCore"
|
||||
public extern Bool ScanResult(CSrvCmd *rqst=NULL,I64 *_result=NULL);
|
||||
public extern I64 GetResult(CSrvCmd *rqst=NULL);
|
||||
#help_index "MultiCore;Boot"
|
||||
public extern U0 MPHalt();
|
||||
|
||||
@@ -669,7 +650,23 @@ public _extern _FAR_CALL32 Bool FarCall32(U0 (*fp_add)());
|
||||
//fp_add can have any fixed number of arguments.
|
||||
public argpop extern I64 CallStkGrow(I64 stk_size_threshold,I64 stk_size,/*argpop*/I64 (*fp_add)(...),...);
|
||||
|
||||
#help_index "Fifo"
|
||||
#help_index "Data Types/Circular Queue"
|
||||
public extern U0 QueDel(CQue *root,Bool querem=FALSE);
|
||||
public extern CQue *QueCopy(CQue *root,CTask *mem_task=NULL);
|
||||
public extern I64 QueCnt(CQue *root);
|
||||
public extern I64 QueSize(CQue *root);
|
||||
|
||||
#help_index "Data Types"
|
||||
public extern U0 LinkedLstDel(U8 **_lst);
|
||||
public extern U8 *LinkedLstCopy(U8 **_lst,CTask *mem_task=NULL);
|
||||
public extern I64 LinkedLstCnt(U8 **_lst);
|
||||
public extern I64 LinkedLstSize(U8 **_lst);
|
||||
|
||||
public extern CQueVectU8 *QueVectU8New(I64 min_index=0);
|
||||
public extern U0 QueVectU8Put(CQueVectU8 *v,I64 index,U8 ch);
|
||||
public extern U0 QueVectU8Del(CQueVectU8 *v);
|
||||
public extern I64 QueVectU8Get(CQueVectU8 *v,I64 index);
|
||||
|
||||
public extern CFifoU8 *FifoU8New(I64 size,CTask *mem_task=NULL);
|
||||
public extern U0 FifoU8Del(CFifoU8 *f);
|
||||
public extern Bool FifoU8Ins(CFifoU8 *f,U8 b);
|
||||
@@ -699,7 +696,7 @@ public _extern _STRCAT U0 StrCat(U8 *dst,U8 *src);
|
||||
public extern I64 sys_key_cnt;
|
||||
public extern U0 SetTypeMatic(U8 delay);
|
||||
extern U0 KbdInit();
|
||||
extern I64 KbdQueMsgs();
|
||||
extern I64 KbdMsgsQue();
|
||||
extern U0 KbdMouseVarsInit();
|
||||
extern Bool MouseDriverInstall();
|
||||
extern U0 KbdMouseHandler(Bool poll_kbd,Bool poll_mouse);
|
||||
@@ -787,17 +784,13 @@ public extern I64 ScanChar();
|
||||
public extern I64 sys_cur_scan_code;
|
||||
|
||||
#help_index "Doc/Task"
|
||||
extern CDoc *(*fp_doc_cur)(CTask *task=NULL);
|
||||
extern CDoc *(*fp_doc_put)(CTask *task=NULL);
|
||||
|
||||
#help_index "Char/Conversion"
|
||||
public extern F64 A2F64(U8 *src,U8 **_end_ptr=NULL);
|
||||
|
||||
#help_index "Time/CDate"
|
||||
public extern U8 *date_fmt_map,*time_fmt_map;
|
||||
public extern U0 DateTimeFmtMapsRst();
|
||||
|
||||
#help_index "Char/Conversion;Time/CDate"
|
||||
public extern CDate A2CDate(U8 *src);
|
||||
#help_index "Char/Conversion;Time/Date"
|
||||
public extern CDate A2Date(U8 *src);
|
||||
|
||||
#help_index "Debugging/PSect;Hash"
|
||||
public extern CHash *PSectFind(U8 *add,I64 *_offset);
|
||||
@@ -813,8 +806,8 @@ public extern Bool PutSrcLink(U8 *add,I64 cnt=1,U8 *buf=NULL);
|
||||
public extern U0 EdLite(U8 *filename,I64 num=1);
|
||||
extern U8 *sys_fix_file_line;
|
||||
public extern U0 SetFix(U8 *filename,I64 line);
|
||||
extern U0 EdLiteFileLine(U8 *fl_file_line);
|
||||
public extern U0 Fix();
|
||||
extern U0 EdLiteFileLine(U8 *_fl_file_line);
|
||||
#help_index "Debugging/Debugger;Doc/Cmd Line (Typically);Cmd Line (Typically);Training"
|
||||
public extern U0 Man(U8 *st);
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
//At least $LK,"DFT_CACHE_LINE_WIDTH","MN:DFT_CACHE_LINE_WIDTH"$ alignment.
|
||||
#define BOOT_RAM_BASE 0x07C00
|
||||
#define BOOT_RAM_LIMIT 0x80000
|
||||
#define BOOT_RAM_LIMIT 0x97000
|
||||
|
||||
//9FC00 is EBDA BIOS area
|
||||
#define VGA_GRAPHIC_MEM_BASE 0xA0000
|
||||
@@ -15,12 +15,10 @@
|
||||
#define CD_BLK_SIZE (4*BLK_SIZE)
|
||||
#define CD_FILE_OFFSET 80
|
||||
|
||||
#define CD_BOOT_LOADER_SIZE CD_BLK_SIZE*1 //Max 4 CDBlks, I think
|
||||
|
||||
//These are the cfguration settings
|
||||
//for a standard production CD-Image
|
||||
#define STD_DISTRO_CDROM_CFG "b1Scale2Mem(2048,0x40000)\nt3 \n\n\n\n\n"
|
||||
#define SAFE_CDROM_CFG "b1Scale2Mem(2048,0x40000)\nt3 \n\n\n\nDontProbe\n\n"
|
||||
#define STD_DISTRO_CDROM_CFG "b1\nScale2Mem(2048,0x40000)\nt3 \n\n\n\n\n"
|
||||
#define SAFE_CDROM_CFG "b1\nScale2Mem(2048,0x40000)\nt3 \n\n\n\nDontProbe\n\n"
|
||||
|
||||
#define BOOT_STK_SIZE BLK_SIZE
|
||||
|
||||
@@ -28,3 +26,6 @@
|
||||
#define BOOT_CODE_HARDDRV 2
|
||||
#define BOOT_CODE_CDROM 3
|
||||
|
||||
#define MAX_BOOT_LOADER_SIZE CD_BLK_SIZE
|
||||
#define MAX_KERNEL_PATCH_TABLE 0x8000
|
||||
#define KERNEL_BIN_LIMIT ((BOOT_RAM_LIMIT-(BOOT_STK_SIZE+MAX_BOOT_LOADER_SIZE))>>4)
|
||||
@@ -1,4 +1,4 @@
|
||||
//See $LK-A,"::/TempleOS/Doc/Acknowledgements.TXT"$ (4).
|
||||
//See $LK-A,"::/TempleOS/Doc/Acknowledgements.TXT"$.
|
||||
//See $LK,"CArcCompress","MN:CArcCompress"$, $LK,"CArcEntry","MN:CArcEntry"$, and $LK,"CArcCtrl","MN:CArcCtrl"$
|
||||
|
||||
asm {
|
||||
@@ -283,7 +283,10 @@ CArcCompress *CompressBuf(U8 *src,I64 size,
|
||||
size_out=(c->dst_pos+7)>>3;
|
||||
result=MAlloc(size_out,mem_task);
|
||||
MemCpy(result,c->dst_buf,size_out);
|
||||
result->compression_type=text_only ? CT_7_BIT:CT_8_BIT;
|
||||
if (text_only)
|
||||
result->compression_type=CT_7_BIT;
|
||||
else
|
||||
result->compression_type=CT_8_BIT;
|
||||
result->compressed_size=size_out;
|
||||
} else {
|
||||
result=MAlloc(size+sizeof(CArcCompress),mem_task);
|
||||
|
||||
@@ -0,0 +1,323 @@
|
||||
U0 LinkedLstDel(U8 **_lst)
|
||||
{
|
||||
U8 **templ;
|
||||
while (_lst) {
|
||||
templ=*_lst;
|
||||
Free(_lst);
|
||||
_lst=templ;
|
||||
}
|
||||
}
|
||||
|
||||
U8 *LinkedLstCopy(U8 **_lst,CTask *mem_task=NULL)
|
||||
{
|
||||
U8 *result=NULL,**templ=&result;
|
||||
while (_lst) {
|
||||
templ=*templ=MAllocIdentical(_lst,mem_task);
|
||||
_lst=*_lst;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
I64 LinkedLstCnt(U8 **_lst)
|
||||
{
|
||||
I64 result=0;
|
||||
while (_lst) {
|
||||
result++;
|
||||
_lst=*_lst;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
I64 LinkedLstSize(U8 **_lst)
|
||||
{
|
||||
I64 result=0;
|
||||
while (_lst) {
|
||||
result+=MSize2(_lst);
|
||||
_lst=*_lst;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
U0 QueDel(CQue *root,Bool querem=FALSE) //Does not delete root
|
||||
{
|
||||
CQue *tempq=root->next,*tempq1;
|
||||
while (tempq!=root) {
|
||||
tempq1=tempq->next;
|
||||
if (querem)
|
||||
QueRem(tempq);
|
||||
Free(tempq);
|
||||
tempq=tempq1;
|
||||
}
|
||||
}
|
||||
|
||||
CQue *QueCopy(CQue *root,CTask *mem_task=NULL)
|
||||
{
|
||||
CQue *result=MAllocIdentical(root,mem_task),*tempq=root->next,*tempq1;
|
||||
QueInit(result);
|
||||
while (tempq!=root) {
|
||||
tempq1=MAllocIdentical(tempq,mem_task);
|
||||
QueIns(tempq1,result->last);
|
||||
tempq=tempq->next;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
I64 QueCnt(CQue *root) //Does not include root
|
||||
{
|
||||
CQue *tempq=root->next;
|
||||
I64 result=0;
|
||||
while (tempq!=root) {
|
||||
result++;
|
||||
tempq=tempq->next;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
I64 QueSize(CQue *root) //Does not include root
|
||||
{
|
||||
CQue *tempq=root->next;
|
||||
I64 result=0;
|
||||
while (tempq!=root) {
|
||||
result+=MSize2(tempq);
|
||||
tempq=tempq->next;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
CQueVectU8 *QueVectU8New(I64 min_index=0)
|
||||
{
|
||||
CQueVectU8 *result=MAlloc(sizeof(CQueVectU8));
|
||||
result->next=result->last=result;
|
||||
result->total_cnt=result->node_cnt=0;
|
||||
result->min_index=min_index;
|
||||
return result;
|
||||
}
|
||||
|
||||
U0 QueVectU8Put(CQueVectU8 *v,I64 index,U8 ch)
|
||||
{
|
||||
CQueVectU8 *tempv;
|
||||
index-=v->min_index;
|
||||
if (index<0) return;
|
||||
if (index<v->total_cnt) {
|
||||
tempv=v;
|
||||
do {
|
||||
index-=tempv->node_cnt;
|
||||
if (index<0) {
|
||||
tempv->body[index+tempv->node_cnt]=ch;
|
||||
return;
|
||||
}
|
||||
tempv=tempv->next;
|
||||
} while (tempv!=v);
|
||||
} else
|
||||
index-=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);
|
||||
}
|
||||
if (index--) {
|
||||
tempv->body[tempv->node_cnt++]=0;
|
||||
v->total_cnt++;
|
||||
} else {
|
||||
tempv->body[tempv->node_cnt++]=ch;
|
||||
v->total_cnt++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
U0 QueVectU8Del(CQueVectU8 *v)
|
||||
{
|
||||
if (v) {
|
||||
QueDel(v);
|
||||
Free(v);
|
||||
}
|
||||
}
|
||||
|
||||
I64 QueVectU8Get(CQueVectU8 *v,I64 index)
|
||||
{
|
||||
CQueVectU8 *tempv;
|
||||
index-=v->min_index;
|
||||
if (!(0<=index<v->total_cnt)) return 0;
|
||||
tempv=v;
|
||||
do {
|
||||
index-=tempv->node_cnt;
|
||||
if (index<0)
|
||||
return tempv->body[index+tempv->node_cnt];
|
||||
tempv=tempv->next;
|
||||
} while (tempv!=v);
|
||||
return 0;
|
||||
}
|
||||
|
||||
CFifoU8 *FifoU8New(I64 size,CTask *mem_task=NULL)
|
||||
{
|
||||
CFifoU8 *f;
|
||||
if (!mem_task) mem_task=Fs;
|
||||
f=MAlloc(sizeof(CFifoU8),mem_task);
|
||||
f->buf=MAlloc(size,mem_task);
|
||||
f->mask=size-1;
|
||||
f->in_ptr=0;
|
||||
f->out_ptr=0;
|
||||
return f;
|
||||
}
|
||||
|
||||
U0 FifoU8Del(CFifoU8 *f)
|
||||
{
|
||||
Free(f->buf);
|
||||
Free(f);
|
||||
}
|
||||
|
||||
Bool FifoU8Ins(CFifoU8 *f,U8 b)
|
||||
{
|
||||
I64 new_in_ptr;
|
||||
PushFD;
|
||||
Cli;
|
||||
new_in_ptr=(f->in_ptr+1)&f->mask;
|
||||
if (new_in_ptr==f->out_ptr) {
|
||||
PopFD;
|
||||
return FALSE;
|
||||
} else {
|
||||
f->buf[f->in_ptr]=b;
|
||||
f->in_ptr=new_in_ptr;
|
||||
PopFD;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
Bool FifoU8Rem(CFifoU8 *f,U8 *_b)
|
||||
{
|
||||
PushFD;
|
||||
Cli;
|
||||
if (f->in_ptr==f->out_ptr) {
|
||||
PopFD;
|
||||
return FALSE;
|
||||
} else {
|
||||
*_b=f->buf[f->out_ptr];
|
||||
f->out_ptr=(f->out_ptr+1)&f->mask;
|
||||
PopFD;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
Bool FifoU8Peek(CFifoU8 *f,U8 *_b)
|
||||
{
|
||||
PushFD;
|
||||
Cli;
|
||||
if (f->in_ptr==f->out_ptr) {
|
||||
PopFD;
|
||||
return FALSE;
|
||||
} else {
|
||||
*_b=f->buf[f->out_ptr];
|
||||
PopFD;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
U0 FifoU8Flush(CFifoU8 *f)
|
||||
{
|
||||
PushFD;
|
||||
Cli;
|
||||
f->out_ptr=f->in_ptr;
|
||||
PopFD;
|
||||
}
|
||||
|
||||
I64 FifoU8Cnt(CFifoU8 *f)
|
||||
{
|
||||
I64 result;
|
||||
PushFD;
|
||||
Cli;
|
||||
if (f->out_ptr>f->in_ptr)
|
||||
result=f->mask+1-(f->out_ptr-f->in_ptr);
|
||||
else
|
||||
result=f->in_ptr-f->out_ptr;
|
||||
PopFD;
|
||||
return result;
|
||||
}
|
||||
|
||||
CFifoI64 *FifoI64New(I64 size,CTask *mem_task=NULL)
|
||||
{
|
||||
CFifoI64 *f;
|
||||
if (!mem_task) mem_task=Fs;
|
||||
f=MAlloc(sizeof(CFifoI64),mem_task);
|
||||
f->buf=MAlloc(size*sizeof(I64),mem_task);
|
||||
f->mask=size-1;
|
||||
f->in_ptr=0;
|
||||
f->out_ptr=0;
|
||||
return f;
|
||||
}
|
||||
|
||||
U0 FifoI64Del(CFifoI64 *f)
|
||||
{
|
||||
Free(f->buf);
|
||||
Free(f);
|
||||
}
|
||||
|
||||
Bool FifoI64Ins(CFifoI64 *f,I64 q)
|
||||
{
|
||||
I64 new_in_ptr;
|
||||
PushFD;
|
||||
Cli;
|
||||
new_in_ptr=(f->in_ptr+1)&f->mask;
|
||||
if (new_in_ptr==f->out_ptr) {
|
||||
PopFD;
|
||||
return FALSE;
|
||||
} else {
|
||||
f->buf[f->in_ptr]=q;
|
||||
f->in_ptr=new_in_ptr;
|
||||
PopFD;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
Bool FifoI64Rem(CFifoI64 *f,I64 *_q)
|
||||
{
|
||||
PushFD;
|
||||
Cli;
|
||||
if (f->in_ptr==f->out_ptr) {
|
||||
PopFD;
|
||||
return FALSE;
|
||||
} else {
|
||||
*_q=f->buf[f->out_ptr];
|
||||
f->out_ptr=(f->out_ptr+1)&f->mask;
|
||||
PopFD;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
Bool FifoI64Peek(CFifoI64 *f,I64 *_q)
|
||||
{
|
||||
PushFD;
|
||||
Cli;
|
||||
if (f->in_ptr==f->out_ptr) {
|
||||
PopFD;
|
||||
return FALSE;
|
||||
} else {
|
||||
*_q=f->buf[f->out_ptr];
|
||||
PopFD;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
U0 FifoI64Flush(CFifoI64 *f)
|
||||
{
|
||||
PushFD;
|
||||
Cli;
|
||||
f->out_ptr=f->in_ptr;
|
||||
PopFD;
|
||||
}
|
||||
|
||||
I64 FifoI64Cnt(CFifoI64 *f)
|
||||
{
|
||||
I64 result;
|
||||
PushFD;
|
||||
Cli;
|
||||
if (f->out_ptr>f->in_ptr)
|
||||
result=f->mask+1-(f->out_ptr-f->in_ptr);
|
||||
else
|
||||
result=f->in_ptr-f->out_ptr;
|
||||
PopFD;
|
||||
return result;
|
||||
}
|
||||
+126
-126
@@ -11,9 +11,9 @@ I64 YearStartDate(I64 year)
|
||||
return year*365+yd4-yd100+yd400-yd4000;
|
||||
}
|
||||
|
||||
CDate CDateStruct2CDate(CDateStruct *_ds)
|
||||
CDate DateStruct2Date(CDateStruct *_ds)
|
||||
{
|
||||
CDate spdt;
|
||||
CDate cdt;
|
||||
I64 i1,i2;
|
||||
i1=YearStartDate(_ds->year);
|
||||
i2=YearStartDate(_ds->year+1);
|
||||
@@ -21,9 +21,9 @@ CDate CDateStruct2CDate(CDateStruct *_ds)
|
||||
i1+=mon_start_days1[_ds->mon-1];
|
||||
else
|
||||
i1+=mon_start_days2[_ds->mon-1];
|
||||
spdt.date=i1+_ds->day_of_mon-1;
|
||||
spdt.time=(_ds->sec10000+100*(_ds->sec100+100*(_ds->sec+60*(_ds->min+60*_ds->hour))))<<21/(15*15*3*625);
|
||||
return spdt;
|
||||
cdt.date=i1+_ds->day_of_mon-1;
|
||||
cdt.time=(_ds->sec10000+100*(_ds->sec100+100*(_ds->sec+60*(_ds->min+60*_ds->hour))))<<21/(15*15*3*625);
|
||||
return cdt;
|
||||
}
|
||||
|
||||
I64 DayOfWeek(I64 i)
|
||||
@@ -35,9 +35,9 @@ I64 DayOfWeek(I64 i)
|
||||
return 6-(6-i)%7;
|
||||
}
|
||||
|
||||
U0 CDate2CDateStruct(CDateStruct *_ds,CDate spdt)
|
||||
U0 Date2DateStruct(CDateStruct *_ds,CDate cdt)
|
||||
{
|
||||
I64 i,k,date=spdt.date;
|
||||
I64 i,k,date=cdt.date;
|
||||
_ds->day_of_week=DayOfWeek(date);
|
||||
_ds->year=(date+1)*100000/CDATE_YEAR_DAYS_INT;
|
||||
i=YearStartDate(_ds->year);
|
||||
@@ -59,7 +59,7 @@ U0 CDate2CDateStruct(CDateStruct *_ds,CDate spdt)
|
||||
}
|
||||
_ds->mon=k+1;
|
||||
_ds->day_of_mon=date+1;
|
||||
k=(625*15*15*3*spdt.time)>>21+1;
|
||||
k=(625*15*15*3*cdt.time)>>21+1;
|
||||
_ds->sec10000=ModU64(&k,100);
|
||||
_ds->sec100=ModU64(&k,100);
|
||||
_ds->sec=ModU64(&k,60);
|
||||
@@ -70,53 +70,53 @@ U0 CDate2CDateStruct(CDateStruct *_ds,CDate spdt)
|
||||
I64 FirstDayOfMon(I64 i)
|
||||
{
|
||||
CDateStruct ds;
|
||||
CDate spdt=0;
|
||||
spdt.date=i;
|
||||
CDate2CDateStruct(&ds,spdt);
|
||||
CDate cdt=0;
|
||||
cdt.date=i;
|
||||
Date2DateStruct(&ds,cdt);
|
||||
ds.day_of_mon=1;
|
||||
spdt=CDateStruct2CDate(&ds);
|
||||
return spdt.date;
|
||||
cdt=DateStruct2Date(&ds);
|
||||
return cdt.date;
|
||||
}
|
||||
|
||||
I64 LastDayOfMon(I64 i)
|
||||
{
|
||||
CDateStruct ds;
|
||||
CDate spdt=0;
|
||||
spdt.date=i;
|
||||
CDate2CDateStruct(&ds,spdt);
|
||||
CDate cdt=0;
|
||||
cdt.date=i;
|
||||
Date2DateStruct(&ds,cdt);
|
||||
ds.mon++;
|
||||
if (ds.mon==13) {
|
||||
ds.mon=0;
|
||||
ds.year++;
|
||||
}
|
||||
ds.day_of_mon=1;
|
||||
spdt=CDateStruct2CDate(&ds);
|
||||
return spdt.date-1;
|
||||
cdt=DateStruct2Date(&ds);
|
||||
return cdt.date-1;
|
||||
}
|
||||
|
||||
I64 FirstDayOfYear(I64 i)
|
||||
{
|
||||
CDateStruct ds;
|
||||
CDate spdt=0;
|
||||
spdt.date=i;
|
||||
CDate2CDateStruct(&ds,spdt);
|
||||
CDate cdt=0;
|
||||
cdt.date=i;
|
||||
Date2DateStruct(&ds,cdt);
|
||||
ds.day_of_mon=1;
|
||||
ds.mon=1;
|
||||
spdt=CDateStruct2CDate(&ds);
|
||||
return spdt.date;
|
||||
cdt=DateStruct2Date(&ds);
|
||||
return cdt.date;
|
||||
}
|
||||
|
||||
I64 LastDayOfYear(I64 i)
|
||||
{
|
||||
CDateStruct ds;
|
||||
CDate spdt=0;
|
||||
spdt.date=i;
|
||||
CDate2CDateStruct(&ds,spdt);
|
||||
CDate cdt=0;
|
||||
cdt.date=i;
|
||||
Date2DateStruct(&ds,cdt);
|
||||
ds.day_of_mon=1;
|
||||
ds.mon=1;
|
||||
ds.year++;
|
||||
spdt=CDateStruct2CDate(&ds);
|
||||
return spdt.date-1;
|
||||
cdt=DateStruct2Date(&ds);
|
||||
return cdt.date-1;
|
||||
}
|
||||
|
||||
|
||||
@@ -189,11 +189,11 @@ U0 GetCurTimeCDateStruct(CDateStruct *_ds)
|
||||
if (_ds->sec>59) _ds->sec=59;
|
||||
}
|
||||
|
||||
CDate GetCurTimeCDate()
|
||||
CDate GetCurTimeDate()
|
||||
{
|
||||
CDateStruct ds;
|
||||
GetCurTimeCDateStruct(&ds);
|
||||
return CDateStruct2CDate(&ds)-local_time_offset;
|
||||
return DateStruct2Date(&ds)-local_time_offset;
|
||||
}
|
||||
|
||||
U0 DateTimeFmtMapsRst()
|
||||
@@ -205,279 +205,279 @@ U0 DateTimeFmtMapsRst()
|
||||
time_fmt_map[i]=i;
|
||||
}
|
||||
|
||||
U8 *MSPrintFTime(CDate spdt,I64 sub_fmt)
|
||||
U8 *MSPrintFTime(CDate cdt,I64 sub_fmt)
|
||||
{
|
||||
CDateStruct ds;
|
||||
if (sub_fmt<TF_NUM)
|
||||
sub_fmt=time_fmt_map[sub_fmt];
|
||||
switch (sub_fmt) {
|
||||
case TF_HH24_MM:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%02d:%02d",ds.hour,ds.min);
|
||||
case TF_HH12_MM_SS_AM:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
if (ds.hour>=12)
|
||||
return MSPrintF("%02d:%02d:%02d pm",ds.hour-12,ds.min,ds.sec);
|
||||
else
|
||||
return MSPrintF("%02d:%02d:%02d am",ds.hour,ds.min,ds.sec);
|
||||
case TF_HH12_MM_AM:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
if (ds.hour>=12)
|
||||
return MSPrintF("%02d:%02d pm",ds.hour-12,ds.min);
|
||||
else
|
||||
return MSPrintF("%02d:%02d am",ds.hour,ds.min);
|
||||
case TF_HH12_MM_SSA:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
if (ds.hour>=12)
|
||||
return MSPrintF("%02d:%02d:%02dp",ds.hour-12,ds.min,ds.sec);
|
||||
else
|
||||
return MSPrintF("%02d:%02d:%02da",ds.hour,ds.min,ds.sec);
|
||||
case TF_HH12_MMA:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
if (ds.hour>=12)
|
||||
return MSPrintF("%02d:%02dp",ds.hour-12,ds.min);
|
||||
else
|
||||
return MSPrintF("%02d:%02da",ds.hour,ds.min);
|
||||
case TF_H_M:
|
||||
CDate2CDateStruct(&ds,spdt);
|
||||
return MSPrintF("%dh %02dm",ds.hour+spdt.date*24,ds.min);
|
||||
Date2DateStruct(&ds,cdt);
|
||||
return MSPrintF("%dh %02dm",ds.hour+cdt.date*24,ds.min);
|
||||
case TF_H_M_S:
|
||||
CDate2CDateStruct(&ds,spdt);
|
||||
return MSPrintF("%dh %02dm %02ds",ds.hour+spdt.date*24,ds.min,ds.sec);
|
||||
Date2DateStruct(&ds,cdt);
|
||||
return MSPrintF("%dh %02dm %02ds",ds.hour+cdt.date*24,ds.min,ds.sec);
|
||||
case TF_D_H_M:
|
||||
CDate2CDateStruct(&ds,spdt);
|
||||
return MSPrintF("%dd %02dh %02dm",spdt.date,ds.hour,ds.min);
|
||||
Date2DateStruct(&ds,cdt);
|
||||
return MSPrintF("%dd %02dh %02dm",cdt.date,ds.hour,ds.min);
|
||||
case TF_D_H_M_S:
|
||||
CDate2CDateStruct(&ds,spdt);
|
||||
return MSPrintF("%dd %02dh %02dm %02ds",spdt.date,ds.hour,ds.min,ds.sec);
|
||||
Date2DateStruct(&ds,cdt);
|
||||
return MSPrintF("%dd %02dh %02dm %02ds",cdt.date,ds.hour,ds.min,ds.sec);
|
||||
case TF_D_H_M_Sh:
|
||||
CDate2CDateStruct(&ds,spdt);
|
||||
return MSPrintF("%dd %02dh %02dm %02d.%02ds",spdt.date,ds.hour,ds.min,ds.sec,ds.sec100);
|
||||
Date2DateStruct(&ds,cdt);
|
||||
return MSPrintF("%dd %02dh %02dm %02d.%02ds",cdt.date,ds.hour,ds.min,ds.sec,ds.sec100);
|
||||
case TF_H_M_Sh:
|
||||
CDate2CDateStruct(&ds,spdt);
|
||||
return MSPrintF("%dh %02dm %02d.%02ds",ds.hour+spdt.date*24,ds.min,ds.sec,ds.sec100);
|
||||
Date2DateStruct(&ds,cdt);
|
||||
return MSPrintF("%dh %02dm %02d.%02ds",ds.hour+cdt.date*24,ds.min,ds.sec,ds.sec100);
|
||||
case TF_Sh:
|
||||
CDate2CDateStruct(&ds,spdt);
|
||||
return MSPrintF("%d.%02d",60*((spdt.date*24+ds.hour)*60+ds.min)+ds.sec,ds.sec100);
|
||||
Date2DateStruct(&ds,cdt);
|
||||
return MSPrintF("%d.%02d",60*((cdt.date*24+ds.hour)*60+ds.min)+ds.sec,ds.sec100);
|
||||
case TF_M_Sh:
|
||||
CDate2CDateStruct(&ds,spdt);
|
||||
return MSPrintF("%02d:%02d.%02d",60*(spdt.date*24+ds.hour)+ds.min,ds.sec,ds.sec100);
|
||||
Date2DateStruct(&ds,cdt);
|
||||
return MSPrintF("%02d:%02d.%02d",60*(cdt.date*24+ds.hour)+ds.min,ds.sec,ds.sec100);
|
||||
case TF_H_M_Sh2:
|
||||
CDate2CDateStruct(&ds,spdt);
|
||||
return MSPrintF("%02d:%02d:%02d.%02d",spdt.date*24+ds.hour,ds.min,ds.sec,ds.sec100);
|
||||
Date2DateStruct(&ds,cdt);
|
||||
return MSPrintF("%02d:%02d:%02d.%02d",cdt.date*24+ds.hour,ds.min,ds.sec,ds.sec100);
|
||||
case TF_D_H_M_Sht:
|
||||
CDate2CDateStruct(&ds,spdt);
|
||||
return MSPrintF("%dd %02dh %02dm %02d.%04ds",spdt.date,ds.hour,ds.min,ds.sec,100*ds.sec100+ds.sec10000);
|
||||
Date2DateStruct(&ds,cdt);
|
||||
return MSPrintF("%dd %02dh %02dm %02d.%04ds",cdt.date,ds.hour,ds.min,ds.sec,100*ds.sec100+ds.sec10000);
|
||||
case TF_H_M_Sht:
|
||||
CDate2CDateStruct(&ds,spdt);
|
||||
return MSPrintF("%dh %02dm %02d.%04ds",ds.hour+spdt.date*24,ds.min,ds.sec,100*ds.sec100+ds.sec10000);
|
||||
Date2DateStruct(&ds,cdt);
|
||||
return MSPrintF("%dh %02dm %02d.%04ds",ds.hour+cdt.date*24,ds.min,ds.sec,100*ds.sec100+ds.sec10000);
|
||||
case TF_Sht:
|
||||
CDate2CDateStruct(&ds,spdt);
|
||||
return MSPrintF("%d.%04d",60*((spdt.date*24+ds.hour)*60+ds.min)+ds.sec,100*ds.sec100+ds.sec10000);
|
||||
Date2DateStruct(&ds,cdt);
|
||||
return MSPrintF("%d.%04d",60*((cdt.date*24+ds.hour)*60+ds.min)+ds.sec,100*ds.sec100+ds.sec10000);
|
||||
case TF_M_Sht:
|
||||
CDate2CDateStruct(&ds,spdt);
|
||||
return MSPrintF("%02d:%02d.%04d",60*(spdt.date*24+ds.hour)+ds.min,ds.sec,100*ds.sec100+ds.sec10000);
|
||||
Date2DateStruct(&ds,cdt);
|
||||
return MSPrintF("%02d:%02d.%04d",60*(cdt.date*24+ds.hour)+ds.min,ds.sec,100*ds.sec100+ds.sec10000);
|
||||
case TF_H_M_Sht2:
|
||||
CDate2CDateStruct(&ds,spdt);
|
||||
return MSPrintF("%02d:%02d:%02d.%04d",spdt.date*24+ds.hour,ds.min,ds.sec,100*ds.sec100+ds.sec10000);
|
||||
Date2DateStruct(&ds,cdt);
|
||||
return MSPrintF("%02d:%02d:%02d.%04d",cdt.date*24+ds.hour,ds.min,ds.sec,100*ds.sec100+ds.sec10000);
|
||||
case TF_HH24:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%02d",ds.hour);
|
||||
case TF_MM:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%02d",ds.min);
|
||||
case TF_SS:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%02d",ds.sec);
|
||||
case TF_HH24_MM_SS:
|
||||
default:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%02d:%02d:%02d",ds.hour,ds.min,ds.sec);
|
||||
}
|
||||
}
|
||||
|
||||
U8 *MSPrintFDate(CDate spdt,I64 sub_fmt)
|
||||
U8 *MSPrintFDate(CDate cdt,I64 sub_fmt)
|
||||
{
|
||||
CDateStruct ds;
|
||||
if (sub_fmt<DF_NUM)
|
||||
sub_fmt=date_fmt_map[sub_fmt];
|
||||
switch (sub_fmt) {
|
||||
case DF_MM_DD:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%02d/%02d",ds.mon,ds.day_of_mon);
|
||||
case DF_wek_MM_DD:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%3tZ %02d/%02d",ds.day_of_week,"ST_DAYS_OF_WEEK",
|
||||
ds.mon,ds.day_of_mon);
|
||||
case DF_wek_MM_DD_YY:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%3tZ %02d/%02d/%02d",ds.day_of_week,"ST_DAYS_OF_WEEK",
|
||||
ds.mon,ds.day_of_mon,ds.year%100);
|
||||
case DF_MM_DD_YYYY:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%02d/%02d/%d",ds.mon,ds.day_of_mon,ds.year);
|
||||
case DF_wek_MM_DD_YYYY:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%3tZ %02d/%02d/%d",ds.day_of_week,"ST_DAYS_OF_WEEK",
|
||||
ds.mon,ds.day_of_mon,ds.year);
|
||||
case DF_mon_DD:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%3tZ %02d",ds.mon-1,"ST_MONTHS",ds.day_of_mon);
|
||||
case DF_wek_mon_DD:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%3tZ, %3tZ %02d",ds.day_of_week,"ST_DAYS_OF_WEEK",
|
||||
ds.mon-1,"ST_MONTHS",ds.day_of_mon);
|
||||
case DF_mon_DD_YYYY:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%3tZ %02d,%04d",ds.mon-1,"ST_MONTHS",ds.day_of_mon,ds.year);
|
||||
case DF_wek_mon_DD_YYYY:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%3tZ, %3tZ %02d,%d",ds.day_of_week,"ST_DAYS_OF_WEEK",
|
||||
ds.mon-1,"ST_MONTHS",ds.day_of_mon,ds.year);
|
||||
case DF_month_DD:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%Z %d",ds.mon-1,"ST_MONTHS",ds.day_of_mon);
|
||||
case DF_week_month_DD:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%Z, %Z %d",ds.day_of_week,"ST_DAYS_OF_WEEK",
|
||||
ds.mon-1,"ST_MONTHS",ds.day_of_mon);
|
||||
case DF_month_DD_YYYY:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%Z %d,%d",ds.mon-1,"ST_MONTHS",ds.day_of_mon,ds.year);
|
||||
case DF_week_month_DD_YYYY:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%Z, %Z %d,%d",ds.day_of_week,"ST_DAYS_OF_WEEK",
|
||||
ds.mon-1,"ST_MONTHS",ds.day_of_mon,ds.year);
|
||||
case DF_DD_MM_YY:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%02d/%02d/%02d",ds.day_of_mon,ds.mon,ds.year%100);
|
||||
case DF_DD_MM:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%02d/%02d",ds.day_of_mon,ds.mon);
|
||||
case DF_wek_DD_MM:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%3tZ %02d/%02d",ds.day_of_week,"ST_DAYS_OF_WEEK",
|
||||
ds.day_of_mon,ds.mon);
|
||||
case DF_wek_DD_MM_YY:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%3tZ %02d/%02d/%02d",ds.day_of_week,"ST_DAYS_OF_WEEK",
|
||||
ds.day_of_mon,ds.mon,ds.year%100);
|
||||
case DF_DD_MM_YYYY:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%02d/%02d/%d",ds.day_of_mon,ds.mon,ds.year);
|
||||
case DF_wek_DD_MM_YYYY:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%3tZ %02d/%02d/%d",ds.day_of_week,"ST_DAYS_OF_WEEK",
|
||||
ds.day_of_mon,ds.mon,ds.year);
|
||||
case DF_DD_mon:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%02d %3tZ",ds.day_of_mon,ds.mon-1,"ST_MONTHS");
|
||||
case DF_wek_DD_mon:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%3tZ, %02d %3tZ",ds.day_of_week,"ST_DAYS_OF_WEEK",
|
||||
ds.day_of_mon,ds.mon-1,"ST_MONTHS");
|
||||
case DF_DD_mon_YYYY:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%02d %3tZ,%04d",ds.day_of_mon,ds.mon-1,"ST_MONTHS",ds.year);
|
||||
case DF_wek_DD_mon_YYYY:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%3tZ, %02d %3tZ,%d",ds.day_of_week,"ST_DAYS_OF_WEEK",
|
||||
ds.day_of_mon,ds.mon-1,"ST_MONTHS",ds.year);
|
||||
case DF_DD_month:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%d %Z",ds.day_of_mon,ds.mon-1,"ST_MONTHS");
|
||||
case DF_week_DD_month:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%Z, %d %Z",ds.day_of_week,"ST_DAYS_OF_WEEK",
|
||||
ds.day_of_mon,ds.mon-1,"ST_MONTHS");
|
||||
case DF_DD_month_YYYY:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%d %Z,%d",ds.day_of_mon,ds.mon-1,"ST_MONTHS",ds.year);
|
||||
case DF_week_DD_month_YYYY:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%Z, %d %Z,%d",ds.day_of_week,"ST_DAYS_OF_WEEK",
|
||||
ds.day_of_mon,ds.mon-1,"ST_MONTHS",ds.year);
|
||||
case DF_YY_MM_DD:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%02d/%02d/%02d",ds.year%100,ds.mon,ds.day_of_mon);
|
||||
case DF_YYYY_MM_DD:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%d/%02d/%02d",ds.year,ds.mon,ds.day_of_mon);
|
||||
case DF_YYMMDD:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%02d%02d%02d",ds.year%100,ds.mon,ds.day_of_mon);
|
||||
case DF_YYYYMMDD:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%d%02d%02d",ds.year,ds.mon,ds.day_of_mon);
|
||||
case DF_MMDDYY:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%02d%02d%02d",ds.mon,ds.day_of_mon,ds.year%100);
|
||||
case DF_MMDDYYYY:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%02d%02d%d",ds.mon,ds.day_of_mon,ds.year);
|
||||
case DF_wek:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%3tZ",ds.day_of_week,"ST_DAYS_OF_WEEK");
|
||||
case DF_week:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%Z",ds.day_of_week,"ST_DAYS_OF_WEEK");
|
||||
case DF_mon:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%3tZ",ds.mon-1,"ST_MONTHS");
|
||||
case DF_month:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%Z",ds.mon-1,"ST_MONTHS");
|
||||
case DF_YYYY_mon:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%d %3tZ",ds.year,ds.mon-1,"ST_MONTHS");
|
||||
case DF_YYYY_month:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%d %Z",ds.year,ds.mon-1,"ST_MONTHS");
|
||||
case DF_YY_mon:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%02d %3tZ",ds.year%100,ds.mon-1,"ST_MONTHS");
|
||||
case DF_YY_month:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%02d %Z",ds.year%100,ds.mon-1,"ST_MONTHS");
|
||||
case DF_mon_YYYY:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%3tZ %d",ds.mon-1,"ST_MONTHS",ds.year);
|
||||
case DF_month_YYYY:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%Z %d",ds.mon-1,"ST_MONTHS",ds.year);
|
||||
case DF_mon_YY:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%3tZ %02d",ds.mon-1,"ST_MONTHS",ds.year%100);
|
||||
case DF_month_YY:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%Z %02d",ds.mon-1,"ST_MONTHS",ds.year%100);
|
||||
case DF_YY:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%02d",ds.year%100);
|
||||
case DF_YYYY:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%d",ds.year);
|
||||
case DF_D:
|
||||
return MSPrintF("%d days",spdt.date);
|
||||
return MSPrintF("%d days",cdt.date);
|
||||
case DF_M:
|
||||
return MSPrintF("%d mons",ToI64(spdt/(CDATE_YEAR_DAYS/12))>>32);
|
||||
return MSPrintF("%d mons",ToI64(cdt/(CDATE_YEAR_DAYS/12))>>32);
|
||||
case DF_Y:
|
||||
return MSPrintF("%d years",ToI64(spdt/CDATE_YEAR_DAYS)>>32);
|
||||
return MSPrintF("%d years",ToI64(cdt/CDATE_YEAR_DAYS)>>32);
|
||||
case DF_D2:
|
||||
return MSPrintF("%d",spdt.date);
|
||||
return MSPrintF("%d",cdt.date);
|
||||
case DF_M2:
|
||||
return MSPrintF("%d",ToI64(spdt/(CDATE_YEAR_DAYS/12))>>32);
|
||||
return MSPrintF("%d",ToI64(cdt/(CDATE_YEAR_DAYS/12))>>32);
|
||||
case DF_Y2:
|
||||
return MSPrintF("%d",ToI64(spdt/CDATE_YEAR_DAYS)>>32);
|
||||
return MSPrintF("%d",ToI64(cdt/CDATE_YEAR_DAYS)>>32);
|
||||
case DF_D3:
|
||||
return MSPrintF("%0.1f",spdt/ToF64(MAX_U32+1));
|
||||
return MSPrintF("%0.1f",cdt/ToF64(MAX_U32+1));
|
||||
case DF_M3:
|
||||
return MSPrintF("%0.1f",spdt/ToF64(MAX_U32+1)/(CDATE_YEAR_DAYS/12));
|
||||
return MSPrintF("%0.1f",cdt/ToF64(MAX_U32+1)/(CDATE_YEAR_DAYS/12));
|
||||
case DF_Y3:
|
||||
return MSPrintF("%0.1f",spdt/ToF64(MAX_U32+1)/CDATE_YEAR_DAYS);
|
||||
return MSPrintF("%0.1f",cdt/ToF64(MAX_U32+1)/CDATE_YEAR_DAYS);
|
||||
case DF_MM_DD_YY:
|
||||
default:
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
return MSPrintF("%02d/%02d/%02d",ds.mon,ds.day_of_mon,ds.year%100);
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,22 @@ Bool IsDbgTask()
|
||||
Bool ChkPtr(U8 *ptr)
|
||||
{
|
||||
if (sys_heap_base<=ptr<=MAPPED_MEM_SPACE) {
|
||||
if (*MemPtAtPageTableEntry(ptr)&1)
|
||||
if (*MemPageTable(ptr)&1)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
} else if (ptr<sys_boot_base)
|
||||
return FALSE;
|
||||
else if (ptr<VGA_GRAPHIC_MEM_BASE)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Bool ChkCodePtr(U8 *ptr)
|
||||
{
|
||||
if (sys_heap_base<=ptr<=sys_heap_limit) {
|
||||
if (*MemPageTable(ptr)&1)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
@@ -279,7 +294,10 @@ U0 D(U8 *add,I64 cnt=0x80,Bool show_offset=TRUE)
|
||||
"%08X ",ptr-add;
|
||||
else
|
||||
"%010X ",ptr;
|
||||
j=cnt>16 ? 16:cnt;
|
||||
if (cnt>16)
|
||||
j=16;
|
||||
else
|
||||
j=cnt;
|
||||
for (i=0;i<j;i++)
|
||||
"%02X ",ptr[i];
|
||||
for (;i<16;i++)
|
||||
|
||||
@@ -8,10 +8,11 @@ U0 LoadSysStrs()
|
||||
DefineLoad("ST_FILE_NOT_FOUND","File not found.\n");
|
||||
DefineLoad("ST_INVALID_FILENAME","Invalid File Name.\n");
|
||||
DefineLoad("ST_PRESS_A_KEY","$$BK,1$$PRESS A KEY$$BK,0$$\n");
|
||||
DefineLoad("ST_PROBE_OR_SKIP","Press '$$FG,PURPLE$$p$$FG$$' to probe or '$$FG,PURPLE$$s$$FG$$' to skip.\n");
|
||||
DefineLoad("ST_EXIT_ALL_APPLICATIONS","$$FG,RED$$Exit all other applications.$$FG$$\n");
|
||||
DefineLoad("ST_GOING_TO_PROBE_HARDWARE","\nWe're going to probe hardware.\n");
|
||||
DefineLoad("ST_ARE_YOU_SURE","ARE YOU SURE ");
|
||||
DefineLoad("ST_NOT_NATIVE","Not Native Partition\n");
|
||||
DefineLoad("ST_NOT_REDSEA","Not RedSea Partition\n");
|
||||
DefineLoad("ST_NOT_FAT32","Not FAT32 Partition\n");
|
||||
DefineLoad("ST_NOT_ISO9660","Not ISO9660 Partition\n");
|
||||
DefineLoad("ST_NOT_ISO13346","Not ISO13346 Partition\n");
|
||||
@@ -39,7 +40,7 @@ U0 LoadSysStrs()
|
||||
DefineLstLoad("ST_FILE_ATTRS","R\0H\0S\0V\0D\0A\0 \0 \0X\0Y\0T\0Z\0C\0F\0");
|
||||
DefineLstLoad("ST_FILE_UTIL_FLAGS","r\0d\0i\0a\0c\0R\0p\0m\0D\0F\0T\0S\0A\0J\0G\0Z\0P\0f\0l\0lf\0lb\0");
|
||||
DefineLstLoad("ST_BLKDEV_TYPES","NULL\0RAM\0ATA\0ATAPI\0");
|
||||
DefineLstLoad("ST_PRT_TYPES","NULL\0NATIVE\0FAT32\0ISO9660\0ISO13490\0ISO13346\0NTFS\0UNKNOWN\0");
|
||||
DefineLstLoad("ST_PRT_TYPES","NULL\0REDSEA\0FAT32\0ISO9660\0ISO13490\0ISO13346\0NTFS\0UNKNOWN\0");
|
||||
|
||||
DefineLoad("ST_MOUNT_INTRO",
|
||||
"\n\n\n$$BK,1$$$$FG,PURPLE$$Mount drives so they will "
|
||||
@@ -52,21 +53,21 @@ U0 LoadSysStrs()
|
||||
"If more than one partition is present\n"
|
||||
"they will be lettered in sequence.\n"
|
||||
"\n"
|
||||
"First Drive Letter($$FG,PURPLE$$<ENTER>$$FG$$ to exit):");
|
||||
"First Drive Letter ($$FG,PURPLE$$<ENTER>$$FG$$ to exit):");
|
||||
DefineLoad("ST_MOUNT_DRV_TYPE",
|
||||
"\t$$FG,PURPLE$$1$$FG$$=RAM\n\t$$FG,PURPLE$$2$$FG$$=ATA(Harddisk)\n"
|
||||
"\t$$FG,PURPLE$$3$$FG$$=ATAPI(CD-ROM)\n"
|
||||
"Type:");
|
||||
DefineLoad("ST_MOUNT_BLKS",
|
||||
"Blks of 512 bytes:");
|
||||
DefineLoad("ST_MOUNT_ADDR",
|
||||
"Addr of RAM disk ($$FG,PURPLE$$<ENTER>$$FG$$ to MAlloc):");
|
||||
DefineLoad("ST_MOUNT_UNIT",
|
||||
"\t$$FG,PURPLE$$0$$FG$$=Master\n\t$$FG,PURPLE$$1$$FG$$=Slave\nUnit:");
|
||||
DefineLoad("ST_MOUNT_FMT_WHOLE_DRV",
|
||||
"\nReformat WHOLE drive!");
|
||||
DefineLoad("ST_MOUNT_BOOTED_CDROM",
|
||||
"<ENTER> to use booted CD-ROM\n");
|
||||
DefineLoad("ST_INCLUDE_0X",
|
||||
"Include $$FG,PURPLE$$0x$$FG$$ prefix\n");
|
||||
DefineLoad("ST_MOUNT_BASE0",
|
||||
"Include $$FG,PURPLE$$0x$$FG$$ prefix.\n"
|
||||
"I/O Port Base0:\n");
|
||||
@@ -95,7 +96,7 @@ U0 LoadSysStrs()
|
||||
|
||||
DefineLstLoad("ST_COLORS","BLACK\0BLUE\0GREEN\0CYAN\0"
|
||||
"RED\0PURPLE\0BROWN\0LTGRAY\0DKGRAY\0LTBLUE\0LTGREEN\0"
|
||||
"LTSCYAN\0LTRED\0LTPURPLE\0YELLOW\0WHITE\0");
|
||||
"LTCYAN\0LTRED\0LTPURPLE\0YELLOW\0WHITE\0");
|
||||
DefineLstLoad("ST_INT_NAMES",
|
||||
"Divide Error\0SingleStep\0NMI\0Breakpoint\0Overflow\0BOUND Range Exceeded\0Invalid Opcode\0No Math Coprocessor\0"
|
||||
"Double Fault\0Coprocessor Segment Fault\0Invalid TASK\0Segment Not Present\0Stk Segment Fault\0General Protection\0Page Fault\0 \0"
|
||||
|
||||
+20
-21
@@ -80,7 +80,7 @@ See also $LK,"GrUpdateScreen","MN:GrUpdateScreen"$().
|
||||
ptr=ptr1=col+row*gr_width;
|
||||
ptr+=VGA_GRAPHIC_MEM_BASE;
|
||||
ptr1+=sys_dc_screen_image; //Write to cached image as well
|
||||
ptr2=&gr_font[ch.u8[0]*FONT_HEIGHT];
|
||||
ptr2=&gr_font[(ch&255)*FONT_HEIGHT];
|
||||
for (i=0;i<FONT_HEIGHT;i++) {
|
||||
*ptr=*ptr1=reverse_bits_table[*ptr2++];
|
||||
ptr+=gr_width>>3;
|
||||
@@ -179,27 +179,29 @@ Bool AKDInputFilterPutS(U8 *st)
|
||||
|
||||
U0 PutKey(I64 ch,I64 sc)
|
||||
{ //See $LK,"PutKeyHandling","FA:::/TempleOS/Doc/KeyBoard.TXT,PutKeyHandling"$
|
||||
CKeyDev *tempp=sys_put_key_root.next;
|
||||
if (!Bt(&Fs->display_flags,DISPLAYf_SILENT)) {
|
||||
if (sys_cur_scan_code & SCF_SCROLL) {
|
||||
if (sys_focus_task==Fs) {
|
||||
CKeyDev *tempp;
|
||||
if (ch||sc) {
|
||||
tempp=sys_put_key_root.next;
|
||||
if (!Bt(&Fs->display_flags,DISPLAYf_SILENT)) {
|
||||
if (sys_cur_scan_code & SCF_SCROLL && sys_focus_task==Fs)
|
||||
while (sys_cur_scan_code & SCF_SCROLL)
|
||||
Yield;
|
||||
}
|
||||
}
|
||||
while (tempp!=&sys_put_key_root) {
|
||||
if (!(sc & SCF_KEY_DESC) || tempp->flags & KDF_HAS_DESCS) {
|
||||
if ((*tempp->put_key)(ch,sc))
|
||||
Yield; //Wait on SCROLL LOCK Key
|
||||
while (tempp!=&sys_put_key_root) {
|
||||
if ((!(sc & SCF_KEY_DESC) || tempp->flags & KDF_HAS_DESCS) &&
|
||||
(*tempp->put_key)(ch,sc))
|
||||
break;
|
||||
tempp=tempp->next;
|
||||
}
|
||||
tempp=tempp->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
U0 PutChar(I64 ch)
|
||||
{
|
||||
PutKey(ch,0);
|
||||
U0 PutChar(U64 ch)
|
||||
{ //You can pack multiple chars into a U64.
|
||||
while (ch) {
|
||||
PutKey(ch&255,0);
|
||||
ch>>=8;
|
||||
}
|
||||
}
|
||||
|
||||
U0 PutS(U8 *st)
|
||||
@@ -209,12 +211,9 @@ U0 PutS(U8 *st)
|
||||
if (!st) return;
|
||||
CKeyDev *tempp=sys_put_key_root.next;
|
||||
if (!Bt(&Fs->display_flags,DISPLAYf_SILENT)) {
|
||||
if (sys_cur_scan_code & SCF_SCROLL) {
|
||||
if (sys_focus_task==Fs) {
|
||||
while (sys_cur_scan_code & SCF_SCROLL)
|
||||
Yield;
|
||||
}
|
||||
}
|
||||
if (sys_cur_scan_code & SCF_SCROLL && sys_focus_task==Fs)
|
||||
while (sys_cur_scan_code & SCF_SCROLL)
|
||||
Yield;
|
||||
while (cont && tempp!=&sys_put_key_root) {
|
||||
if (tempp->put_s) {
|
||||
if ((*tempp->put_s)(st))
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//See $LK-A,"::/TempleOS/Doc/Acknowledgements.TXT"$ (2).
|
||||
//See $LK-A,"::/TempleOS/Doc/Acknowledgements.TXT"$.
|
||||
|
||||
#define ATA_NOP 0x00
|
||||
#define ATA_DEV_RST 0x08
|
||||
|
||||
@@ -66,16 +66,16 @@ Bool BlkDevInit(CBlkDev *bdev)
|
||||
bdev->flags|=BDF_INIT_IN_PROGRESS;
|
||||
switch(bdev->type) {
|
||||
case BDT_RAM:
|
||||
bdev->RAM_dsk=AMAlloc((bdev->max_blk+1)<<BLK_SIZE_BITS);
|
||||
bdev->max_blk=MSize(bdev->RAM_dsk)>>BLK_SIZE_BITS-1;
|
||||
p->type=PT_NATIVE;
|
||||
if (sys_boot_code.u8[0]!=BOOT_CODE_RAM ||
|
||||
!NativeFSDrvValidate(bdev->first_drv_let))
|
||||
NativeFSFmt(bdev->first_drv_let);
|
||||
else {
|
||||
p->size=bdev->max_blk+1;
|
||||
NativeFSPrtInit(p);
|
||||
if (!bdev->RAM_dsk) {
|
||||
bdev->RAM_dsk=AMAlloc((bdev->max_blk+1)<<BLK_SIZE_BITS);
|
||||
bdev->max_blk=MSize(bdev->RAM_dsk)>>BLK_SIZE_BITS-1;
|
||||
}
|
||||
p->type=PT_REDSEA;
|
||||
p->size=bdev->max_blk+1;
|
||||
if (RedSeaFSDrvValidate(bdev->first_drv_let))
|
||||
RedSeaFSPrtInit(p);
|
||||
else
|
||||
RedSeaFSFmt(bdev->first_drv_let);
|
||||
result=TRUE;
|
||||
break;
|
||||
case BDT_ATA:
|
||||
@@ -214,7 +214,7 @@ U0 CleanMAPBuf(CPrt *p,I64 MAP_select=-1)
|
||||
WBlks(p,p->cur_map_blk(I64)+i<<BLK_SIZE_BITS,p->map2+i+p->cur_map_blk_num,1);
|
||||
}
|
||||
|
||||
U0 SetNativeBuf(CPrt *p,I64 c,I64 map_select=-1)
|
||||
U0 SetFSBuf(CPrt *p,I64 c,I64 map_select=-1)
|
||||
{
|
||||
I64 MAP_blk_num;
|
||||
if (c==INVALID_CLUSTER)
|
||||
@@ -264,7 +264,7 @@ U0 WZeroBlks(CPrt *p,I64 blk,I64 cnt)
|
||||
}
|
||||
|
||||
//Very dangerous
|
||||
Bool SetDrvType(U8 drv_let,I64 type=PT_NATIVE)
|
||||
Bool SetDrvType(U8 drv_let,I64 type=PT_REDSEA)
|
||||
{
|
||||
I64 i,j,ext_base,prt_num,offset,cur_type;
|
||||
CMasterBoot mbr;
|
||||
@@ -285,8 +285,8 @@ Bool SetDrvType(U8 drv_let,I64 type=PT_NATIVE)
|
||||
else {
|
||||
if (prt_num+'A'==ToUpper(drv_let)) {
|
||||
switch (type) {
|
||||
case PT_NATIVE:
|
||||
mbr.p[i].type=MBR_PT_NATIVE;
|
||||
case PT_REDSEA:
|
||||
mbr.p[i].type=MBR_PT_REDSEA;
|
||||
break;
|
||||
case PT_FAT32:
|
||||
mbr.p[i].type=MBR_PT_FAT32a;
|
||||
@@ -416,7 +416,7 @@ U0 ChgDsk(U8 drv_let=0)
|
||||
else if (bdev->flags&BDF_REMOVABLE)
|
||||
DskCacheInvalidate(p);
|
||||
Drv(drv_let);
|
||||
NativeFSFreeFreeLst(p);
|
||||
RedSeaFSFreeFreeLst(p);
|
||||
Preempt(old_preempt);
|
||||
}
|
||||
|
||||
@@ -464,7 +464,7 @@ U0 PrtRep()
|
||||
drv_let=Prt2Drv(p);
|
||||
if (Bt(&p->type,PTf_DISABLE))
|
||||
"$$FG,RED$$X";
|
||||
else if (drv_let==dft_drv)
|
||||
else if (drv_let==*sys_acct)
|
||||
"$$FG,GREEN$$:";
|
||||
else
|
||||
'' CH_SPACE;
|
||||
@@ -495,12 +495,12 @@ I64 ClusterNumNext(CPrt *p,I64 c,I64 cnt=1)
|
||||
unlock=PrtLock(p);
|
||||
switch (p->type) {
|
||||
case PT_ISO9660:
|
||||
case PT_NATIVE:
|
||||
case PT_REDSEA:
|
||||
c+=cnt;
|
||||
break;
|
||||
case PT_FAT32:
|
||||
while (cnt-->0 && 0<c<0x0FFFFFF8) {
|
||||
SetNativeBuf(p,c);
|
||||
SetFSBuf(p,c);
|
||||
c=p->cur_map_blk[c & (BLK_SIZE/4-1)];
|
||||
}
|
||||
if (!(0<c<0x0FFFFFF8))
|
||||
@@ -534,7 +534,7 @@ I64 RClustersBlks(CPrt *p,U8 *buf,I64 c,I64 blks)
|
||||
unlock=PrtLock(p);
|
||||
switch (p->type) {
|
||||
case PT_ISO9660:
|
||||
case PT_NATIVE:
|
||||
case PT_REDSEA:
|
||||
RBlks(p,buf,p->data+c*p->spc,blks);
|
||||
c+=(blks+p->spc-1)/p->spc;
|
||||
break;
|
||||
@@ -590,8 +590,8 @@ I64 Name2DirCluster(CPrt *p,U8 *dirname)
|
||||
StrFirstRem(buf,"/",buf2);
|
||||
if (*buf2) {
|
||||
switch (p->type) {
|
||||
case PT_NATIVE:
|
||||
cont=NativeFSFileFind(p,cur_dir_cluster,buf2,&de,FUF_JUST_DIRS);
|
||||
case PT_REDSEA:
|
||||
cont=RedSeaFSFileFind(p,cur_dir_cluster,buf2,&de,FUF_JUST_DIRS);
|
||||
break;
|
||||
case PT_FAT32:
|
||||
cont=FAT32FileFind(p,cur_dir_cluster,buf2,&de,FUF_JUST_DIRS);
|
||||
@@ -636,8 +636,8 @@ I64 Name2ParentDirCluster(CPrt *p,U8 *dirname)
|
||||
StrFirstRem(buf,"/",buf2);
|
||||
if (*buf2) {
|
||||
switch (p->type) {
|
||||
case PT_NATIVE:
|
||||
cont=NativeFSFileFind(p,cur_dir_cluster,buf2,&de,FUF_JUST_DIRS);
|
||||
case PT_REDSEA:
|
||||
cont=RedSeaFSFileFind(p,cur_dir_cluster,buf2,&de,FUF_JUST_DIRS);
|
||||
break;
|
||||
case PT_FAT32:
|
||||
cont=FAT32FileFind(p,cur_dir_cluster,buf2,&de,FUF_JUST_DIRS);
|
||||
@@ -676,7 +676,7 @@ I64 WClustersBlks(CPrt *p,U8 *buf,I64 c,I64 blks)
|
||||
try {
|
||||
unlock=PrtLock(p);
|
||||
switch (p->type) {
|
||||
case PT_NATIVE:
|
||||
case PT_REDSEA:
|
||||
WBlks(p,buf,p->data+c*p->spc,blks);
|
||||
c=0;
|
||||
break;
|
||||
@@ -715,8 +715,8 @@ I64 ClusersAlloc(CPrt *p,I64 c=0,I64 cnt=1,Bool contiguous=FALSE)
|
||||
PrtChk(p);
|
||||
if (cnt<=0) return c;
|
||||
switch (p->type) {
|
||||
case PT_NATIVE:
|
||||
return NativeFSAllocClusters(p,cnt);
|
||||
case PT_REDSEA:
|
||||
return RedSeaFSAllocClusters(p,cnt);
|
||||
case PT_FAT32:
|
||||
if (contiguous) {
|
||||
if (c) throw(EXCEPT_FILE,3);
|
||||
|
||||
@@ -25,7 +25,7 @@ Bool Drv(U8 drv_let)
|
||||
Free(Fs->cur_dir);
|
||||
Fs->cur_dir=StrNew("/");
|
||||
switch (p->type) {
|
||||
case PT_NATIVE:
|
||||
case PT_REDSEA:
|
||||
case PT_FAT32:
|
||||
case PT_ISO9660:
|
||||
return TRUE;
|
||||
@@ -44,7 +44,7 @@ Bool Cd(U8 *dirname,Bool make_dirs=FALSE)
|
||||
if (!*dirname) return TRUE;
|
||||
if (dirname[1]==':') {
|
||||
if (*dirname==':') {
|
||||
if (Fs->cur_prt->drv_let!=dft_drv)
|
||||
if (Fs->cur_prt->drv_let!=*sys_acct)
|
||||
if (!Drv(*dirname)) return FALSE;
|
||||
} else {
|
||||
if (Fs->cur_prt!=
|
||||
@@ -85,8 +85,8 @@ Bool Cd(U8 *dirname,Bool make_dirs=FALSE)
|
||||
p=Fs->cur_prt;
|
||||
cur_dir_cluster=Name2DirCluster(p,new_cur_dir);
|
||||
switch (p->type) {
|
||||
case PT_NATIVE:
|
||||
result=NativeFSCd(buf,cur_dir_cluster);
|
||||
case PT_REDSEA:
|
||||
result=RedSeaFSCd(buf,cur_dir_cluster);
|
||||
break;
|
||||
case PT_FAT32:
|
||||
result=FAT32Cd(buf,cur_dir_cluster);
|
||||
@@ -248,8 +248,8 @@ I64 Del(U8 *files_find_mask,Bool print_msg=TRUE)
|
||||
CFileAccess *fa;
|
||||
if (fa=FileAccessNew(files_find_mask)) {
|
||||
switch (fa->p->type) {
|
||||
case PT_NATIVE:
|
||||
result=NativeFSFilesDel(fa->p,Fs->cur_dir,fa->mask,0,FALSE,print_msg);
|
||||
case PT_REDSEA:
|
||||
result=RedSeaFSFilesDel(fa->p,Fs->cur_dir,fa->mask,0,FALSE,print_msg);
|
||||
break;
|
||||
case PT_FAT32:
|
||||
result=FAT32FilesDel(fa->p,Fs->cur_dir,fa->mask,0,FALSE,print_msg);
|
||||
@@ -296,8 +296,8 @@ U8 *FileRead(U8 *filename,I64 *_size=NULL,I64 *_attr=NULL,Bool raw=FALSE)
|
||||
curname=altname;
|
||||
if (fa=FileAccessNew(curname)) {
|
||||
switch (fa->p->type) {
|
||||
case PT_NATIVE:
|
||||
result=NativeFSFileRead(fa->p,Fs->cur_dir,fa->mask,&size,&attr,raw,&ac);
|
||||
case PT_REDSEA:
|
||||
result=RedSeaFSFileRead(fa->p,Fs->cur_dir,fa->mask,&size,&attr,raw,&ac);
|
||||
break;
|
||||
case PT_FAT32:
|
||||
result=FAT32FileRead(fa->p,Fs->cur_dir,fa->mask,&size,&attr,raw,&ac);
|
||||
@@ -322,8 +322,8 @@ U8 *FileRead(U8 *filename,I64 *_size=NULL,I64 *_attr=NULL,Bool raw=FALSE)
|
||||
while (!result && StrCmp(Fs->cur_dir,"/")) {
|
||||
Cd("..");
|
||||
switch (Fs->cur_prt->type) {
|
||||
case PT_NATIVE:
|
||||
result=NativeFSFileRead(fa->p,Fs->cur_dir,fa->mask,&size,&attr,raw,&ac);
|
||||
case PT_REDSEA:
|
||||
result=RedSeaFSFileRead(fa->p,Fs->cur_dir,fa->mask,&size,&attr,raw,&ac);
|
||||
break;
|
||||
case PT_FAT32:
|
||||
result=FAT32FileRead(fa->p,Fs->cur_dir,fa->mask,&size,&attr,raw,&ac);
|
||||
@@ -383,8 +383,8 @@ Bool FileFind(U8 *filename,CDirEntry *rde=NULL,I64 fuf_flags=0)
|
||||
if (fa=FileAccessNew(curname)) {
|
||||
cur_dir_cluster=Name2DirCluster(fa->p,Fs->cur_dir);
|
||||
switch (fa->p->type) {
|
||||
case PT_NATIVE:
|
||||
result=NativeFSFileFind(fa->p,cur_dir_cluster,fa->mask,&de,fuf_flags);
|
||||
case PT_REDSEA:
|
||||
result=RedSeaFSFileFind(fa->p,cur_dir_cluster,fa->mask,&de,fuf_flags);
|
||||
break;
|
||||
case PT_FAT32:
|
||||
result=FAT32FileFind(fa->p,cur_dir_cluster,fa->mask,&de,fuf_flags);
|
||||
@@ -411,8 +411,8 @@ Bool FileFind(U8 *filename,CDirEntry *rde=NULL,I64 fuf_flags=0)
|
||||
Cd("..");
|
||||
cur_dir_cluster=Name2DirCluster(fa->p,Fs->cur_dir);
|
||||
switch (fa->p->type) {
|
||||
case PT_NATIVE:
|
||||
result=NativeFSFileFind(fa->p,cur_dir_cluster,fa->mask,&de,fuf_flags);
|
||||
case PT_REDSEA:
|
||||
result=RedSeaFSFileFind(fa->p,cur_dir_cluster,fa->mask,&de,fuf_flags);
|
||||
break;
|
||||
case PT_FAT32:
|
||||
result=FAT32FileFind(fa->p,cur_dir_cluster,fa->mask,&de,fuf_flags);
|
||||
@@ -458,7 +458,7 @@ I64 FileSizeExpanded(U8 *filename,I64 fuf_flags=0)
|
||||
if (FileFind(filename,&de,fuf_flags)) {
|
||||
p=Drv2Prt(*de.full_name);
|
||||
Free(de.full_name);
|
||||
if (p->type==PT_NATIVE && de.expanded_size)
|
||||
if (p->type==PT_REDSEA && de.expanded_size)
|
||||
return de.expanded_size;
|
||||
else {
|
||||
if (de.size && FileAttr(de.name) & _ATTR_COMPRESSED) {
|
||||
@@ -472,7 +472,7 @@ I64 FileSizeExpanded(U8 *filename,I64 fuf_flags=0)
|
||||
}
|
||||
|
||||
I64 FileWrite(U8 *filename,U8 *fbuf,
|
||||
I64 size,CDate spdt=0,I64 attr=0,Bool raw=FALSE)
|
||||
I64 size,CDate cdt=0,I64 attr=0,Bool raw=FALSE)
|
||||
{
|
||||
I64 c=0;
|
||||
CHashGeneric *temph;
|
||||
@@ -481,13 +481,13 @@ I64 FileWrite(U8 *filename,U8 *fbuf,
|
||||
U8 *absname=FileNameAbs(filename);
|
||||
if (fa=FileAccessNew(filename,FALSE,TRUE)) {
|
||||
switch (fa->p->type) {
|
||||
case PT_NATIVE:
|
||||
c=NativeFSFileWrite(fa->p,Fs->cur_dir,fa->mask,
|
||||
fbuf,size,spdt,attr,raw,&ac);
|
||||
case PT_REDSEA:
|
||||
c=RedSeaFSFileWrite(fa->p,Fs->cur_dir,fa->mask,
|
||||
fbuf,size,cdt,attr,raw,&ac);
|
||||
break;
|
||||
case PT_FAT32:
|
||||
c=FAT32FileWrite(fa->p,Fs->cur_dir,fa->mask,
|
||||
fbuf,size,spdt,attr,raw,&ac);
|
||||
fbuf,size,cdt,attr,raw,&ac);
|
||||
break;
|
||||
case PT_ISO9660:
|
||||
PutDefineErr("ST_NOT_WRITABLE");
|
||||
|
||||
@@ -31,7 +31,7 @@ Bool CopySingle(U8 *f1,U8 *f2) //Just one file
|
||||
{
|
||||
U8 *absf1=FileNameAbs(f1),*absf2=FileNameAbs(f2),*buf;
|
||||
I64 cnt,n,size,attr1=FileAttr(f1),attr2=FileAttr(f2),
|
||||
xsum=NATIVE_XSUM,i,j;
|
||||
xsum=TEMPLEOS_XSUM,i,j;
|
||||
CFile *in_file=NULL,*out_file=NULL;
|
||||
|
||||
if (!StrCmp(absf1,absf2)) { //onto self?
|
||||
@@ -111,8 +111,8 @@ Bool MkDir(U8 *filename)
|
||||
name=MStrUtil(fa->mask,
|
||||
SUF_REM_LEADING|SUF_REM_TRAILING|SUF_REM_CTRL_CHARS);
|
||||
switch (fa->p->type) {
|
||||
case PT_NATIVE:
|
||||
result=NativeFSMkDir(fa->p,Fs->cur_dir,name);
|
||||
case PT_REDSEA:
|
||||
result=RedSeaFSMkDir(fa->p,Fs->cur_dir,name);
|
||||
break;
|
||||
case PT_FAT32:
|
||||
result=FAT32MkDir(fa->p,Fs->cur_dir,name);
|
||||
@@ -137,8 +137,8 @@ I64 SysDel(U8 *wild,Bool make_mask) //this is dangerous
|
||||
CFileAccess *fa;
|
||||
if (fa=FileAccessNew(wild,make_mask)) {
|
||||
switch (fa->p->type) {
|
||||
case PT_NATIVE:
|
||||
result=NativeFSFilesDel(fa->p,Fs->cur_dir,fa->mask,0,TRUE,TRUE);
|
||||
case PT_REDSEA:
|
||||
result=RedSeaFSFilesDel(fa->p,Fs->cur_dir,fa->mask,0,TRUE,TRUE);
|
||||
break;
|
||||
case PT_FAT32:
|
||||
result=FAT32FilesDel(fa->p,Fs->cur_dir,fa->mask,0,TRUE,TRUE);
|
||||
@@ -168,11 +168,11 @@ U0 Fmt(I64 drv_let,Bool quick=TRUE,Bool confirm=TRUE,I64 type=PT_FAT32)
|
||||
return;
|
||||
}
|
||||
switch (type) {
|
||||
case PT_NATIVE:
|
||||
case PT_REDSEA:
|
||||
Silent(ON);
|
||||
Drv(drv_let);
|
||||
Silent(old_silent);
|
||||
NativeFSFmt(drv_let,quick);
|
||||
RedSeaFSFmt(drv_let,quick);
|
||||
DskCacheInvalidate(Drv2Prt(drv_let));
|
||||
Drv(drv_let);
|
||||
break;
|
||||
@@ -266,7 +266,10 @@ U0 CDImageWriteTask(CDualBuf *d)
|
||||
n=cnt;
|
||||
if (n>d->CD_bdev->max_writes)
|
||||
n=d->CD_bdev->max_writes;
|
||||
buf=d->in_buf&1 ? d->buf1:d->buf0;
|
||||
if (d->in_buf&1)
|
||||
buf=d->buf1;
|
||||
else
|
||||
buf=d->buf0;
|
||||
while (d->in_buf>d->out_buf+1)
|
||||
Yield;
|
||||
FRBlks(f,buf,blk,n);
|
||||
@@ -345,7 +348,10 @@ U0 CDImageWrite(U8 cd_drv_let,U8 *in_name=NULL,I64 media_type=MT_CD)
|
||||
n=cnt;
|
||||
if (n>bdev->max_writes)
|
||||
n=bdev->max_writes;
|
||||
buf=d->out_buf&1 ? d->buf1:d->buf0;
|
||||
if (d->out_buf&1)
|
||||
buf=d->buf1;
|
||||
else
|
||||
buf=d->buf0;
|
||||
while (d->in_buf<=d->out_buf)
|
||||
Yield;
|
||||
ATAPIWriteBlks(bdev,buf,blk/spc,(n+spc-1)/spc);
|
||||
|
||||
@@ -662,8 +662,6 @@ Bool BootCdProbe(CBlkDev *bdev)
|
||||
Bool result=FALSE;
|
||||
"Port: %04X,%04X Unit: %02X ",bdev->base0,bdev->base1,bdev->unit;
|
||||
if (ATAProbe(bdev->base0,bdev->base1,bdev->unit)==BDT_ATAPI) {
|
||||
//After preboot + BootCD.BIN.Z comes Kernel.BIN.C
|
||||
//See $LK,"CDBOOT","FA:::/TempleOS/Adam/Dsk/DskCDDVD.CPP,CDBOOT"$, See $LK,"CD Boot Blk","FF:::/TempleOS/Adam/Boot/BootCD.CPP,BOOT_CODE_CDROM"$
|
||||
" ATAPI";
|
||||
if (ATAPIStartStop(bdev,TRUE,tS+5.0)) {
|
||||
" Started";
|
||||
@@ -774,20 +772,15 @@ U0 ATARepEntry(I64 base0,I64 base1,I64 unit,I64 irq,U8 *msg,CATARep **_root,I64
|
||||
}
|
||||
}
|
||||
|
||||
Bool hint_ata_disable=FALSE;
|
||||
|
||||
U0 ATARepExitAllApplications()
|
||||
Bool ATARepExitAllApplications()
|
||||
{
|
||||
I64 ch;
|
||||
PutDefine("ST_GOING_TO_PROBE_HARDWARE");
|
||||
PutDefine("ST_EXIT_ALL_APPLICATIONS");
|
||||
PutDefine("ST_PRESS_A_KEY");
|
||||
"Press '$$FG,PURPLE$$p$$FG$$' to probe or '$$FG,PURPLE$$s$$FG$$' to skip.\n";
|
||||
ch=ToUpper(GetChar(NULL,FALSE));
|
||||
if (ch=='S')
|
||||
hint_ata_disable=TRUE;
|
||||
PutDefine("ST_PROBE_OR_SKIP");
|
||||
if (ToUpper(GetChar(,FALSE))=='S')
|
||||
return TRUE;
|
||||
else
|
||||
hint_ata_disable=FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
public I64 ATARep(Bool pmt=TRUE,Bool just_ide=FALSE,CATARep **_root=NULL)
|
||||
@@ -800,9 +793,7 @@ public I64 ATARep(Bool pmt=TRUE,Bool just_ide=FALSE,CATARep **_root=NULL)
|
||||
|
||||
if (_root) *_root=NULL;
|
||||
|
||||
if (pmt)
|
||||
ATARepExitAllApplications;
|
||||
if (hint_ata_disable)
|
||||
if (pmt && ATARepExitAllApplications)
|
||||
return 0;
|
||||
|
||||
old_preempt=Preempt(OFF);
|
||||
@@ -870,13 +861,13 @@ public I64 ATARep(Bool pmt=TRUE,Bool just_ide=FALSE,CATARep **_root=NULL)
|
||||
return num_hints;
|
||||
}
|
||||
|
||||
CATARep *ATAIDDrvs(CATARep *root,U8 _dft_drv,CATARep **_ata_drv,CATARep **_atapi_drv)
|
||||
CATARep *ATAIDDrvs(CATARep *root,U8 _sys_acct_drv,CATARep **_ata_drv,CATARep **_atapi_drv)
|
||||
{
|
||||
CATARep *result=NULL,*tempha=root,*ata_drv=NULL,*atapi_drv=NULL;
|
||||
CBlkDev *bdev;
|
||||
Bool was_silent=Silent(ON);
|
||||
try
|
||||
bdev=Drv2BlkDev(_dft_drv);
|
||||
bdev=Drv2BlkDev(_sys_acct_drv);
|
||||
catch {
|
||||
Fs->catch_except=TRUE;
|
||||
bdev=NULL;
|
||||
@@ -929,7 +920,7 @@ I64 AutoMountIDE()
|
||||
I64 result=0;
|
||||
CATARep *root=NULL,*ata_drv=NULL,*atapi_drv=NULL,*tempha;
|
||||
ATARep(FALSE,TRUE,&root);
|
||||
ATAIDDrvs(root,dft_drv,&ata_drv,&atapi_drv);
|
||||
ATAIDDrvs(root,*sys_acct,&ata_drv,&atapi_drv);
|
||||
if (ata_drv && ATAMount(sys_first_hd_drv_let,BDT_ATA,
|
||||
ata_drv->base0,ata_drv->base1,ata_drv->unit))
|
||||
result++;
|
||||
|
||||
@@ -31,13 +31,13 @@ I64 BlkDevAdd(CBlkDev *bdev,Bool one_prt,Bool make_free)
|
||||
if (make_free)
|
||||
p=PrtMakeFree(bdev->first_drv_let+result);
|
||||
else
|
||||
p=PrtNextFree(bdev->first_drv_let);
|
||||
p=PrtNextFree(bdev->first_drv_let+result);
|
||||
p->bdev=bdev;
|
||||
p->size=bdev->max_blk+1;
|
||||
switch (bdev->type) {
|
||||
case BDT_RAM:
|
||||
p->pt_signature=PRT_SIGNATURE_VAL;
|
||||
p->type=PT_NATIVE;
|
||||
p->type=PT_REDSEA;
|
||||
p->rblks=&RAMRBlks;
|
||||
p->wblks=&RAMWBlks;
|
||||
//This is to force creation of a RAM
|
||||
@@ -61,7 +61,7 @@ I64 BlkDevAdd(CBlkDev *bdev,Bool one_prt,Bool make_free)
|
||||
if (one_prt) {
|
||||
p->pt_signature=PRT_SIGNATURE_VAL;
|
||||
result++;
|
||||
p->type=PT_NATIVE;
|
||||
p->type=PT_REDSEA;
|
||||
p->rblks=&ATARBlks;
|
||||
p->wblks=&ATAWBlks;
|
||||
p->size=bdev->max_blk+1;
|
||||
@@ -82,18 +82,18 @@ I64 BlkDevAdd(CBlkDev *bdev,Bool one_prt,Bool make_free)
|
||||
if (make_free)
|
||||
p=PrtMakeFree(bdev->first_drv_let+result);
|
||||
else
|
||||
p=PrtNextFree(bdev->first_drv_let);
|
||||
p=PrtNextFree(bdev->first_drv_let+result);
|
||||
p->bdev=bdev;
|
||||
p->rblks=&ATARBlks;
|
||||
p->wblks=&ATAWBlks;
|
||||
p->offset=mbr.p[i].offset+offset;
|
||||
p->size =mbr.p[i].size;
|
||||
switch (mbr.p[i].type) {
|
||||
case MBR_PT_NATIVE:
|
||||
case MBR_PT_REDSEA:
|
||||
p->pt_signature=PRT_SIGNATURE_VAL;
|
||||
result++;
|
||||
p->type=PT_NATIVE;
|
||||
NativeFSPrtInit(p);
|
||||
p->type=PT_REDSEA;
|
||||
RedSeaFSPrtInit(p);
|
||||
break;
|
||||
case MBR_PT_FAT32a:
|
||||
case MBR_PT_FAT32b:
|
||||
@@ -104,9 +104,9 @@ I64 BlkDevAdd(CBlkDev *bdev,Bool one_prt,Bool make_free)
|
||||
ATAReadBlks(bdev,&br,p->offset,1);
|
||||
p->pt_signature=PRT_SIGNATURE_VAL;
|
||||
result++;
|
||||
if (br.signature==MBR_PT_NATIVE) {
|
||||
p->type=PT_NATIVE;
|
||||
NativeFSPrtInit(p);
|
||||
if (br.signature==MBR_PT_REDSEA) {
|
||||
p->type=PT_REDSEA;
|
||||
RedSeaFSPrtInit(p);
|
||||
} else {
|
||||
p->type=PT_FAT32;
|
||||
FAT32PrtInit(p);
|
||||
@@ -185,7 +185,7 @@ U0 Mount(Bool repartition=FALSE)
|
||||
{
|
||||
CBlkDev *bdev;
|
||||
I64 first_prt_num,type,unit,num_hints;
|
||||
U8 blks_buf[32],base0_buf[128],base1_buf[128];
|
||||
U8 blks_buf[128],addr_buf[128],base0_buf[128],base1_buf[128];
|
||||
Bool add;
|
||||
CATARep *root,*tempha;
|
||||
|
||||
@@ -201,7 +201,7 @@ U0 Mount(Bool repartition=FALSE)
|
||||
|
||||
unit=0;
|
||||
if (type==BDT_ATA || type==BDT_ATAPI) {
|
||||
num_hints=ATARep(TRUE,,&root);
|
||||
num_hints=ATARep(,,&root);
|
||||
do {
|
||||
if (num_hints)
|
||||
PutDefine("ST_MOUNT_BASE0_HINT");
|
||||
@@ -231,15 +231,20 @@ U0 Mount(Bool repartition=FALSE)
|
||||
LinkedLstDel(root);
|
||||
}
|
||||
if (type==BDT_RAM) {
|
||||
PutDefine("ST_MOUNT_ADDR");
|
||||
GetS(addr_buf,128);
|
||||
PutDefine("ST_MOUNT_BLKS");
|
||||
GetS(blks_buf,32);
|
||||
GetS(blks_buf,128);
|
||||
}
|
||||
|
||||
if (BDT_NULL<type<BDT_NUM_TYPES && 0<=unit<=1) {
|
||||
bdev=BlkDevNextFree(first_prt_num+'A',type);
|
||||
bdev->unit=unit;
|
||||
if (type==BDT_RAM)
|
||||
if (type==BDT_RAM) {
|
||||
if (!*addr_buf) StrCpy(addr_buf,"0");
|
||||
bdev->RAM_dsk=A2I(addr_buf);
|
||||
bdev->max_blk=A2I(blks_buf)-1;
|
||||
}
|
||||
if (type==BDT_ATA ||
|
||||
type==BDT_ATAPI) {
|
||||
bdev->base0=A2I(base0_buf);
|
||||
@@ -269,7 +274,10 @@ I64 SysPmtI64()
|
||||
U8 st[136];
|
||||
StrCpy(st,"0x");
|
||||
GetS(st+2,134,FALSE);
|
||||
return A2I(st);
|
||||
if (!st[2])
|
||||
return 0;
|
||||
else
|
||||
return A2I(st);
|
||||
}
|
||||
|
||||
Bool PmtBaseUnit(CBlkDev *bdev)
|
||||
@@ -287,12 +295,19 @@ Bool PmtBaseUnit(CBlkDev *bdev)
|
||||
PutDefine("ST_CDROM_PORTS_PMT1");
|
||||
bdev->base0=SysPmtI64;
|
||||
bdev->base1=0;
|
||||
"\nUnit (0 or 1): ";
|
||||
do ch=GetChar(NULL,FALSE);
|
||||
while (!('0'<=ch<='1'));
|
||||
'' ch;
|
||||
bdev->unit=ch-'0';
|
||||
return TRUE;
|
||||
bdev->unit =0;
|
||||
if (bdev->base0) {
|
||||
"\nUnit (0 or 1): ";
|
||||
do ch=GetChar(,FALSE);
|
||||
while (!('0'<=ch<='1'));
|
||||
'' ch;
|
||||
bdev->unit=ch-'0';
|
||||
cdrom_boot_is_good=BootCdProbe(bdev);
|
||||
return TRUE;
|
||||
} else {
|
||||
cdrom_boot_is_good=FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
@@ -307,11 +322,11 @@ U0 BlkDevsInitAll()
|
||||
drv_to_prt[i]=&sys_prts[i];
|
||||
sys_raw_dc_col=0;
|
||||
#exe {
|
||||
if (kernel_cfg->opts[CFG_AUTO_MOUNT_IDE])
|
||||
StreamPutS("AutoMountIDE;");
|
||||
StreamPutS("#exe {OptOff(OPTf_WARN_PAREN);}");
|
||||
StreamDoc(kernel_cfg->add_dev);
|
||||
StreamPutS("#exe {OptOn(OPTf_WARN_PAREN);}");
|
||||
if (kernel_cfg->opts[CFG_AUTO_MOUNT_IDE])
|
||||
StreamPutS("AutoMountIDE;");
|
||||
StreamPutS("#exe {OptOff(OPTf_WARN_PAREN);}");
|
||||
StreamDoc(kernel_cfg->add_dev);
|
||||
StreamPutS("#exe {OptOn(OPTf_WARN_PAREN);}");
|
||||
};
|
||||
PrtRep;
|
||||
}
|
||||
|
||||
@@ -22,11 +22,11 @@ CFile *FOpen(U8 *filename,U8 *flags,I64 cnt=0)
|
||||
f->file_cluster_num=INVALID_CLUSTER;
|
||||
full_name=FileNameAbs(filename);
|
||||
f->p=Drv2Prt(*full_name);
|
||||
if (f->p->type==PT_NATIVE)
|
||||
if (f->p->type==PT_REDSEA)
|
||||
contiguous=TRUE;
|
||||
if (contiguous) {
|
||||
f->flags|=FF_CONTIGUOUS;
|
||||
if (f->p->type!=PT_NATIVE) {
|
||||
if (f->p->type!=PT_REDSEA) {
|
||||
if (!(FileAttr(filename) & _ATTR_CONTIGUOUS))
|
||||
throw(EXCEPT_FILE,2);
|
||||
}
|
||||
@@ -82,7 +82,7 @@ U0 FClose(CFile *f)
|
||||
if (f->flags & FF_NEEDS_WRITE) {
|
||||
if (fa=FileAccessNew(f->de.full_name)) {
|
||||
if (!(f->flags & FF_USE_OLD_DATETIME))
|
||||
f->de.datetime=GetCurTimeCDate;
|
||||
f->de.datetime=GetCurTimeDate;
|
||||
if (f->flags & FF_NEW_FILE)
|
||||
CDirNew(fa->p,Fs->cur_dir,&f->de,TRUE);
|
||||
else
|
||||
@@ -152,7 +152,10 @@ Bool FRBlks(CFile *f,U8 *buf,I64 blk=FFB_NEXT_BLK,I64 cnt=1)
|
||||
|
||||
if (i=blk%spc) {
|
||||
c=FSetCluster(f,c,blk,TRUE);
|
||||
j= cnt<spc-i ? cnt:spc-i;
|
||||
if (cnt<spc-i)
|
||||
j=cnt;
|
||||
else
|
||||
j=spc-i;
|
||||
MemCpy(buf,f->cluster_buf+i<<BLK_SIZE_BITS,j<<BLK_SIZE_BITS);
|
||||
buf+=j<<BLK_SIZE_BITS;
|
||||
cnt-=j;
|
||||
@@ -218,7 +221,10 @@ Bool FWBlks(CFile *f,U8 *buf,I64 blk=FFB_NEXT_BLK,I64 cnt=1)
|
||||
|
||||
if (i=blk%spc) {
|
||||
FSetCluster(f,c,blk,TRUE);
|
||||
j=cnt<spc-i ? cnt:spc-i;
|
||||
if (cnt<spc-i)
|
||||
j=cnt;
|
||||
else
|
||||
j=spc-i;
|
||||
MemCpy(f->cluster_buf+BLK_SIZE*i,buf,j<<BLK_SIZE_BITS);
|
||||
f->flags|=FF_BUF_DIRTY;
|
||||
buf+=j<<BLK_SIZE_BITS;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
Bool CDirNew(CPrt *p,U8 *cur_dir,CDirEntry *tempm,Bool free_old_chain=TRUE)
|
||||
{
|
||||
switch (p->type) {
|
||||
case PT_NATIVE:
|
||||
return NativeFSDirNew(p,cur_dir,tempm,free_old_chain);
|
||||
case PT_REDSEA:
|
||||
return RedSeaFSDirNew(p,cur_dir,tempm,free_old_chain);
|
||||
case PT_FAT32:
|
||||
return FAT32DirNew(p,cur_dir,tempm,free_old_chain);
|
||||
case PT_ISO9660:
|
||||
@@ -151,8 +151,8 @@ CDirEntry *SysFilesFind(U8 *files_find_mask,I64 fuf_flags)
|
||||
CDirEntry *result=NULL;
|
||||
PrtChk(p);
|
||||
switch (p->type) {
|
||||
case PT_NATIVE:
|
||||
result=NativeFSFilesFind(files_find_mask,fuf_flags);
|
||||
case PT_REDSEA:
|
||||
result=RedSeaFSFilesFind(files_find_mask,fuf_flags);
|
||||
break;
|
||||
case PT_FAT32:
|
||||
result=FAT32FilesFind(files_find_mask,fuf_flags);
|
||||
@@ -237,7 +237,7 @@ U0 Dir2(U8 *files_find_mask,I64 fuf_flags,Bool full)
|
||||
esize=Bsr(esize)/4+1;
|
||||
c=Bsr(c)/4+1;
|
||||
|
||||
"$$MA+A,\"Directory \",\"PopUpCd;Dir;\n\"$$ of %s\n",st;
|
||||
"$$MA+A,\"Directory\",\"PopUpCd;Dir;\n\"$$ of %s\n",st;
|
||||
if (full)
|
||||
"__DATE__ __TIME__ %*ts %*ts %*ts\n",
|
||||
csize,"SIZE",esize,"UNCMPSIZE",c,"CLUSTER";
|
||||
|
||||
@@ -100,7 +100,7 @@ CPrt *Drv2Prt(U8 drv_let=0)
|
||||
p=Fs->cur_prt;
|
||||
else {
|
||||
if (drv_let==':')
|
||||
drv_let=dft_drv;
|
||||
drv_let=*sys_acct;
|
||||
p=drv_to_prt[ToUpper(drv_let)-'A'];
|
||||
}
|
||||
PrtChk(p);
|
||||
@@ -159,7 +159,7 @@ U8 *DirNameAbs(U8 *_dirname)
|
||||
drv[2]=0;
|
||||
if (*dirname && dirname[1]==':') {
|
||||
if (*dirname==':')
|
||||
*drv=dft_drv;
|
||||
*drv=*sys_acct;
|
||||
else
|
||||
*drv=*dirname;
|
||||
dirname=dirname+2;
|
||||
@@ -267,18 +267,19 @@ U8 *DftExt(U8 *filename,U8 *extension)
|
||||
return result;
|
||||
}
|
||||
|
||||
CDirEntry *CdDir(CDirEntry *tempm,U8 *abs_name)
|
||||
CDirEntry *Cd2DirEntry(CDirEntry *tempm,U8 *abs_name)
|
||||
{
|
||||
I64 i;
|
||||
while (tempm) {
|
||||
i=StrLen(tempm->full_name);
|
||||
if (StrNCmp(tempm->full_name,abs_name,i))
|
||||
if (StrNCmp(tempm->full_name,abs_name,i)||
|
||||
i && tempm->full_name[i-1]!='/' && abs_name[i] && abs_name[i]!='/')
|
||||
tempm=tempm->next;
|
||||
else
|
||||
if (StrLen(abs_name)==i)
|
||||
return tempm;
|
||||
else
|
||||
return CdDir(tempm->sub,abs_name);
|
||||
return Cd2DirEntry(tempm->sub,abs_name);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
U0 CDate2Dos(U16 *t,U16 *d,CDate spdt)
|
||||
U0 CDate2Dos(U16 *t,U16 *d,CDate cdt)
|
||||
{
|
||||
CDateStruct ds;
|
||||
CDate2CDateStruct(&ds,spdt+local_time_offset);
|
||||
Date2DateStruct(&ds,cdt+local_time_offset);
|
||||
*d=ds.day_of_mon+(ds.mon+(ds.year-1980)<<4)<<5;
|
||||
*t=ds.sec>>1+(ds.min+ds.hour<<6)<<5;
|
||||
}
|
||||
@@ -16,7 +16,7 @@ CDate Dos2CDate(U16 t,U16 d)
|
||||
ds.sec=(t&0x1F)*2; t=t>>5;
|
||||
ds.min=t&0x3F;
|
||||
ds.hour=t>>6;
|
||||
return CDateStruct2CDate(&ds)-local_time_offset;
|
||||
return DateStruct2Date(&ds)-local_time_offset;
|
||||
}
|
||||
|
||||
U0 FAT32PrtInit(CPrt *p)
|
||||
@@ -71,9 +71,9 @@ U0 FAT32Fmt(U8 drv_let,Bool quick=TRUE)
|
||||
PrtLock(p);
|
||||
SetDrvType(drv_let,PT_FAT32);
|
||||
p->type=PT_FAT32;
|
||||
br->jump_and_nop[0]=0xEB;
|
||||
br->jump_and_nop[1]=0x58;
|
||||
br->jump_and_nop[2]=0x90;
|
||||
br->jump_and_nop[0]=OC_JMP_REL8;
|
||||
br->jump_and_nop[1]=offset(CFAT32Boot.code)-2;
|
||||
br->jump_and_nop[2]=OC_NOP;
|
||||
MemCpy(br->oem_name,"MSWIN4.1",8);
|
||||
br->bytes_per_sect=BLK_SIZE;
|
||||
if (p->size<= 500000)
|
||||
@@ -163,7 +163,10 @@ I64 FATNameXSum(U8 *src)
|
||||
{
|
||||
I64 i,result=0;
|
||||
for (i=0;i<11;i++)
|
||||
result.u8[0]=(result&1?0x80:0)+result>>1+*src++;
|
||||
if (result&1)
|
||||
result.u8[0]=0x80+result>>1+*src++;
|
||||
else
|
||||
result.u8[0]=result>>1+*src++;
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -288,7 +291,7 @@ Bool FAT32DirFill(CFAT32DirEntry *de,CDirEntry *tempm,I64 *_de_cnt=NULL)
|
||||
de[de_cnt].size=tempm->size;
|
||||
de[de_cnt].attr=tempm->attr;
|
||||
if (!tempm->datetime)
|
||||
tempm->datetime=GetCurTimeCDate;
|
||||
tempm->datetime=GetCurTimeDate;
|
||||
CDate2Dos(&de[de_cnt].WrtTime,&de[de_cnt].WrtDate,tempm->datetime);
|
||||
if (_de_cnt)
|
||||
*_de_cnt=de_cnt+1;
|
||||
@@ -447,7 +450,7 @@ U0 FAT32FreeClusters(CPrt *p,I64 c)
|
||||
unlock=PrtLock(p);
|
||||
CleanMAPBuf(p);
|
||||
do {
|
||||
SetNativeBuf(p,c,0);
|
||||
SetFSBuf(p,c,0);
|
||||
next=p->cur_map_blk[c&(BLK_SIZE/4-1)];
|
||||
p->cur_map_blk[c&(BLK_SIZE/4-1)]=0;
|
||||
LBts(p->buffered_map_dirty_bits,0);
|
||||
@@ -457,7 +460,7 @@ U0 FAT32FreeClusters(CPrt *p,I64 c)
|
||||
|
||||
c=saved_c;
|
||||
do {
|
||||
SetNativeBuf(p,c,1);
|
||||
SetFSBuf(p,c,1);
|
||||
next=p->cur_map_blk[c&(BLK_SIZE/4-1)];
|
||||
p->cur_map_blk[c&(BLK_SIZE/4-1)]=0;
|
||||
LBts(p->buffered_map_dirty_bits,0);
|
||||
@@ -498,14 +501,14 @@ I64 FAT32AllocClusters(CPrt *p,I64 c,I64 cnt)
|
||||
j=1;
|
||||
wrap_around=TRUE;
|
||||
}
|
||||
SetNativeBuf(p,j);
|
||||
SetFSBuf(p,j);
|
||||
if (!p->cur_map_blk[j&(BLK_SIZE/4-1)])
|
||||
break;
|
||||
}
|
||||
if (!(0<first<0x0FFFFFF8))
|
||||
first=j;
|
||||
if (0<c<l) {
|
||||
SetNativeBuf(p,c);
|
||||
SetFSBuf(p,c);
|
||||
p->cur_map_blk[c&(BLK_SIZE/4-1)]=j;
|
||||
LBts(p->buffered_map_dirty_bits,0);
|
||||
}
|
||||
@@ -513,7 +516,7 @@ I64 FAT32AllocClusters(CPrt *p,I64 c,I64 cnt)
|
||||
}
|
||||
|
||||
if (0<c<l) {
|
||||
SetNativeBuf(p,c);
|
||||
SetFSBuf(p,c);
|
||||
p->cur_map_blk[c&(BLK_SIZE/4-1)]=0x0FFFFFFF;
|
||||
LBts(p->buffered_map_dirty_bits,0);
|
||||
}
|
||||
@@ -552,7 +555,7 @@ I64 FAT32AllocContiguousClusters(CPrt *p,I64 cnt)
|
||||
while (cont && i<cnt) {
|
||||
if ((first+i+1)*p->spc+p->data>p->size+p->offset)
|
||||
Dbg;
|
||||
SetNativeBuf(p,first+i);
|
||||
SetFSBuf(p,first+i);
|
||||
if (p->cur_map_blk[(first+i)&(BLK_SIZE/4-1)])
|
||||
cont=FALSE;
|
||||
else
|
||||
@@ -564,7 +567,7 @@ I64 FAT32AllocContiguousClusters(CPrt *p,I64 cnt)
|
||||
CleanMAPBuf(p);
|
||||
|
||||
for (i=0;i<cnt;i++) {
|
||||
SetNativeBuf(p,first+i,0);
|
||||
SetFSBuf(p,first+i,0);
|
||||
if (i+1==cnt)
|
||||
p->cur_map_blk[(first+i)&(BLK_SIZE/4-1)]=0x0FFFFFFF;
|
||||
else
|
||||
@@ -574,7 +577,7 @@ I64 FAT32AllocContiguousClusters(CPrt *p,I64 cnt)
|
||||
CleanMAPBuf(p,0);
|
||||
|
||||
for (i=0;i<cnt;i++) {
|
||||
SetNativeBuf(p,first+i,1);
|
||||
SetFSBuf(p,first+i,1);
|
||||
if (i+1==cnt)
|
||||
p->cur_map_blk[(first+i)&(BLK_SIZE/4-1)]=0x0FFFFFFF;
|
||||
else
|
||||
@@ -834,7 +837,7 @@ I64 FAT32FilesDel(CPrt *p,U8 *cur_dir,U8 *files_find_mask,I64 fuf_flags,
|
||||
}
|
||||
|
||||
I64 FAT32FileWrite(CPrt *p,U8 *cur_dir,U8 *name,U8 *buf,I64 size,
|
||||
CDate spdt=0,I64 attr=0,Bool raw=FALSE,
|
||||
CDate cdt=0,I64 attr=0,Bool raw=FALSE,
|
||||
CArcCompress **_ac2=NULL)
|
||||
{
|
||||
CDirEntry de;
|
||||
@@ -844,8 +847,8 @@ I64 FAT32FileWrite(CPrt *p,U8 *cur_dir,U8 *name,U8 *buf,I64 size,
|
||||
MemSet(&de,0,sizeof(CDirEntry));
|
||||
if (_ac2) *_ac2=NULL;
|
||||
if (size<0) size=0;
|
||||
if (!spdt)
|
||||
spdt=GetCurTimeCDate;
|
||||
if (!cdt)
|
||||
cdt=GetCurTimeDate;
|
||||
if (p->type!=PT_FAT32)
|
||||
PutDefine("ST_NOT_FAT32");
|
||||
else if (!CFileNameTo(de.name,name))
|
||||
@@ -869,7 +872,7 @@ I64 FAT32FileWrite(CPrt *p,U8 *cur_dir,U8 *name,U8 *buf,I64 size,
|
||||
c=0x0FFFFFFF;
|
||||
de.cluster=c;
|
||||
de.attr=attr;
|
||||
de.datetime=spdt;
|
||||
de.datetime=cdt;
|
||||
if (blk_cnt)
|
||||
WClustersBlks(p,buf,c,blk_cnt);
|
||||
FAT32DirNew(p,cur_dir,&de,TRUE);
|
||||
@@ -979,7 +982,7 @@ Bool FAT32MkDir(CPrt *p,U8 *cur_dir,U8 *name)
|
||||
d_native.name[1]=0;
|
||||
d_native.cluster=c;
|
||||
d_native.size=0;
|
||||
d_native.datetime=GetCurTimeCDate;
|
||||
d_native.datetime=GetCurTimeDate;
|
||||
FAT32DirFill(dFAT,&d_native);
|
||||
dFAT++;
|
||||
|
||||
@@ -990,7 +993,7 @@ Bool FAT32MkDir(CPrt *p,U8 *cur_dir,U8 *name)
|
||||
d_native.name[2]=0;
|
||||
d_native.cluster=cur_dir_cluster;
|
||||
d_native.size=0;
|
||||
d_native.datetime=GetCurTimeCDate;
|
||||
d_native.datetime=GetCurTimeDate;
|
||||
FAT32DirFill(dFAT,&d_native);
|
||||
WClusters(p,buf,c,1);
|
||||
Free(buf);
|
||||
|
||||
@@ -57,10 +57,10 @@ ipi_done:
|
||||
return result;
|
||||
}
|
||||
|
||||
U0 CDate2ISO1(CISO1Date *dst,CDate spdt)
|
||||
U0 Date2ISO1(CISO1Date *dst,CDate cdt)
|
||||
{
|
||||
CDateStruct ds;
|
||||
CDate2CDateStruct(&ds,spdt);
|
||||
Date2DateStruct(&ds,cdt);
|
||||
dst->year=ds.year-ISO1_BASE_YEAR;
|
||||
dst->mon=ds.mon;
|
||||
dst->day=ds.day_of_mon;
|
||||
@@ -81,7 +81,7 @@ CDate ISO1DateStruct2CDate(CISO1Date *dt)
|
||||
ds.sec=dt->sec;
|
||||
ds.min=dt->min;
|
||||
ds.hour=dt->hour;
|
||||
return CDateStruct2CDate(&ds);
|
||||
return DateStruct2Date(&ds);
|
||||
}
|
||||
|
||||
Bool ISO1FromName(U8 *dst,U8 *src)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
U0 NativeFSFreeFreeLst(CPrt *p)
|
||||
U0 RedSeaFSFreeFreeLst(CPrt *p)
|
||||
{
|
||||
CFreeLst *tempf,*tempf1;
|
||||
Bool unlock;
|
||||
@@ -20,7 +20,7 @@ U0 NativeFSFreeFreeLst(CPrt *p)
|
||||
PrtUnlock(p);
|
||||
}
|
||||
|
||||
U0 NativeFSFreeLstBuild(CPrt *p)
|
||||
U0 RedSeaFSFreeLstBuild(CPrt *p)
|
||||
{
|
||||
Bool unlock;
|
||||
CFreeLst *tempf;
|
||||
@@ -30,13 +30,13 @@ U0 NativeFSFreeLstBuild(CPrt *p)
|
||||
try {
|
||||
unlock=PrtLock(p);
|
||||
if (p->next_free)
|
||||
NativeFSFreeFreeLst(p);
|
||||
RedSeaFSFreeFreeLst(p);
|
||||
p->next_free=&p->next_free;
|
||||
p->last_free=&p->next_free;
|
||||
while (first<max_cluster) {
|
||||
i=0; //count free clusters
|
||||
while (first+i<max_cluster) {
|
||||
SetNativeBuf(p,first+i);
|
||||
SetFSBuf(p,first+i);
|
||||
if (Bt(p->cur_map_blk,(first+i)&(BLK_SIZE<<3-1)))
|
||||
break;
|
||||
else
|
||||
@@ -57,18 +57,18 @@ U0 NativeFSFreeLstBuild(CPrt *p)
|
||||
PrtUnlock(p);
|
||||
}
|
||||
|
||||
U0 NativeFSPrtInit(CPrt *p)
|
||||
U0 RedSeaFSPrtInit(CPrt *p)
|
||||
{
|
||||
CBootStruct br;
|
||||
Bool unlock;
|
||||
try {
|
||||
unlock=PrtLock(p);
|
||||
RBlks(p,&br,p->offset,1);
|
||||
if (br.signature!=MBR_PT_NATIVE ||
|
||||
if (br.signature!=MBR_PT_REDSEA ||
|
||||
br.signature2!=0xAA55)
|
||||
throw(EXCEPT_PRT,7);
|
||||
p->type=PT_NATIVE;
|
||||
NativeFSFreeFreeLst(p);
|
||||
p->type=PT_REDSEA;
|
||||
RedSeaFSFreeFreeLst(p);
|
||||
p->spc=br.sects_per_cluster;
|
||||
p->size=br.sects;
|
||||
p->data=p->offset+1+br.bitmap_sects-p->spc;
|
||||
@@ -83,16 +83,16 @@ U0 NativeFSPrtInit(CPrt *p)
|
||||
PrtUnlock(p);
|
||||
}
|
||||
|
||||
Bool NativeFSDrvValidate(U8 drv_let)
|
||||
Bool RedSeaFSDrvValidate(U8 drv_let)
|
||||
{
|
||||
CPrt *p;
|
||||
CBootStruct br;
|
||||
Bool result=FALSE;
|
||||
try {
|
||||
p=Drv2Prt(drv_let);
|
||||
if (p->type==PT_NATIVE &&
|
||||
if (p->type==PT_REDSEA &&
|
||||
RBlks(p,&br,p->offset,1) &&
|
||||
br.signature==MBR_PT_NATIVE &&
|
||||
br.signature==MBR_PT_REDSEA &&
|
||||
br.signature2==0xAA55 &&
|
||||
br.sects==p->size)
|
||||
result=TRUE;
|
||||
@@ -101,7 +101,7 @@ Bool NativeFSDrvValidate(U8 drv_let)
|
||||
return result;
|
||||
}
|
||||
|
||||
U0 NativeFSFmt(U8 drv_let,Bool quick=TRUE)
|
||||
U0 RedSeaFSFmt(U8 drv_let,Bool quick=TRUE)
|
||||
{
|
||||
U8 *root_dir;
|
||||
CDirEntry *d_native;
|
||||
@@ -110,9 +110,9 @@ U0 NativeFSFmt(U8 drv_let,Bool quick=TRUE)
|
||||
I64 i,n;
|
||||
try {
|
||||
PrtLock(p);
|
||||
// SetDrvType(drv_let,PT_NATIVE);
|
||||
// SetDrvType(drv_let,PT_REDSEA);
|
||||
SetDrvType(drv_let,PT_FAT32);
|
||||
p->type=PT_NATIVE;
|
||||
p->type=PT_REDSEA;
|
||||
br->U8s_per_sect=BLK_SIZE;
|
||||
if (p->size<0x20000)
|
||||
br->sects_per_cluster=1;
|
||||
@@ -127,7 +127,7 @@ U0 NativeFSFmt(U8 drv_let,Bool quick=TRUE)
|
||||
else
|
||||
br->sects_per_cluster=32;
|
||||
|
||||
br->signature=MBR_PT_NATIVE;
|
||||
br->signature=MBR_PT_REDSEA;
|
||||
br->signature2=0xAA55;
|
||||
br->sects=p->size;
|
||||
n=br->sects_per_cluster*(BLK_SIZE<<3);
|
||||
@@ -143,7 +143,7 @@ U0 NativeFSFmt(U8 drv_let,Bool quick=TRUE)
|
||||
WZeroBlks(p,p->offset,i);
|
||||
|
||||
WBlks(p,br,p->offset,1);
|
||||
NativeFSPrtInit(p);
|
||||
RedSeaFSPrtInit(p);
|
||||
ClusersAlloc(p,0,1,FALSE); //Alloc #1
|
||||
br->root_cluster=ClusersAlloc(p,0,1,FALSE);
|
||||
WBlks(p,br,p->offset,1);
|
||||
@@ -156,7 +156,7 @@ U0 NativeFSFmt(U8 drv_let,Bool quick=TRUE)
|
||||
d_native->cluster=br->root_cluster;
|
||||
d_native->size=p->spc<<BLK_SIZE_BITS;
|
||||
d_native->expanded_size=d_native->size;
|
||||
d_native->datetime=GetCurTimeCDate;
|
||||
d_native->datetime=GetCurTimeDate;
|
||||
|
||||
d_native(U8 *)+=CDIR_SIZE;
|
||||
|
||||
@@ -164,10 +164,10 @@ U0 NativeFSFmt(U8 drv_let,Bool quick=TRUE)
|
||||
d_native->name[1]='.';
|
||||
d_native->attr=_ATTR_DIR|_ATTR_CONTIGUOUS;
|
||||
d_native->cluster=br->root_cluster;
|
||||
d_native->datetime=GetCurTimeCDate;
|
||||
d_native->datetime=GetCurTimeDate;
|
||||
|
||||
WBlks(p,root_dir,p->data+br->root_cluster*p->spc,p->spc);
|
||||
NativeFSPrtInit(p);
|
||||
RedSeaFSPrtInit(p);
|
||||
PrtUnlock(p);
|
||||
} catch
|
||||
PrtUnlock(p);
|
||||
@@ -175,7 +175,7 @@ U0 NativeFSFmt(U8 drv_let,Bool quick=TRUE)
|
||||
Free(root_dir);
|
||||
}
|
||||
|
||||
Bool NativeFSFileFind(CPrt *p,I64 cur_dir_cluster,U8 *name,CDirEntry *_result,I64 fuf_flags=0)
|
||||
Bool RedSeaFSFileFind(CPrt *p,I64 cur_dir_cluster,U8 *name,CDirEntry *_result,I64 fuf_flags=0)
|
||||
{ //$LK,"FUF_JUST_DIRS","MN:FUF_JUST_DIRS"$, $LK,"FUF_JUST_FILES","MN:FUF_JUST_FILES"$
|
||||
CDirEntry *buf,*buf2,*ptr;
|
||||
U8 dname[CDIR_FILENAME_LEN];
|
||||
@@ -185,8 +185,8 @@ Bool NativeFSFileFind(CPrt *p,I64 cur_dir_cluster,U8 *name,CDirEntry *_result,I6
|
||||
throw(EXCEPT_FUF,10);
|
||||
MemSet(_result,0,sizeof(CDirEntry));
|
||||
PrtChk(p);
|
||||
if (p->type!=PT_NATIVE)
|
||||
PutDefineErr("ST_NOT_NATIVE");
|
||||
if (p->type!=PT_REDSEA)
|
||||
PutDefineErr("ST_NOT_REDSEA");
|
||||
else if (!CFileNameTo(dname,name))
|
||||
PutDefineErr("ST_INVALID_FILENAME");
|
||||
else {
|
||||
@@ -229,7 +229,7 @@ exit_this:
|
||||
|
||||
|
||||
|
||||
U8 *NativeFSFileRead(CPrt *p,U8 *cur_dir,U8 *filename,I64 *_size,
|
||||
U8 *RedSeaFSFileRead(CPrt *p,U8 *cur_dir,U8 *filename,I64 *_size,
|
||||
I64 *_attr,Bool raw,CArcCompress **_ac2)
|
||||
{
|
||||
U8 *buf=NULL;
|
||||
@@ -241,20 +241,20 @@ U8 *NativeFSFileRead(CPrt *p,U8 *cur_dir,U8 *filename,I64 *_size,
|
||||
if (_size) *_size=0;
|
||||
if (_ac2) *_ac2=NULL;
|
||||
if (_attr) *_attr=0;
|
||||
if (p->type!=PT_NATIVE)
|
||||
PutDefineErr("ST_NOT_NATIVE");
|
||||
if (p->type!=PT_REDSEA)
|
||||
PutDefineErr("ST_NOT_REDSEA");
|
||||
else {
|
||||
try {
|
||||
PrtLock(p);
|
||||
cur_dir_cluster=Name2DirCluster(p,cur_dir);
|
||||
if (NativeFSFileFind(p,cur_dir_cluster,filename,&de,FUF_JUST_FILES)) {
|
||||
if (RedSeaFSFileFind(p,cur_dir_cluster,filename,&de,FUF_JUST_FILES)) {
|
||||
if (_attr) *_attr=de.attr;
|
||||
blk_cnt=(de.size+BLK_SIZE-1)>>BLK_SIZE_BITS;
|
||||
buf=MAlloc(blk_cnt<<BLK_SIZE_BITS+1);
|
||||
c=de.cluster;
|
||||
c=RClustersBlks(p,buf,c,blk_cnt);
|
||||
if (de.xsum) {
|
||||
if (de.xsum^ArcXSum(buf,de.size) !=NATIVE_XSUM)
|
||||
if (de.xsum^ArcXSum(buf,de.size) !=TEMPLEOS_XSUM)
|
||||
throw(EXCEPT_ARC_XSUM);
|
||||
}
|
||||
if (FileAttr(de.name) & _ATTR_COMPRESSED && !raw) {
|
||||
@@ -281,13 +281,13 @@ U8 *NativeFSFileRead(CPrt *p,U8 *cur_dir,U8 *filename,I64 *_size,
|
||||
return buf;
|
||||
}
|
||||
|
||||
Bool NativeFSCd(U8 *name,I64 cur_dir_cluster)
|
||||
Bool RedSeaFSCd(U8 *name,I64 cur_dir_cluster)
|
||||
{
|
||||
CDirEntry de;
|
||||
if (Fs->cur_prt->type!=PT_NATIVE)
|
||||
PutDefineErr("ST_NOT_NATIVE");
|
||||
if (Fs->cur_prt->type!=PT_REDSEA)
|
||||
PutDefineErr("ST_NOT_REDSEA");
|
||||
else {
|
||||
if (NativeFSFileFind(Fs->cur_prt,cur_dir_cluster,
|
||||
if (RedSeaFSFileFind(Fs->cur_prt,cur_dir_cluster,
|
||||
name,&de,FUF_JUST_DIRS))
|
||||
return TRUE;
|
||||
else {
|
||||
@@ -298,20 +298,20 @@ Bool NativeFSCd(U8 *name,I64 cur_dir_cluster)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
U0 NativeFSFreeClusters(CPrt *p,I64 c,I64 cnt)
|
||||
U0 RedSeaFSFreeClusters(CPrt *p,I64 c,I64 cnt)
|
||||
{
|
||||
CFreeLst *tempf;
|
||||
Bool found=FALSE,unlock,unlock_break;
|
||||
PrtChk(p);
|
||||
if (!c) return;
|
||||
if (p->type!=PT_NATIVE)
|
||||
PutDefineErr("ST_NOT_NATIVE");
|
||||
if (p->type!=PT_REDSEA)
|
||||
PutDefineErr("ST_NOT_REDSEA");
|
||||
else {
|
||||
try {
|
||||
unlock_break=BreakLock;
|
||||
unlock=PrtLock(p);
|
||||
if (!p->next_free)
|
||||
NativeFSFreeLstBuild(p);
|
||||
RedSeaFSFreeLstBuild(p);
|
||||
tempf=p->next_free;
|
||||
while (!found && tempf!=&p->next_free) {
|
||||
if (tempf->start+tempf->size==c) {
|
||||
@@ -331,7 +331,7 @@ U0 NativeFSFreeClusters(CPrt *p,I64 c,I64 cnt)
|
||||
QueIns(tempf,p->last_free);
|
||||
}
|
||||
while (cnt-->0) {
|
||||
SetNativeBuf(p,c);
|
||||
SetFSBuf(p,c);
|
||||
LBtr(p->cur_map_blk,c&(BLK_SIZE<<3-1));
|
||||
LBts(p->buffered_map_dirty_bits,0);
|
||||
c++;
|
||||
@@ -351,7 +351,7 @@ U0 NativeFSFreeClusters(CPrt *p,I64 c,I64 cnt)
|
||||
}
|
||||
}
|
||||
|
||||
I64 NativeFSAllocClusters(CPrt *p,I64 cnt)
|
||||
I64 RedSeaFSAllocClusters(CPrt *p,I64 cnt)
|
||||
{
|
||||
CFreeLst *tempf,*best_free=NULL;
|
||||
I64 i,first,best_size=MAX_I64;
|
||||
@@ -362,7 +362,7 @@ I64 NativeFSAllocClusters(CPrt *p,I64 cnt)
|
||||
unlock_break=BreakLock;
|
||||
unlock=PrtLock(p);
|
||||
if (!p->next_free)
|
||||
NativeFSFreeLstBuild(p);
|
||||
RedSeaFSFreeLstBuild(p);
|
||||
tempf=p->next_free;
|
||||
while (tempf!=&p->next_free) {
|
||||
if (tempf->size>=cnt && tempf->size<best_size) {
|
||||
@@ -377,7 +377,7 @@ I64 NativeFSAllocClusters(CPrt *p,I64 cnt)
|
||||
Dbg;
|
||||
first=best_free->start;
|
||||
for (i=0;i<cnt;i++) {
|
||||
SetNativeBuf(p,first+i);
|
||||
SetFSBuf(p,first+i);
|
||||
LBts(p->cur_map_blk,(first+i)&(BLK_SIZE<<3-1));
|
||||
LBts(p->buffered_map_dirty_bits,0);
|
||||
}
|
||||
@@ -402,7 +402,7 @@ I64 NativeFSAllocClusters(CPrt *p,I64 cnt)
|
||||
}
|
||||
|
||||
|
||||
Bool NativeFSDirNew(CPrt *p,U8 *cur_dir,CDirEntry *de,Bool free_old_chain)
|
||||
Bool RedSeaFSDirNew(CPrt *p,U8 *cur_dir,CDirEntry *de,Bool free_old_chain)
|
||||
{
|
||||
CDirEntry *buf,*buf2,*ptr,de2;
|
||||
CBootStruct *br;
|
||||
@@ -434,7 +434,7 @@ Bool NativeFSDirNew(CPrt *p,U8 *cur_dir,CDirEntry *de,Bool free_old_chain)
|
||||
else {
|
||||
buf2=CAlloc(dir_size+p->spc<<BLK_SIZE_BITS);
|
||||
MemCpy(buf2,buf,dir_size);
|
||||
NativeFSFreeClusters(p,cur_dir_cluster,
|
||||
RedSeaFSFreeClusters(p,cur_dir_cluster,
|
||||
(dir_size>>BLK_SIZE_BITS+p->spc-1)/p->spc);
|
||||
dir_size+=p->spc<<BLK_SIZE_BITS;
|
||||
c=ClusersAlloc(p,0,(dir_size>>BLK_SIZE_BITS+p->spc-1)/p->spc,TRUE);
|
||||
@@ -460,12 +460,12 @@ Bool NativeFSDirNew(CPrt *p,U8 *cur_dir,CDirEntry *de,Bool free_old_chain)
|
||||
Free(parent_dir);
|
||||
parent_dir=StrNew("/");
|
||||
}
|
||||
if (NativeFSFileFind(p,Name2DirCluster(p,parent_dir),
|
||||
if (RedSeaFSFileFind(p,Name2DirCluster(p,parent_dir),
|
||||
temp,&de2,FUF_JUST_DIRS)) {
|
||||
de2.cluster=c;
|
||||
de2.size=dir_size;
|
||||
de2.expanded_size=dir_size;
|
||||
NativeFSDirNew(p,parent_dir,&de2,FALSE);
|
||||
RedSeaFSDirNew(p,parent_dir,&de2,FALSE);
|
||||
} else
|
||||
Dbg;
|
||||
Free(temp);
|
||||
@@ -483,7 +483,7 @@ Bool NativeFSDirNew(CPrt *p,U8 *cur_dir,CDirEntry *de,Bool free_old_chain)
|
||||
} else {
|
||||
if (!StrCmp(de->name,ptr->name)) {
|
||||
if (free_old_chain)
|
||||
NativeFSFreeClusters(p,ptr->cluster,
|
||||
RedSeaFSFreeClusters(p,ptr->cluster,
|
||||
(ptr->size+p->spc<<BLK_SIZE_BITS-1)/p->spc<<BLK_SIZE_BITS);
|
||||
if (!written)
|
||||
MemCpy(&ptr->start,&de->start,CDIR_SIZE);
|
||||
@@ -514,7 +514,7 @@ Bool NativeFSDirNew(CPrt *p,U8 *cur_dir,CDirEntry *de,Bool free_old_chain)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
I64 NativeFSFilesDel(CPrt *p,U8 *cur_dir,U8 *files_find_mask,I64 fuf_flags,
|
||||
I64 RedSeaFSFilesDel(CPrt *p,U8 *cur_dir,U8 *files_find_mask,I64 fuf_flags,
|
||||
Bool del_dir,Bool print_msg)
|
||||
{
|
||||
CDirEntry *buf,*buf2,*ptr;
|
||||
@@ -550,7 +550,7 @@ I64 NativeFSFilesDel(CPrt *p,U8 *cur_dir,U8 *files_find_mask,I64 fuf_flags,
|
||||
ptr->attr|=_ATTR_DELETED;
|
||||
WBlks(p,buf(U8 *)+j<<BLK_SIZE_BITS,
|
||||
p->data+cur_dir_cluster*p->spc+j,1);
|
||||
NativeFSFreeClusters(p,ptr->cluster,
|
||||
RedSeaFSFreeClusters(p,ptr->cluster,
|
||||
(ptr->size+p->spc<<BLK_SIZE_BITS-1)/p->spc<<BLK_SIZE_BITS);
|
||||
}
|
||||
ptr(U8 *)+=CDIR_SIZE;
|
||||
@@ -571,8 +571,8 @@ I64 NativeFSFilesDel(CPrt *p,U8 *cur_dir,U8 *files_find_mask,I64 fuf_flags,
|
||||
return result;
|
||||
}
|
||||
|
||||
I64 NativeFSFileWrite(CPrt *p,U8 *cur_dir,U8 *name,U8 *buf,I64 size,
|
||||
CDate spdt,I64 attr,Bool raw,
|
||||
I64 RedSeaFSFileWrite(CPrt *p,U8 *cur_dir,U8 *name,U8 *buf,I64 size,
|
||||
CDate cdt,I64 attr,Bool raw,
|
||||
CArcCompress **_ac2)
|
||||
{
|
||||
CDirEntry de;
|
||||
@@ -582,15 +582,15 @@ I64 NativeFSFileWrite(CPrt *p,U8 *cur_dir,U8 *name,U8 *buf,I64 size,
|
||||
MemSet(&de,0,sizeof(CDirEntry));
|
||||
if (_ac2) *_ac2=NULL;
|
||||
if (size<0) size=0;
|
||||
if (!spdt)
|
||||
spdt=GetCurTimeCDate;
|
||||
if (!cdt)
|
||||
cdt=GetCurTimeDate;
|
||||
|
||||
if (p->type!=PT_NATIVE)
|
||||
PutDefineErr("ST_NOT_NATIVE");
|
||||
if (p->type!=PT_REDSEA)
|
||||
PutDefineErr("ST_NOT_REDSEA");
|
||||
else if (!CFileNameTo(de.name,name))
|
||||
PutDefineErr("ST_INVALID_FILENAME");
|
||||
else {
|
||||
NativeFSFilesDel(p,cur_dir,de.name,0,FALSE,FALSE);
|
||||
RedSeaFSFilesDel(p,cur_dir,de.name,0,FALSE,FALSE);
|
||||
attr=FileAttr(name,attr);
|
||||
attr|=_ATTR_CONTIGUOUS;
|
||||
contiguous=TRUE;
|
||||
@@ -601,17 +601,17 @@ I64 NativeFSFileWrite(CPrt *p,U8 *cur_dir,U8 *name,U8 *buf,I64 size,
|
||||
buf=ac;
|
||||
}
|
||||
de.size=size;
|
||||
de.xsum=ArcXSum(buf,size)^NATIVE_XSUM;
|
||||
de.xsum=ArcXSum(buf,size)^TEMPLEOS_XSUM;
|
||||
if (blk_cnt=(size+BLK_SIZE-1)>>BLK_SIZE_BITS)
|
||||
c=ClusersAlloc(p,0,(blk_cnt+p->spc-1)/p->spc,contiguous);
|
||||
else
|
||||
c=INVALID_CLUSTER;
|
||||
de.cluster=c;
|
||||
de.attr=attr;
|
||||
de.datetime=spdt;
|
||||
de.datetime=cdt;
|
||||
if (blk_cnt)
|
||||
WClustersBlks(p,buf,c,blk_cnt);
|
||||
NativeFSDirNew(p,cur_dir,&de,TRUE);
|
||||
RedSeaFSDirNew(p,cur_dir,&de,TRUE);
|
||||
if (_ac2)
|
||||
*_ac2=ac;
|
||||
else
|
||||
@@ -620,7 +620,7 @@ I64 NativeFSFileWrite(CPrt *p,U8 *cur_dir,U8 *name,U8 *buf,I64 size,
|
||||
return c;
|
||||
}
|
||||
|
||||
CDirEntry *NativeFSFilesFind(U8 *files_find_mask,I64 fuf_flags,CDirEntry *parent=NULL)
|
||||
CDirEntry *RedSeaFSFilesFind(U8 *files_find_mask,I64 fuf_flags,CDirEntry *parent=NULL)
|
||||
{
|
||||
CPrt *p=Fs->cur_prt;
|
||||
CDirEntry *buf,*buf2,*ptr,*result=NULL,*tempm;
|
||||
@@ -657,7 +657,7 @@ CDirEntry *NativeFSFilesFind(U8 *files_find_mask,I64 fuf_flags,CDirEntry *parent
|
||||
tempm->full_name=DirNameAbs(tempm->name);
|
||||
PrtUnlock(p);
|
||||
if (Cd(tempm->name)) {
|
||||
tempm->sub=NativeFSFilesFind(files_find_mask,fuf_flags,tempm);
|
||||
tempm->sub=RedSeaFSFilesFind(files_find_mask,fuf_flags,tempm);
|
||||
Cd("..");
|
||||
}
|
||||
PrtLock(p);
|
||||
@@ -679,7 +679,7 @@ CDirEntry *NativeFSFilesFind(U8 *files_find_mask,I64 fuf_flags,CDirEntry *parent
|
||||
return result;
|
||||
}
|
||||
|
||||
Bool NativeFSMkDir(CPrt *p,U8 *cur_dir,U8 *name)
|
||||
Bool RedSeaFSMkDir(CPrt *p,U8 *cur_dir,U8 *name)
|
||||
{
|
||||
I64 size=p->spc<<BLK_SIZE_BITS,c,
|
||||
cur_dir_cluster=Name2DirCluster(p,cur_dir);
|
||||
@@ -695,7 +695,7 @@ Bool NativeFSMkDir(CPrt *p,U8 *cur_dir,U8 *name)
|
||||
d_native->cluster=c;
|
||||
d_native->size=size;
|
||||
d_native->expanded_size=size;
|
||||
d_native->datetime=GetCurTimeCDate;
|
||||
d_native->datetime=GetCurTimeDate;
|
||||
d_native(U8 *)+=CDIR_SIZE;
|
||||
|
||||
d_native->attr=_ATTR_DIR|_ATTR_CONTIGUOUS;
|
||||
@@ -705,7 +705,7 @@ Bool NativeFSMkDir(CPrt *p,U8 *cur_dir,U8 *name)
|
||||
d_native->cluster=cur_dir_cluster;
|
||||
d_native->size=0;
|
||||
d_native->expanded_size=0;
|
||||
d_native->datetime=GetCurTimeCDate;
|
||||
d_native->datetime=GetCurTimeDate;
|
||||
WClusters(p,buf,c,1);
|
||||
Free(buf);
|
||||
if (unlock_break)
|
||||
@@ -61,7 +61,7 @@ U0 EdLite(U8 *filename,I64 num=1)
|
||||
//Light weight text editor for debugging
|
||||
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_dc_flags=sys_raw_dc_flags;
|
||||
old_dc_flags=sys_raw_dc_flags;
|
||||
CLine root,*templ,*templ1,*cur_line;
|
||||
Bool old_raw=Raw(ON),
|
||||
old_debug=InDbg(ON),
|
||||
@@ -81,12 +81,12 @@ U0 EdLite(U8 *filename,I64 num=1)
|
||||
src=buf;
|
||||
while (*src) {
|
||||
src2=src;
|
||||
while ((ch=*src++) && ch!=CH_CARRIAGE_RETURN && ch!='\n');
|
||||
while ((ch=*src++) && ch!='\r' && ch!='\n');
|
||||
src--;
|
||||
*src++=0;
|
||||
if (!ch)
|
||||
src--;
|
||||
while (ch==CH_CARRIAGE_RETURN && *src=='\n' || *src==CH_CURSOR)
|
||||
while (ch=='\r' && *src=='\n' || *src==CH_CURSOR)
|
||||
src++;
|
||||
dst=src3=src2;
|
||||
while (ch=*src3++)
|
||||
@@ -195,7 +195,7 @@ U0 EdLite(U8 *filename,I64 num=1)
|
||||
}
|
||||
break;
|
||||
case '\n':
|
||||
case CH_CARRIAGE_RETURN:
|
||||
case '\r':
|
||||
templ=MAlloc(sizeof(CLine));
|
||||
templ->line=StrNew(cur_line->line+cur_col);
|
||||
cur_line->line[cur_col]=0;
|
||||
@@ -249,7 +249,6 @@ U0 EdLite(U8 *filename,I64 num=1)
|
||||
cur_line->line=src;
|
||||
cur_col++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
} while (ch!=CH_SHIFT_ESC && ch!=CH_ESC);
|
||||
|
||||
@@ -294,7 +293,7 @@ U0 EdLite(U8 *filename,I64 num=1)
|
||||
PopFD;
|
||||
}
|
||||
|
||||
U0 EdLiteFileLine(U8 *_fl_file_line)
|
||||
U0 ToFileLine(U8 *_fl_file_line,U8 **_filename,I64 *_linenum)
|
||||
{
|
||||
U8 *st,*fl_file_line=StrNew(_fl_file_line);
|
||||
I64 linenum;
|
||||
@@ -303,8 +302,17 @@ U0 EdLiteFileLine(U8 *_fl_file_line)
|
||||
StrLastRem(fl_file_line,",",st);
|
||||
linenum=A2I(st);
|
||||
Free(st);
|
||||
EdLite(fl_file_line,linenum);
|
||||
Free(fl_file_line);
|
||||
*_filename=fl_file_line;
|
||||
*_linenum=linenum;
|
||||
}
|
||||
|
||||
U0 EdLiteFileLine(U8 *fl_file_line)
|
||||
{
|
||||
U8 *filename;
|
||||
I64 linenum;
|
||||
ToFileLine(fl_file_line,&filename,&linenum);
|
||||
EdLite(filename,linenum);
|
||||
Free(filename);
|
||||
}
|
||||
|
||||
U0 SetFix(U8 *filename,I64 line)
|
||||
|
||||
@@ -1,169 +0,0 @@
|
||||
CFifoU8 *FifoU8New(I64 size,CTask *mem_task=NULL)
|
||||
{
|
||||
CFifoU8 *f;
|
||||
if (!mem_task) mem_task=Fs;
|
||||
f=MAlloc(sizeof(CFifoU8),mem_task);
|
||||
f->buf=MAlloc(size,mem_task);
|
||||
f->mask=size-1;
|
||||
f->in_ptr=0;
|
||||
f->out_ptr=0;
|
||||
return f;
|
||||
}
|
||||
|
||||
U0 FifoU8Del(CFifoU8 *f)
|
||||
{
|
||||
Free(f->buf);
|
||||
Free(f);
|
||||
}
|
||||
|
||||
Bool FifoU8Ins(CFifoU8 *f,U8 b)
|
||||
{
|
||||
I64 new_in_ptr;
|
||||
PushFD;
|
||||
Cli;
|
||||
new_in_ptr=(f->in_ptr+1)&f->mask;
|
||||
if (new_in_ptr==f->out_ptr) {
|
||||
PopFD;
|
||||
return FALSE;
|
||||
} else {
|
||||
f->buf[f->in_ptr]=b;
|
||||
f->in_ptr=new_in_ptr;
|
||||
PopFD;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
Bool FifoU8Rem(CFifoU8 *f,U8 *_b)
|
||||
{
|
||||
PushFD;
|
||||
Cli;
|
||||
if (f->in_ptr==f->out_ptr) {
|
||||
PopFD;
|
||||
return FALSE;
|
||||
} else {
|
||||
*_b=f->buf[f->out_ptr];
|
||||
f->out_ptr=(f->out_ptr+1)&f->mask;
|
||||
PopFD;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
Bool FifoU8Peek(CFifoU8 *f,U8 *_b)
|
||||
{
|
||||
PushFD;
|
||||
Cli;
|
||||
if (f->in_ptr==f->out_ptr) {
|
||||
PopFD;
|
||||
return FALSE;
|
||||
} else {
|
||||
*_b=f->buf[f->out_ptr];
|
||||
PopFD;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
U0 FifoU8Flush(CFifoU8 *f)
|
||||
{
|
||||
PushFD;
|
||||
Cli;
|
||||
f->out_ptr=f->in_ptr;
|
||||
PopFD;
|
||||
}
|
||||
|
||||
I64 FifoU8Cnt(CFifoU8 *f)
|
||||
{
|
||||
I64 result;
|
||||
PushFD;
|
||||
Cli;
|
||||
if (f->out_ptr>f->in_ptr)
|
||||
result=f->mask+1-(f->out_ptr-f->in_ptr);
|
||||
else
|
||||
result=f->in_ptr-f->out_ptr;
|
||||
PopFD;
|
||||
return result;
|
||||
}
|
||||
|
||||
CFifoI64 *FifoI64New(I64 size,CTask *mem_task=NULL)
|
||||
{
|
||||
CFifoI64 *f;
|
||||
if (!mem_task) mem_task=Fs;
|
||||
f=MAlloc(sizeof(CFifoI64),mem_task);
|
||||
f->buf=MAlloc(size*sizeof(I64),mem_task);
|
||||
f->mask=size-1;
|
||||
f->in_ptr=0;
|
||||
f->out_ptr=0;
|
||||
return f;
|
||||
}
|
||||
|
||||
U0 FifoI64Del(CFifoI64 *f)
|
||||
{
|
||||
Free(f->buf);
|
||||
Free(f);
|
||||
}
|
||||
|
||||
Bool FifoI64Ins(CFifoI64 *f,I64 q)
|
||||
{
|
||||
I64 new_in_ptr;
|
||||
PushFD;
|
||||
Cli;
|
||||
new_in_ptr=(f->in_ptr+1)&f->mask;
|
||||
if (new_in_ptr==f->out_ptr) {
|
||||
PopFD;
|
||||
return FALSE;
|
||||
} else {
|
||||
f->buf[f->in_ptr]=q;
|
||||
f->in_ptr=new_in_ptr;
|
||||
PopFD;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
Bool FifoI64Rem(CFifoI64 *f,I64 *_q)
|
||||
{
|
||||
PushFD;
|
||||
Cli;
|
||||
if (f->in_ptr==f->out_ptr) {
|
||||
PopFD;
|
||||
return FALSE;
|
||||
} else {
|
||||
*_q=f->buf[f->out_ptr];
|
||||
f->out_ptr=(f->out_ptr+1)&f->mask;
|
||||
PopFD;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
Bool FifoI64Peek(CFifoI64 *f,I64 *_q)
|
||||
{
|
||||
PushFD;
|
||||
Cli;
|
||||
if (f->in_ptr==f->out_ptr) {
|
||||
PopFD;
|
||||
return FALSE;
|
||||
} else {
|
||||
*_q=f->buf[f->out_ptr];
|
||||
PopFD;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
U0 FifoI64Flush(CFifoI64 *f)
|
||||
{
|
||||
PushFD;
|
||||
Cli;
|
||||
f->out_ptr=f->in_ptr;
|
||||
PopFD;
|
||||
}
|
||||
|
||||
I64 FifoI64Cnt(CFifoI64 *f)
|
||||
{
|
||||
I64 result;
|
||||
PushFD;
|
||||
Cli;
|
||||
if (f->out_ptr>f->in_ptr)
|
||||
result=f->mask+1-(f->out_ptr-f->in_ptr);
|
||||
else
|
||||
result=f->in_ptr-f->out_ptr;
|
||||
PopFD;
|
||||
return result;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
//See $LK-A,"::/TempleOS/Doc/Acknowledgements.TXT"$ (1).
|
||||
//See $LK-A,"::/TempleOS/Doc/Acknowledgements.TXT"$.
|
||||
|
||||
U8 sys_font_8x8[256*8]= {
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
|
||||
+10
-12
@@ -299,12 +299,12 @@ _HASH_ADD::
|
||||
MOV U64 CHash.next[RCX],RBX
|
||||
MOV U64 [RAX],RCX
|
||||
|
||||
//Queins
|
||||
//QueIns RCX
|
||||
MOV RBX,U64 CHashTable.last_added[RDI]
|
||||
MOV U64 CHash.next_added[RCX],RDI
|
||||
MOV U64 CHash.last_added[RCX],RBX
|
||||
MOV U64 CHash.next_added[RBX],RCX
|
||||
MOV U64 CHashTable.last_added[RDI],RCX
|
||||
MOV U64 CHash.next_added[RCX],RDI
|
||||
|
||||
POPFD
|
||||
POP RDI
|
||||
@@ -324,12 +324,12 @@ _HASH_ADD_AFTER::
|
||||
MOV U64 CHash.next[RCX],RBX
|
||||
MOV U64 [RAX],RCX
|
||||
|
||||
//QueIns
|
||||
//QueIns RCX
|
||||
MOV RBX,U64 CHashTable.last_added[RDI]
|
||||
MOV U64 CHash.next_added[RCX],RDI
|
||||
MOV U64 CHash.last_added[RCX],RBX
|
||||
MOV U64 CHash.next_added[RBX],RCX
|
||||
MOV U64 CHashTable.last_added[RDI],RCX
|
||||
MOV U64 CHash.next_added[RCX],RDI
|
||||
|
||||
POPFD
|
||||
POP RDI
|
||||
@@ -357,7 +357,7 @@ _HASH_REPLACE::
|
||||
MOV RCX,U64 SF_ARG1[RBP]
|
||||
JZ @@05 //Z set by find
|
||||
|
||||
//QueRem/QueIns
|
||||
//QueRem RAX,QueIns RCX
|
||||
MOV RBX,U64 CHash.next_added[RAX]
|
||||
MOV U64 CHash.next_added[RCX],RBX
|
||||
MOV U64 CHash.last_added[RBX],RCX
|
||||
@@ -368,12 +368,12 @@ _HASH_REPLACE::
|
||||
MOV RBX,U64 CHash.next[RAX]
|
||||
JMP @@10
|
||||
|
||||
//QueIns
|
||||
//QueIns RCX
|
||||
@@05: MOV RBX,U64 CHashTable.last_added[RDI]
|
||||
MOV U64 CHash.next_added[RCX],RDI
|
||||
MOV U64 CHash.last_added[RCX],RBX
|
||||
MOV U64 CHash.next_added[RBX],RCX
|
||||
MOV U64 CHashTable.last_added[RDI],RCX
|
||||
MOV U64 CHash.next_added[RCX],RDI
|
||||
|
||||
MOV RBX,RAX
|
||||
|
||||
@@ -418,7 +418,7 @@ _HASH_REM_DEL::
|
||||
MOV RBX,U64 CHash.next[RAX]
|
||||
MOV U64 [RDX],RBX
|
||||
|
||||
//QueRem
|
||||
//QueRem RAX
|
||||
MOV RBX,U64 CHash.next_added[RAX]
|
||||
MOV RDX,U64 CHash.last_added[RAX]
|
||||
MOV U64 CHash.next_added[RDX],RBX
|
||||
@@ -486,10 +486,8 @@ U0 HashDel(CHashSrcSym *temph)
|
||||
Free(temph->index);
|
||||
Free(temph->import_name);
|
||||
LinkedLstDel(temph->ie_lst);
|
||||
if (temph->type & (HTT_FUN | HTT_EXPORT_SYS_SYM)) {
|
||||
if (temph->type & (HTT_FUN | HTT_EXPORT_SYS_SYM))
|
||||
Free(temph->debug);
|
||||
Free(temph->indent);
|
||||
}
|
||||
if (temph->type & (HTT_FUN | HTT_CLASS))
|
||||
//Assumes code not on heap, so doesn't Free.
|
||||
//$LK,"MemberLstDel","MN:MemberLstDel"$() is an import to the Kernel module
|
||||
@@ -779,7 +777,7 @@ U8 *Load(U8 *filename,I64 ld_flags=0,CBinFile *bfh_addr=INVALID_PTR)
|
||||
lo_skip:
|
||||
module_base=bfh_addr(U8 *)+sizeof(CBinFile);
|
||||
|
||||
if (ArcXSum(bfh_addr,bfh_addr->file_size)!=NATIVE_XSUM)
|
||||
if (ArcXSum(bfh_addr,bfh_addr->file_size)!=TEMPLEOS_XSUM)
|
||||
throw(EXCEPT_ARC_XSUM);
|
||||
|
||||
absname=FileNameAbs(fbuf);
|
||||
|
||||
@@ -183,8 +183,7 @@ U0 IntInit1()
|
||||
}
|
||||
ptr=temp_ptr;
|
||||
*ptr(U16 *)++=256*16-1;
|
||||
*ptr(U32 *)++=sys_idt(I64).u32[0];
|
||||
*ptr(U32 *)++=sys_idt(I64).u32[1];
|
||||
*ptr(I64 *)++=sys_idt;
|
||||
*ptr(U16 *)++=0;
|
||||
SetRAX(temp_ptr);
|
||||
asm { LIDT U64 [RAX] }
|
||||
|
||||
+19
-11
@@ -24,19 +24,23 @@ class CKernelCfg
|
||||
U8 *acct_name;
|
||||
U8 *dsk_cache_size_exp;
|
||||
CDoc *add_dev;
|
||||
|
||||
Bool opts[CFG_NUM_OPTIONS];
|
||||
U8 mem_init_val,heap_init_val,var_init_val,
|
||||
dft_drv,auto_mount_ide_hd_let,auto_mount_ide_cd_let;
|
||||
sys_acct_drv,auto_mount_ide_hd_let,auto_mount_ide_cd_let;
|
||||
Bool cdrom_ports_pmt;
|
||||
};
|
||||
|
||||
CDoc *KernelCfgAddDev(CKernelCfg *c)
|
||||
{
|
||||
I64 num_hints,first_prt_num,type,unit,cnt=0;
|
||||
U8 blks_buf[256],base0_buf[128],base1_buf[128],drv_let;
|
||||
U8 blks_buf[256],addr_buf[256],base0_buf[128],base1_buf[128];
|
||||
CATARep *root=NULL,*tempha;
|
||||
CDoc *doc=DocNew;
|
||||
Bool make_free;
|
||||
|
||||
//See $LK,"InsBootDstDrv","FF:::/TempleOS/Adam/Boot/InsBoot.CPP,InsBootDstDrv"$
|
||||
if (!(c->sys_acct_drv=NamedFramePtr("InsBootDstDrv")))
|
||||
c->sys_acct_drv=Fs->cur_prt->drv_let;
|
||||
|
||||
PutDefine("ST_MOUNT_INTRO");
|
||||
do {
|
||||
@@ -50,11 +54,13 @@ CDoc *KernelCfgAddDev(CKernelCfg *c)
|
||||
|
||||
unit=0;
|
||||
if (type==BDT_RAM) {
|
||||
PutDefine("ST_MOUNT_ADDR");
|
||||
GetS(addr_buf,256);
|
||||
PutDefine("ST_MOUNT_BLKS");
|
||||
GetS(blks_buf,256);
|
||||
} else if (type==BDT_ATA ||
|
||||
type==BDT_ATAPI) {
|
||||
num_hints=ATARep(TRUE,,&root);
|
||||
num_hints=ATARep(,,&root);
|
||||
if (type==BDT_ATAPI) {
|
||||
PutDefine("ST_MOUNT_BOOTED_CDROM");
|
||||
if (num_hints)
|
||||
@@ -94,27 +100,28 @@ CDoc *KernelCfgAddDev(CKernelCfg *c)
|
||||
if (BDT_NULL<type<BDT_NUM_TYPES && 0<=unit<=1) {
|
||||
DocPrintF(doc,"bdev=BlkDevNextFree(%d,%d);"
|
||||
"bdev->unit=%d;",first_prt_num+'A',type,unit);
|
||||
if (type==BDT_RAM)
|
||||
if (type==BDT_RAM) {
|
||||
if (!*addr_buf) StrCpy(addr_buf,"0");
|
||||
DocPrintF(doc,"bdev->RAM_dsk=%s;",addr_buf);
|
||||
DocPrintF(doc,"bdev->max_blk=(%s)-1;",blks_buf);
|
||||
}
|
||||
make_free=FALSE;
|
||||
if (type==BDT_ATA || type==BDT_ATAPI) {
|
||||
if (type==BDT_ATAPI && !*base0_buf) {
|
||||
c->cdrom_ports_pmt=TRUE;
|
||||
DocPrintF(doc,"boot_drv_pmt=PmtBaseUnit(bdev);");
|
||||
if (first_prt_num+'A'==c->sys_acct_drv)
|
||||
make_free=TRUE;
|
||||
} else
|
||||
DocPrintF(doc,"bdev->base0=%s;bdev->base1=%s;",
|
||||
base0_buf,base1_buf);
|
||||
}
|
||||
DocPrintF(doc,"BlkDevAdd(bdev,FALSE,FALSE);");
|
||||
DocPrintF(doc,"BlkDevAdd(bdev,FALSE,%d);",make_free);
|
||||
cnt++;
|
||||
} else
|
||||
PutDefine("ST_FAILED");
|
||||
}
|
||||
} while (!cnt || 0<=first_prt_num<NUM_PRTS);
|
||||
|
||||
//See $LK,"InsBootDstDrv","FF:::/TempleOS/Adam/Boot/InsBoot.CPP,InsBootDstDrv"$
|
||||
if (!(drv_let=NamedFramePtr("InsBootDstDrv")))
|
||||
drv_let=Fs->cur_prt->drv_let;
|
||||
c->dft_drv=drv_let;
|
||||
return doc;
|
||||
}
|
||||
|
||||
@@ -191,6 +198,7 @@ U0 KernelCfgOptions(CKernelCfg *c)
|
||||
c->auto_mount_ide_hd_let=0;
|
||||
c->auto_mount_ide_cd_let=0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} while (*st);
|
||||
|
||||
@@ -44,9 +44,9 @@ U0 SysGlblsInit()
|
||||
KeyDevAdd(&AKDRawDisplayPutKey,&AKDRawDisplayPutS,0x60000000,FALSE);
|
||||
#exe {
|
||||
if (*kernel_cfg->acct_name)
|
||||
StreamPrintF("sys_acct=StrNew(\"%C:/TempleOS/Accts/%s\");",kernel_cfg->dft_drv,kernel_cfg->acct_name);
|
||||
StreamPrintF("sys_acct=StrNew(\"%C:/TempleOS/Accts/%s\");",kernel_cfg->sys_acct_drv,kernel_cfg->acct_name);
|
||||
else
|
||||
StreamPrintF("sys_acct=StrNew(\"%C:/TempleOS/Accts\");",kernel_cfg->dft_drv);
|
||||
StreamPrintF("sys_acct=StrNew(\"%C:/TempleOS/Accts\");",kernel_cfg->sys_acct_drv);
|
||||
StreamPutS("#exe{OptOff(OPTf_WARN_PAREN);}");
|
||||
StreamPrintF("DskCacheInit(%s);",kernel_cfg->dsk_cache_size_exp);
|
||||
StreamPutS("#exe{OptOn(OPTf_WARN_PAREN);}");
|
||||
@@ -55,6 +55,10 @@ U0 SysGlblsInit()
|
||||
for (i=-308;i<309;i++)
|
||||
pow10_I64[i+309]=Pow10(i);
|
||||
|
||||
QueInit(&snd_record_root);
|
||||
snd_record_root.freq=0;
|
||||
snd_record_root.time_stamp=tT;
|
||||
|
||||
//$AN,"Independent Heap Ctrl Example","Independent Heap Ctrl Example"$
|
||||
i=1; //Rqst 1 blk, we might get more.
|
||||
m=MemBlksUncachedAlloc(&i,sys_code_bp);
|
||||
@@ -150,7 +154,7 @@ U0 Reboot()
|
||||
SysHlt;
|
||||
}
|
||||
|
||||
U0 Kernel()
|
||||
U0 KernelMain()
|
||||
{ //Continued from $LK,"Kernel","FF:::/TempleOS/Kernel/KStart.CPP,I32 &Kernel"$
|
||||
adam_task=Fs;
|
||||
HeapsInit;
|
||||
@@ -166,8 +170,7 @@ U0 Kernel()
|
||||
SysGrInit;
|
||||
StrCpy(Fs->task_name,"Adam Task CPU#0");
|
||||
StrCpy(Fs->task_title,Fs->task_name);
|
||||
Fs->text_attr=WHITE<<4+PURPLE;
|
||||
Fs->border_attr=WHITE<<4+LTPURPLE;
|
||||
Fs->title_src=TTS_TASK_NAME;
|
||||
Fs->win_right=text_cols-2;
|
||||
Fs->win_top++;
|
||||
TaskDerivedValsUpdate;
|
||||
@@ -210,7 +213,7 @@ U0 Kernel()
|
||||
else if (mp_cnt<2)
|
||||
Spawn(&MouseDriverInstall);
|
||||
else
|
||||
MPSpawn(&MouseDriverInstall);
|
||||
Spawn(&MouseDriverInstall,,,1);
|
||||
|
||||
"BlkDevsInitAll\n";
|
||||
BlkDevsInitAll;
|
||||
@@ -235,13 +238,15 @@ U0 Kernel()
|
||||
try
|
||||
ExeFile("Adam1"); //Continues $LK,"/TempleOS/Kernel/Adam1.CPP","FL:/TempleOS/Kernel/Adam1.CPP,1"$
|
||||
catch {
|
||||
Raw(ON);
|
||||
CatchAll;
|
||||
Dbg;
|
||||
}
|
||||
|
||||
LBts(&sys_run_level,RLf_ADAM_SERVER);
|
||||
ServantTaskCont; //Never to return
|
||||
SrvTaskCont; //Never to return
|
||||
}
|
||||
|
||||
asm { ALIGN 16,OC_NOP
|
||||
SYS_KERNEL_END::}
|
||||
SYS_KERNEL_END::
|
||||
}
|
||||
+22
-13
@@ -5,7 +5,8 @@ before import is resolved, you can use
|
||||
var and check it before calling.
|
||||
*/
|
||||
import U0 MemberLstDel(CHashClass *tempc);
|
||||
import I64 ExePutS(U8 *buf,U8 *filename=NULL,Bool just_load=FALSE);
|
||||
import I64 ExePutS(U8 *buf,U8 *filename=NULL,
|
||||
Bool just_load=FALSE,CLexHashTableContext *htc=NULL);
|
||||
import I64 ExeFile(U8 *name,Bool just_load=FALSE);
|
||||
import U0 DisplaySpecialKeys(I64 sc);
|
||||
import Bool DocUnlock(CDoc *doc);
|
||||
@@ -34,6 +35,9 @@ extern U0 Dm(U8 *buf,I64 cnt=0x80);
|
||||
extern U0 MPInt(I64 num,I64 cpu_num=1);
|
||||
extern U0 XTalk(CTask *task,U8 *fmt,...);
|
||||
extern Bool Suspend(CTask *task=NULL,Bool state=TRUE);
|
||||
extern U0 SrvCmdDel(CSrvCmd *tempc);
|
||||
extern U0 SrvCmdQueDel(CSrvCmd *root);
|
||||
extern U0 SrvCtrlInit(CSrvCtrl *ctrl);
|
||||
extern Bool TaskValidate(CTask *task);
|
||||
|
||||
extern U8 *FileExtRem(U8 *src,U8 *dst=NULL);
|
||||
@@ -42,23 +46,23 @@ extern Bool FileFind(U8 *filename,CDirEntry *rde=NULL,I64 fuf_flags=0);
|
||||
extern Bool ISOPrtInit(CPrt *p,I64 blk);
|
||||
extern Bool ISO1FileFind(CPrt *p,I64 cur_dir_cluster,U8 *name,CDirEntry *_result,I64 fuf_flags=0);
|
||||
extern CDirEntry *ISO1FilesFind(U8 *files_find_mask,I64 fuf_flags,CDirEntry *parent=NULL);
|
||||
extern U0 NativeFSFreeFreeLst(CPrt *p);
|
||||
extern U0 NativeFSPrtInit(CPrt *p);
|
||||
extern U0 RedSeaFSFreeFreeLst(CPrt *p);
|
||||
extern U0 RedSeaFSPrtInit(CPrt *p);
|
||||
extern U0 FAT32PrtInit(CPrt *p);
|
||||
extern Bool NativeFSDrvValidate(U8 drv_let);
|
||||
extern U0 NativeFSFmt(U8 drv_let,Bool quick=TRUE);
|
||||
extern Bool NativeFSFileFind(CPrt *p,I64 cur_dir_cluster,U8 *name,CDirEntry *_result,I64 fuf_flags=0);
|
||||
extern Bool RedSeaFSDrvValidate(U8 drv_let);
|
||||
extern U0 RedSeaFSFmt(U8 drv_let,Bool quick=TRUE);
|
||||
extern Bool RedSeaFSFileFind(CPrt *p,I64 cur_dir_cluster,U8 *name,CDirEntry *_result,I64 fuf_flags=0);
|
||||
extern Bool FAT32FileFind(CPrt *p,I64 cur_dir_cluster,U8 *name,CDirEntry *_result,I64 fuf_flags=0);
|
||||
extern U8 *FileRead(U8 *filename,I64 *_size=NULL,I64 *_attr=NULL,Bool raw=FALSE);
|
||||
extern I64 NativeFSAllocClusters(CPrt *p,I64 cnt);
|
||||
extern I64 RedSeaFSAllocClusters(CPrt *p,I64 cnt);
|
||||
extern I64 FAT32AllocClusters(CPrt *p,I64 c,I64 cnt);
|
||||
extern I64 FAT32AllocContiguousClusters(CPrt *p,I64 cnt);
|
||||
extern Bool NativeFSDirNew(CPrt *p,U8 *cur_dir,CDirEntry *de,Bool free_old_chain);
|
||||
extern Bool RedSeaFSDirNew(CPrt *p,U8 *cur_dir,CDirEntry *de,Bool free_old_chain);
|
||||
extern Bool FAT32DirNew(CPrt *p,U8 *cur_dir,CDirEntry *de,Bool free_old_chain);
|
||||
extern CDirEntry *NativeFSFilesFind (U8 *files_find_mask,I64 fuf_flags,CDirEntry *parent=NULL);
|
||||
extern CDirEntry *RedSeaFSFilesFind (U8 *files_find_mask,I64 fuf_flags,CDirEntry *parent=NULL);
|
||||
extern CDirEntry *FAT32FilesFind(U8 *files_find_mask,I64 fuf_flags,CDirEntry *parent=NULL,I64 *_dir_size=NULL);
|
||||
extern I64 FileWrite(U8 *filename,U8 *fbuf,
|
||||
I64 size,CDate spdt=0,I64 attr=0,Bool raw=FALSE);
|
||||
I64 size,CDate cdt=0,I64 attr=0,Bool raw=FALSE);
|
||||
|
||||
extern U0 Exit();
|
||||
extern U0 AdamLog(U8 *fmt,...);
|
||||
@@ -66,16 +70,21 @@ extern U0 Dbg(U8 *msg=NULL,I64 msg_num=0);
|
||||
extern Bool BptS(U8 *add,CTask *task=NULL,Bool live=TRUE);
|
||||
extern U0 DbgHelp();
|
||||
extern U8 *Caller(I64 num=1);
|
||||
extern CTask *SpawnQue(U0 (*fp_add)(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 CTask *SpawnUser(U8 *fmt=NULL,...);
|
||||
extern U0 TaskRstAwaitingMsg(CTask *task=NULL);
|
||||
extern CTaskCmd *QueMsg(CTask *_servant,CTask *master,
|
||||
extern CSrvCmd *TaskMsgQue(CTask *_srv,CTask *master,
|
||||
I64 code,I64 p1,I64 p2,I64 flags);
|
||||
extern U0 TaskWait(CTask *task=NULL);
|
||||
extern U0 TaskInitExt(Bool from_dbg=FALSE);
|
||||
extern I64 ServantCmdsHandler(CTask *task=NULL);
|
||||
extern I64 SrvCmdsHandler(CTask *task=NULL);
|
||||
extern U0 PrintF(U8 *fmt,...);
|
||||
extern U0 PutS(U8 *st);
|
||||
extern U0 PutChar(I64 ch);
|
||||
extern U0 PutChar(U64 ch);
|
||||
extern U0 PutDefine(U8 *name);
|
||||
extern U0 NewLine(I64 cnt=1);
|
||||
extern I64 GetChar(I64 *scancode=NULL,Bool echo=TRUE,Bool raw_cursor=FALSE);
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
U8 sys_temp_filename[136];
|
||||
CTaskCmd sys_macro_root;
|
||||
CSrvCmd sys_macro_root;
|
||||
CKeyDev sys_put_key_root;
|
||||
CTask *sys_macro_util_task=NULL,
|
||||
*sys_dbg_focus_task=NULL;
|
||||
U8 *sys_dbg_msg=NULL;
|
||||
I64 sys_dbg_msg_num=0;
|
||||
|
||||
CMPCmdCtrl *mp_ctrl=NULL;
|
||||
CMPCrash *mp_crash=NULL;
|
||||
U8 mp_apic_ids[MP_MAX_PROCESSORS];
|
||||
I64 *sys_idt=NULL;
|
||||
@@ -27,7 +26,7 @@ U8 *gr_font;
|
||||
U8 *sys_fix_file_line=NULL;
|
||||
|
||||
CTask *sys_winmgr_task=NULL,
|
||||
*sys_task_being_screen_updated=NULL;
|
||||
*sys_task_being_screen_updated=NULL;
|
||||
I64 sys_rnd_seed;
|
||||
CDoc *sys_clipboard_doc;
|
||||
U8 *sys_dft_iso_name;
|
||||
@@ -40,10 +39,10 @@ I64 sys_auto_mount_ide_cnt=0;
|
||||
kernel_cfg->auto_mount_ide_hd_let='C';
|
||||
if (!kernel_cfg->auto_mount_ide_cd_let)
|
||||
kernel_cfg->auto_mount_ide_cd_let='T';
|
||||
StreamPrintF("U8 dft_drv=%d,sys_first_hd_drv_let=%d,sys_first_cd_drv_let=%d;",
|
||||
ToUpper(kernel_cfg->dft_drv),kernel_cfg->auto_mount_ide_hd_let,kernel_cfg->auto_mount_ide_cd_let);
|
||||
StreamPrintF("U8 sys_first_hd_drv_let=%d,sys_first_cd_drv_let=%d;",
|
||||
kernel_cfg->auto_mount_ide_hd_let,kernel_cfg->auto_mount_ide_cd_let);
|
||||
}
|
||||
Bool boot_drv_pmt=FALSE;
|
||||
Bool boot_drv_pmt=FALSE,cdrom_boot_is_good=TRUE;
|
||||
CPrt *drv_to_prt[32];
|
||||
U8 *sys_acct;
|
||||
U8 *reverse_bits_table,*set_bits_table;
|
||||
@@ -70,9 +69,7 @@ CMemRange sys_mem32_dev_root;
|
||||
U8 *sys_mem64_dev_ptr=MAPPED_MEM_SPACE;
|
||||
|
||||
F64 snd_freq=0;
|
||||
I64 snd_dev=SD_PC_SPEAKER;
|
||||
Bool snd_record=FALSE;
|
||||
F64 snd_vol=0.1,snd_reverb_intensity=0.2,snd_reverb_delay=0.3;
|
||||
|
||||
F64 *pow10_I64;
|
||||
|
||||
@@ -124,14 +121,12 @@ U32 key_down_bitmap[8];
|
||||
//BitTest, $LK,"Bt","MN:Bt"$(), with an unmerged scan code.
|
||||
U32 key_down_bitmap2[8];
|
||||
|
||||
U0 (*fp_snd)(F64 freq,I64 waveform,F64 amp)=NULL;
|
||||
U0 (*fp_snd_record)(F64 freq,I64 waveform,F64 amp)=NULL;
|
||||
U0 (*fp_snd_fill_buf)(SND_OUT_CONTAINER *buf,I64 buf_num)=NULL;
|
||||
U0 (*fp_snd_copy_buf)(SND_IN_CONTAINER *buf,I64 buf_num)=NULL;
|
||||
CSndData snd_record_root;
|
||||
|
||||
U8 *(*fp_mgets)(I64 flags=0)=NULL;
|
||||
U0 (*fp_prs_stream_blk)(CLex *lx)=NULL;
|
||||
U0 (*fp_update_ctrls)(CTask *task)=NULL;
|
||||
CDoc *(*fp_doc_cur)(CTask *task=NULL)=NULL;
|
||||
CDoc *(*fp_doc_put)(CTask *task=NULL)=NULL;
|
||||
U0 (*fp_set_std_palette)()=NULL;
|
||||
|
||||
CPSectCache *psect_cache;
|
||||
|
||||
+11
-10
@@ -7,7 +7,7 @@ It continues here: $LK,"Kernel","FF:::/TempleOS/Kernel/KEnd.CPP,U0 Kernel"$.
|
||||
|
||||
The boot loader jumps here, in real-mode (16-bit).
|
||||
It actually jumps to the $LK,"CBinFile","MN:CBinFile"$ which is placed
|
||||
just before this $LK,"generated by the compiler","FF:::/TempleOS/Compiler/CmpMain.CPP,NATIVE_XSUM"$.
|
||||
just before this $LK,"generated by the compiler","FF:::/TempleOS/Compiler/CmpMain.CPP,TEMPLEOS_XSUM"$.
|
||||
The header begins with a short jmp to
|
||||
the start of this file's code which begins
|
||||
with the following small jump past some data.
|
||||
@@ -16,9 +16,9 @@ This file is first in the Kernel image
|
||||
because it is #included first. $LK,"Kernel.PRJ","FF:::/TempleOS/Kernel/Kernel.PRJ,KStart:1"$
|
||||
*/
|
||||
USE16
|
||||
SYS_TEMPLEOS_START1::
|
||||
SYS_KERNEL_START1::
|
||||
//This must match $LK,"CKernel","MN:CKernel"$.
|
||||
JMP U16 SYS_TEMPLEOS_START2
|
||||
JMP U16 SYS_KERNEL_START2
|
||||
|
||||
// ************************************
|
||||
// ASM Global vars required for 16-bit start-up
|
||||
@@ -26,7 +26,7 @@ SYS_TEMPLEOS_START1::
|
||||
ALIGN 4,OC_NOP
|
||||
SYS_BOOT_BASE:: DU32 0; //Fixed offset from start used by reboot
|
||||
SYS_BOOT_PATCH_TABLE_BASE:: DU32 0;
|
||||
#exe {StreamPrintF("SYS_COMPILE_TIME:: DU64 0x%X;",GetCurTimeCDate);}
|
||||
#exe {StreamPrintF("SYS_COMPILE_TIME:: DU64 0x%X;",GetCurTimeDate);}
|
||||
|
||||
//See $LK,"BootCdProbe","MN:BootCdProbe"$
|
||||
#assert SYS_COMPILE_TIME+8+16<CD_BLK_SIZE
|
||||
@@ -52,7 +52,7 @@ GDT_CPU_TRS_RING3: DU8 MP_MAX_PROCESSORS*16 DUP(0);;
|
||||
|
||||
SYS_BIOS_GR_MODE:: DU16 0;
|
||||
SYS_PCI_BUSSES:: DU16 0;
|
||||
#assert $$-SYS_TEMPLEOS_START1==sizeof(CKernel)-sizeof(CBinFile)
|
||||
#assert $$-SYS_KERNEL_START1==sizeof(CKernel)-sizeof(CBinFile)
|
||||
|
||||
ALIGN 8,OC_NOP
|
||||
SYS_ADAM_TASK:: DU8 sizeof(CTask) DUP(0);
|
||||
@@ -62,7 +62,7 @@ SYS_RUN_LEVEL:: DU32 0;
|
||||
|
||||
// ************************************
|
||||
//EBX is SYS_BOOT_CODE (val passed from boot blk)
|
||||
SYS_TEMPLEOS_START2::
|
||||
SYS_KERNEL_START2::
|
||||
MOV AX,(BOOT_RAM_LIMIT-BOOT_STK_SIZE)/16
|
||||
MOV SS,AX
|
||||
MOV SP,BOOT_STK_SIZE
|
||||
@@ -83,9 +83,9 @@ GET_IP:
|
||||
MOV AX,CS
|
||||
ADD AX,BX
|
||||
PUSH AX
|
||||
PUSH U16 SYS_TEMPLEOS_START3
|
||||
PUSH U16 SYS_KERNEL_START3
|
||||
RETF
|
||||
SYS_TEMPLEOS_START3::
|
||||
SYS_KERNEL_START3::
|
||||
//XSUM Kernel
|
||||
MOV AX,CS
|
||||
DEC AX
|
||||
@@ -94,7 +94,7 @@ SYS_TEMPLEOS_START3::
|
||||
XOR ESI,ESI
|
||||
MOV ECX,U32 CBinFile.file_size[ESI]
|
||||
SHR ECX,4
|
||||
MOV EBX,NATIVE_XSUM
|
||||
MOV EBX,TEMPLEOS_XSUM
|
||||
@@05: LODSD
|
||||
XOR EBX,EAX
|
||||
LODSD
|
||||
@@ -289,6 +289,7 @@ USE32
|
||||
ALIGN 8,OC_NOP
|
||||
SYS_HEAP_BASE:: DU64 0x100000+0x1000*(NUM_PML1+NUM_PML2+NUM_PML3+NUM_PML4);
|
||||
SYS_HEAP_LIMIT:: DU64 0;
|
||||
SYS_KERNEL_END_PTR:: DU64 SYS_KERNEL_END;
|
||||
|
||||
#exe {
|
||||
StreamPrintF(
|
||||
@@ -457,7 +458,7 @@ USE64
|
||||
CALL SET_FS_BASE
|
||||
MOV RSP,U64 CTask.rsp[RAX]
|
||||
|
||||
JMP I32 &Kernel
|
||||
JMP I32 &KernelMain
|
||||
|
||||
// ************************************
|
||||
USE32
|
||||
|
||||
@@ -28,7 +28,7 @@ U0 KbdCmdSend(I64 port, U8 val)
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw (EXCEPT_LOCAL);
|
||||
throw(EXCEPT_LOCAL);
|
||||
}
|
||||
|
||||
I64 KbdCmdRead()
|
||||
@@ -37,7 +37,7 @@ I64 KbdCmdRead()
|
||||
while (tS<timeout)
|
||||
if (InU8(KBD_CTRL)&1)
|
||||
return InU8(KBD_PORT);
|
||||
throw (EXCEPT_LOCAL);
|
||||
throw(EXCEPT_LOCAL);
|
||||
}
|
||||
|
||||
U0 KbdCmdFlush()
|
||||
@@ -77,7 +77,7 @@ U0 KbdMouseCmdAck(U8 val)
|
||||
}
|
||||
} while (ack!=0xFA && --timeout);
|
||||
if (!timeout)
|
||||
throw (EXCEPT_LOCAL);
|
||||
throw(EXCEPT_LOCAL);
|
||||
}
|
||||
|
||||
U0 SetTypeMatic(U8 delay)
|
||||
@@ -163,7 +163,7 @@ U8 scan_code_map[0x100]={
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,SC_CARRIAGE_RETURN,SC_CTRL,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,SC_ENTER,SC_CTRL,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0x35,0,0,SC_ALT,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,SC_HOME,SC_CURSOR_UP,SC_PAGE_UP,0,SC_CURSOR_LEFT,0,SC_CURSOR_RIGHT,0,SC_END,
|
||||
@@ -184,7 +184,7 @@ U8 num_lock_map[0x100]={
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,SC_CARRIAGE_RETURN,SC_CTRL,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,SC_ENTER,SC_CTRL,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0x35,0,0,SC_ALT,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,SC_HOME,SC_CURSOR_UP,SC_PAGE_UP,0,SC_CURSOR_LEFT,0,SC_CURSOR_RIGHT,0,SC_END,
|
||||
@@ -251,12 +251,12 @@ U8 *ScanCode2KeyName(I64 sc)
|
||||
StrCat(buf,"ALT ");
|
||||
if (sc&SCF_SHIFT)
|
||||
StrCat(buf,"SHIFT ");
|
||||
if (ch=ScanCode2A(sc.u8[0])) {
|
||||
if (ch=ScanCode2A(sc&255)) {
|
||||
st=A2KeyName(ch,FALSE);
|
||||
StrCpy(buf+StrLen(buf),st);
|
||||
Free(st);
|
||||
} else {
|
||||
switch (sc.u8[0]) {
|
||||
switch (sc&255) {
|
||||
case SC_BACKSPACE:StrCat(buf,"BACK"); break;
|
||||
case SC_CAPS: StrCat(buf,"CAPS"); break;
|
||||
case SC_NUM: StrCat(buf,"NUM"); break;
|
||||
@@ -402,15 +402,15 @@ U0 KbdPktRead()
|
||||
sc=KbdBuildSC(raw_byte,&last_raw_byte,&last_sc,&set_LEDs,&ctrl_alt);
|
||||
if (ctrl_alt && sc) {
|
||||
if (!(sc & SCF_KEY_UP)) {
|
||||
if (sc.u8[0]==SC_DELETE)
|
||||
if (sc&255==SC_DELETE)
|
||||
CtrlAltDel(last_sc);
|
||||
else {
|
||||
if (sc.u8[0]==SC_ESC)
|
||||
if (sc&255==SC_ESC)
|
||||
ch='e';
|
||||
else if (sc.u8[0]==SC_TAB)
|
||||
else if (sc&255==SC_TAB)
|
||||
ch='t';
|
||||
else
|
||||
ch=ScanCode2A(sc.u8[0]);
|
||||
ch=ScanCode2A(sc&255);
|
||||
if ('a'<=ch<='z' && fp_ctrl_alt_let_cbs[ch-'a'] &&
|
||||
Bt(&ctrl_alt_let_in_irq_flags,ch-'a')) {
|
||||
(*fp_ctrl_alt_let_cbs[ch-'a'])(last_sc);
|
||||
@@ -489,12 +489,12 @@ U0 KbdHandler()
|
||||
}
|
||||
if (ctrl_alt) {
|
||||
if (!(sc & SCF_KEY_UP)) {
|
||||
if (sc.u8[0]==SC_ESC)
|
||||
if (sc&255==SC_ESC)
|
||||
ch='e';
|
||||
else if (sc.u8[0]==SC_TAB)
|
||||
else if (sc&255==SC_TAB)
|
||||
ch='t';
|
||||
else
|
||||
ch=ScanCode2A(sc.u8[0]);
|
||||
ch=ScanCode2A(sc&255);
|
||||
if ('a'<=ch<='z' && fp_ctrl_alt_let_cbs[ch-'a'] &&
|
||||
!Bt(&ctrl_alt_let_in_irq_flags,ch-'a'))
|
||||
(*fp_ctrl_alt_let_cbs[ch-'a'])(sys_cur_scan_code);
|
||||
@@ -516,7 +516,7 @@ U0 KbdHandler()
|
||||
}
|
||||
}
|
||||
|
||||
I64 KbdQueMsgs()
|
||||
I64 KbdMsgsQue()
|
||||
{
|
||||
I64 p1,p2,msg_code=MSG_NULL;
|
||||
CTask *task_focus;
|
||||
@@ -524,11 +524,11 @@ I64 KbdQueMsgs()
|
||||
while (FifoI64Rem(scan_code_fifo,&p2)) {
|
||||
p1=ScanCode2A(p2);
|
||||
if (p2 & SCF_KEY_UP) {
|
||||
QueMsg(task_focus,0,
|
||||
TaskMsgQue(task_focus,0,
|
||||
MSG_KEY_UP,p1,p2,0);
|
||||
msg_code=MSG_KEY_UP;
|
||||
} else {
|
||||
QueMsg(task_focus,0,
|
||||
TaskMsgQue(task_focus,0,
|
||||
MSG_KEY_DOWN,p1,p2,0);
|
||||
msg_code=MSG_KEY_DOWN;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
U0 InputFilterTask()
|
||||
{
|
||||
U8 *st;
|
||||
CTaskCmd *tempc,*tempc1;
|
||||
CSrvCmd *tempc,*tempc1;
|
||||
Bool old_filter;
|
||||
I64 old_flags=GetFlags;
|
||||
LBts(&Fs->task_flags,TASKf_USER);
|
||||
@@ -10,26 +9,24 @@ U0 InputFilterTask()
|
||||
old_filter=LBts(&Fs->last_input_filter_task->task_flags,TASKf_FILTER_INPUT);
|
||||
LBEqu(&Fs->task_flags,TASKf_FILTER_INPUT,old_filter);
|
||||
while (TRUE) {
|
||||
ServantCmdsHandler;
|
||||
SrvCmdsHandler;
|
||||
Cli;
|
||||
tempc1=&Fs->next_servant_cmd;
|
||||
tempc1=&Fs->srv_ctrl.next_waiting;
|
||||
tempc=tempc1->next;
|
||||
if (tempc==tempc1)
|
||||
break;
|
||||
else {
|
||||
if (tempc->cmd_code==TASKCT_TEXT_INPUT) {
|
||||
if (tempc->cmd_code==SVCT_TEXT_INPUT) {
|
||||
QueRem(tempc);
|
||||
SetFlags(old_flags);
|
||||
st=tempc->data;
|
||||
Free(tempc);
|
||||
if (!IsSysDeterministic)
|
||||
Preempt(ON);
|
||||
try
|
||||
ExePutS(st);
|
||||
ExePutS(tempc->aux_str);
|
||||
catch
|
||||
Fs->catch_except=TRUE;
|
||||
Preempt(OFF);
|
||||
Free(st);
|
||||
SrvCmdDel(tempc);
|
||||
} else
|
||||
break;
|
||||
}
|
||||
@@ -44,28 +41,28 @@ U0 InputFilterTask()
|
||||
I64 ScanMsg(I64 *_p1=NULL,I64 *_p2=NULL,I64 mask=~1,CTask *task=NULL)
|
||||
{
|
||||
I64 result,old_flags;
|
||||
CTaskCmd *tempc,*tempc1;
|
||||
CSrvCmd *tempc,*tempc1;
|
||||
if (!task) task=Fs;
|
||||
old_flags=GetFlags;
|
||||
tempc1=&task->next_servant_cmd;
|
||||
tempc1=&task->srv_ctrl.next_waiting;
|
||||
while (TRUE) {
|
||||
if (task==Fs)
|
||||
ServantCmdsHandler;
|
||||
SrvCmdsHandler;
|
||||
Cli;
|
||||
tempc=tempc1->next;
|
||||
if (tempc==tempc1)
|
||||
break;
|
||||
else {
|
||||
if (tempc->cmd_code==TASKCT_MSG) {
|
||||
if (tempc->cmd_code==SVCT_MSG) {
|
||||
QueRem(tempc);
|
||||
SetFlags(old_flags);
|
||||
result=tempc->msg_code;
|
||||
if (_p1)
|
||||
*_p1=tempc->p1;
|
||||
*_p1=tempc->aux1;
|
||||
if (_p2)
|
||||
*_p2=tempc->p2;
|
||||
Free(tempc);
|
||||
if ((result!=MSG_KEY_DOWN || !(tempc->p2&SCF_KEY_DESC) ||
|
||||
*_p2=tempc->aux2;
|
||||
SrvCmdDel(tempc);
|
||||
if ((result!=MSG_KEY_DOWN || !(tempc->aux2&SCF_KEY_DESC) ||
|
||||
Bt(&mask,MSGF_ALLOW_KEY_DESC)) && Bt(&mask,result))
|
||||
goto sm_done;
|
||||
}
|
||||
@@ -140,13 +137,12 @@ I64 GetKey(I64 *_scancode=NULL,Bool echo=FALSE,Bool raw_cursor=FALSE)
|
||||
{
|
||||
I64 ch,sc;
|
||||
Bool old_preempt=Preempt(OFF),cursor_on=FALSE;
|
||||
|
||||
while (!ScanKey(&ch,&sc,FALSE)) {
|
||||
if (IsRaw && raw_cursor) {
|
||||
if (!cursor_on && Blink) {
|
||||
if (!cursor_on && ToI64(GetTimeStamp*5/time_stamp_freq)&1) {
|
||||
'Û';
|
||||
cursor_on=TRUE;
|
||||
} else if (cursor_on && !Blink) {
|
||||
} else if (cursor_on && !(ToI64(GetTimeStamp*5/time_stamp_freq)&1)) {
|
||||
'' CH_BACKSPACE;
|
||||
cursor_on=FALSE;
|
||||
}
|
||||
@@ -159,7 +155,7 @@ I64 GetKey(I64 *_scancode=NULL,Bool echo=FALSE,Bool raw_cursor=FALSE)
|
||||
PushFD;
|
||||
Cli;
|
||||
KbdMouseHandler(TRUE,FALSE);
|
||||
KbdQueMsgs;
|
||||
KbdMsgsQue;
|
||||
PopFD;
|
||||
if (old_preempt && GetFlags&1<<RFLAGf_INT)
|
||||
Yield;
|
||||
@@ -184,7 +180,7 @@ I64 GetChar(I64 *_scancode=NULL,Bool echo=TRUE,Bool raw_cursor=FALSE)
|
||||
do ch1=GetKey(_scancode,FALSE,raw_cursor);
|
||||
while (!ch1);
|
||||
if (echo)
|
||||
"$$FU$$%c$$FG$$",ch1;
|
||||
"$$PT$$%c$$FG$$",ch1;
|
||||
return ch1;
|
||||
}
|
||||
|
||||
@@ -211,7 +207,7 @@ I64 GetS(U8 *buf,I64 size,Bool allow_ext=TRUE)
|
||||
Free(st);
|
||||
} else {
|
||||
while (TRUE) {
|
||||
ch=GetChar(NULL,FALSE,IsInDbg);
|
||||
ch=GetChar(,FALSE,IsInDbg);
|
||||
if (ch=='\n') {
|
||||
'' ch;
|
||||
break;
|
||||
|
||||
+3220
-3300
File diff suppressed because it is too large.
Load diff
@@ -24,7 +24,7 @@ kernel_cfg=KernelCfgNew;
|
||||
#include "Font8x8"
|
||||
#include "Memory"
|
||||
#include "Interrupts"
|
||||
#include "FIFO"
|
||||
#include "DataTypes1a"
|
||||
#include "Compress"
|
||||
#include "Hash1a"
|
||||
#include "Date"
|
||||
@@ -41,7 +41,7 @@ kernel_cfg=KernelCfgNew;
|
||||
|
||||
#include "QSort"
|
||||
#include "Task1a"
|
||||
#include "TaskCmd"
|
||||
#include "SrvCmd"
|
||||
#include "BIOS32"
|
||||
|
||||
#exe {Cd("Dsk");};
|
||||
@@ -53,7 +53,7 @@ kernel_cfg=KernelCfgNew;
|
||||
#include "DskAddDev"
|
||||
#include "DskDir"
|
||||
#include "FileSysISO1"
|
||||
#include "FileSysNative"
|
||||
#include "FileSysRedSea"
|
||||
#include "FileSysFAT"
|
||||
#include "Dsk1b"
|
||||
#include "DskCFile"
|
||||
|
||||
@@ -70,7 +70,7 @@ I64 CeilI64(I64 num,I64 to)
|
||||
}
|
||||
}
|
||||
|
||||
//See $LK-A,"::/TempleOS/Doc/Acknowledgements.TXT"$ (6).
|
||||
//See $LK-A,"::/TempleOS/Doc/Acknowledgements.TXT"$.
|
||||
#ifdef SYS_DETERMINISTIC
|
||||
$FG,6$U16 RandU16()
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
asm {
|
||||
/*
|
||||
See $LK-A,"::/TempleOS/Doc/Acknowledgements.TXT"$ (3).
|
||||
See $LK-A,"::/TempleOS/Doc/Acknowledgements.TXT"$.
|
||||
See $LK-A,"::/TempleOS/Doc/Mem.TXT"$
|
||||
*/
|
||||
|
||||
@@ -190,7 +190,7 @@ I64 MemPageSize(U8 *a)
|
||||
return 0x200000;
|
||||
}
|
||||
|
||||
I64 *MemPtAtPageTableEntry(U8 *a)
|
||||
I64 *MemPageTable(U8 *a)
|
||||
{
|
||||
if (a<NUM_PML1*0x1000*0x200)
|
||||
return PAGE_TABLE_BASE+ a>>12 *8;
|
||||
@@ -201,7 +201,7 @@ I64 *MemPtAtPageTableEntry(U8 *a)
|
||||
|
||||
Bool MemPagePresentMark(U8 *a,Bool val)
|
||||
{
|
||||
I64 *pte=MemPtAtPageTableEntry(a);
|
||||
I64 *pte=MemPageTable(a);
|
||||
Bool result=*pte&1;
|
||||
if (val)
|
||||
*pte=*pte|1; //Mark present
|
||||
@@ -415,7 +415,7 @@ am_done:
|
||||
m=result;
|
||||
m1=m(U8 *)+i;
|
||||
while (m<m1) {
|
||||
pte=MemPtAtPageTableEntry(m);
|
||||
pte=MemPageTable(m);
|
||||
*pte &= ~0x18;
|
||||
InvlPg(m);
|
||||
m(U8 *)+=MemPageSize(m);
|
||||
@@ -442,7 +442,7 @@ U8 *MemBlksUncachedAlloc(I64 *_pages2Meg,CBlkPool *bp=NULL)
|
||||
m=result;
|
||||
m1=m(U8 *)+num<<21;
|
||||
while (m<m1) {
|
||||
pte=MemPtAtPageTableEntry(m);
|
||||
pte=MemPageTable(m);
|
||||
*pte= *pte& ~0x18 |0x10;
|
||||
InvlPg(m);
|
||||
m(U8 *)+=MemPageSize(m);
|
||||
@@ -468,7 +468,7 @@ U8 *MemBlksWriteThroughAlloc(I64 *_pages2Meg,CBlkPool *bp=NULL)
|
||||
m=result;
|
||||
m1=m(U8 *)+num<<21;
|
||||
while (m<m1) {
|
||||
pte=MemPtAtPageTableEntry(m);
|
||||
pte=MemPageTable(m);
|
||||
*pte= *pte& ~0x18 |8;
|
||||
InvlPg(m);
|
||||
m(U8 *)+=MemPageSize(m);
|
||||
@@ -486,7 +486,7 @@ U0 MemBlks2MegFree(CMemBlk *m,I64 pages2Meg,CBlkPool *bp=NULL)
|
||||
m2=m;
|
||||
m1=m(U8 *)+pages2Meg<<21;
|
||||
while (m2<m1) {
|
||||
pte=MemPtAtPageTableEntry(m2);
|
||||
pte=MemPageTable(m2);
|
||||
*pte=*pte & ~0x18;
|
||||
InvlPg(m2);
|
||||
m2(U8 *)+=MemPageSize(m2);
|
||||
@@ -1029,92 +1029,6 @@ U8 *AStrNew(U8 *buf)
|
||||
return StrNew(buf,adam_task);
|
||||
}
|
||||
|
||||
U0 LinkedLstDel(U8 **_lst)
|
||||
{
|
||||
U8 **d;
|
||||
while (_lst) {
|
||||
d=*_lst;
|
||||
Free(_lst);
|
||||
_lst=d;
|
||||
}
|
||||
}
|
||||
|
||||
U8 *LinkedLstCopy(U8 **_lst,CTask *mem_task=NULL)
|
||||
{
|
||||
U8 *result=NULL,**d=&result;
|
||||
while (_lst) {
|
||||
d=*d=MAllocIdentical(_lst,mem_task);
|
||||
_lst=*_lst;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
I64 LinkedLstCnt(U8 **_lst)
|
||||
{
|
||||
I64 result=0;
|
||||
while (_lst) {
|
||||
result++;
|
||||
_lst=*_lst;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
I64 LinkedLstSize(U8 **_lst)
|
||||
{
|
||||
I64 result=0;
|
||||
while (_lst) {
|
||||
result+=MSize2(_lst);
|
||||
_lst=*_lst;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
U0 QueDel(CQue *root,Bool querem=FALSE) //Does not delete root
|
||||
{
|
||||
CQue *d=root->next,*d1;
|
||||
while (d!=root) {
|
||||
d1=d->next;
|
||||
if (querem)
|
||||
QueRem(d);
|
||||
Free(d);
|
||||
d=d1;
|
||||
}
|
||||
}
|
||||
|
||||
CQue *QueCopy(CQue *root,CTask *mem_task=NULL)
|
||||
{
|
||||
CQue *result=MAllocIdentical(root,mem_task),*d=root->next,*d1;
|
||||
QueInit(result);
|
||||
while (d!=root) {
|
||||
d1=MAllocIdentical(d,mem_task);
|
||||
QueIns(d1,result->last);
|
||||
d=d->next;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
I64 QueCnt(CQue *root) //Does not include root
|
||||
{
|
||||
CQue *d=root->next;
|
||||
I64 result=0;
|
||||
while (d!=root) {
|
||||
result++;
|
||||
d=d->next;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
I64 QueSize(CQue *root) //Does not include root
|
||||
{
|
||||
CQue *d=root->next;
|
||||
I64 result=0;
|
||||
while (d!=root) {
|
||||
result+=MSize2(d);
|
||||
d=d->next;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
U0 BlkPoolAdd(CBlkPool *bp,CMemBlk *m,I64 pages512)
|
||||
{
|
||||
if (sys_mem_init_flag)
|
||||
@@ -1330,7 +1244,7 @@ U8 *Mem64DevAlloc(I64 *_pages2Meg)
|
||||
Yield;
|
||||
while (i--) {
|
||||
sys_mem64_dev_ptr-=0x200000;
|
||||
pte=MemPtAtPageTableEntry(sys_mem64_dev_ptr);
|
||||
pte=MemPageTable(sys_mem64_dev_ptr);
|
||||
*pte=*pte&~0x18 |0x11; //Uncached and present
|
||||
InvlPg(sys_mem64_dev_ptr);
|
||||
}
|
||||
|
||||
+19
-28
@@ -186,38 +186,29 @@ U0 Sleep(I64 mS)
|
||||
SleepUntil(sys_jiffies+mS*JIFFY_FREQ/1000);
|
||||
}
|
||||
|
||||
U0 Snd(F64 freq,I64 waveform=WF_SQUARE,F64 amp=1.0)
|
||||
// The internal PC speaker only does square waves.
|
||||
// waveform and amp are for HDAudio.
|
||||
// Use $LK,"SndFilePlay","MN:SndFilePlay"$() or $LK-A,"::/TempleOS/Demo/Snd/PolyPhonic.CPP"$ as a template for
|
||||
// doing polyphonic or fancy HD Audio snd.
|
||||
U0 Snd(F64 freq)
|
||||
{
|
||||
I64 p;
|
||||
if (!Bt(&sys_semas[SYS_SEMA_MUTE],0) && snd_vol &&
|
||||
!LBts(&sys_semas[SYS_SEMA_SND],0)) {
|
||||
if (!IsInDbg && snd_dev!=SD_PC_SPEAKER) {
|
||||
CSndData *d;
|
||||
if (!Bt(&sys_semas[SYS_SEMA_MUTE],0) &&
|
||||
!LBts(&sys_semas[SYS_SEMA_SND],0)) {
|
||||
if (freq!=snd_freq) {
|
||||
snd_freq=freq;
|
||||
if (fp_snd) {
|
||||
if (0<freq<=20000 && amp>0)
|
||||
(*fp_snd)(freq,waveform,amp);
|
||||
else
|
||||
(*fp_snd)(0,waveform,0);
|
||||
}
|
||||
} else {
|
||||
if (freq!=snd_freq) {
|
||||
snd_freq=freq;
|
||||
if (0<freq<=20000 && amp>0) {
|
||||
p=SYS_TIMER_FREQ/freq;
|
||||
OutU8(0x43,0xB6);
|
||||
OutU8(0x42,p);
|
||||
OutU8(0x42,p.u8[1]);
|
||||
OutU8(0x61,3|InU8(0x61));
|
||||
} else
|
||||
OutU8(0x61,InU8(0x61)&~3);
|
||||
}
|
||||
if (0<freq<=20000) {
|
||||
p=SYS_TIMER_FREQ/freq;
|
||||
OutU8(0x43,0xB6);
|
||||
OutU8(0x42,p);
|
||||
OutU8(0x42,p.u8[1]);
|
||||
OutU8(0x61,3|InU8(0x61));
|
||||
} else
|
||||
OutU8(0x61,InU8(0x61)&~3);
|
||||
}
|
||||
if (!IsInDbg && snd_record) {
|
||||
d=ACAlloc(sizeof(CSndData));
|
||||
d->freq=freq;
|
||||
d->time_stamp=tT;
|
||||
QueIns(d,snd_record_root.last);
|
||||
}
|
||||
if (!IsInDbg && snd_record && fp_snd_record)
|
||||
(*fp_snd_record)(freq,waveform,amp);
|
||||
LBtr(&sys_semas[SYS_SEMA_SND],0);
|
||||
}
|
||||
}
|
||||
|
||||
+80
-167
@@ -80,7 +80,7 @@ USE64
|
||||
}
|
||||
|
||||
U0 TSSBusy(I64 tr,Bool val=OFF)
|
||||
{
|
||||
{ //See $LK-A,"::/TempleOS/Demo/Lectures/Ring3.CPP"$.
|
||||
LBEqu((&sys_gdttab)(U8 *)+tr+4,9,val);
|
||||
}
|
||||
|
||||
@@ -124,16 +124,9 @@ CTSS *TSSNew(I64 cpu_num)
|
||||
return tss;
|
||||
}
|
||||
|
||||
U0 MPCmdCtrlInit(CMPCmdCtrl *ctrl)
|
||||
{
|
||||
MemSet(ctrl,0,sizeof(CMPCmdCtrl));
|
||||
QueInit(ctrl);
|
||||
ctrl->next_done=ctrl->last_done=&ctrl->next_done;
|
||||
}
|
||||
|
||||
CTask *TaskIdleInit()
|
||||
{
|
||||
CTask *task=Spawn(0,NULL,"Idle Task",Fs,,0);
|
||||
CTask *task=Spawn(0,NULL,"Idle Task",,Fs,,0);
|
||||
Bts(&task->task_flags,TASKf_IDLE);
|
||||
return task;
|
||||
}
|
||||
@@ -144,7 +137,6 @@ CCPU *CPUStructInit(I64 num,CCPU *c)
|
||||
c->addr=c;
|
||||
c->num=num;
|
||||
c->idle_factor=0.01;
|
||||
MPCmdCtrlInit(&c->cmd_ctrl);
|
||||
if (num)
|
||||
c->idle_task=TaskIdleInit;
|
||||
else
|
||||
@@ -158,7 +150,7 @@ U0 MPInt(U8 num,I64 cpu_num=1)
|
||||
if (!Bt(&sys_run_level,RLf_MP))
|
||||
return;
|
||||
else
|
||||
throw(EXCEPT_MULTICORE,0);
|
||||
throw(EXCEPT_MULTICORE,1);
|
||||
}
|
||||
PushFD;
|
||||
Cli; //multitasking safe because each core has a local apic and IRQ's are off
|
||||
@@ -191,22 +183,22 @@ U0 MPHalt()
|
||||
BusyWait(10000);
|
||||
}
|
||||
|
||||
U0 MPWake(I64 target_cpu_mask)
|
||||
U0 MPWake(I64 target_cpu)
|
||||
{
|
||||
I64 i;
|
||||
target_cpu_mask&=1<<mp_cnt-1;
|
||||
Btr(&target_cpu_mask,Gs->num);
|
||||
PushFD;
|
||||
Cli;
|
||||
for (i=Bsf(target_cpu_mask);target_cpu_mask;i++)
|
||||
if (Btr(&target_cpu_mask,i)) {
|
||||
if (Bt(&cpu_structs[i].cpu_flags,CPUf_SETH_SLEEP))
|
||||
cpu_structs[i].seth_task->wake_jiffy=0;
|
||||
MPInt(I_WAKE,i);
|
||||
if (Bt(&cpu_structs[i].cpu_flags,CPUf_SETH_SLEEP)) //In case went back to sleep
|
||||
cpu_structs[i].seth_task->wake_jiffy=0;
|
||||
}
|
||||
PopFD;
|
||||
if (0<=target_cpu<mp_cnt) {
|
||||
PushFD;
|
||||
Cli;
|
||||
if (Bt(&cpu_structs[target_cpu].cpu_flags,CPUf_SETH_SLEEP))
|
||||
cpu_structs[target_cpu].seth_task->wake_jiffy=0;
|
||||
if (!target_cpu)
|
||||
LBtr(&adam_task->task_flags,TASKf_AWAITING_MSG);
|
||||
MPInt(I_WAKE,target_cpu);
|
||||
if (!target_cpu)
|
||||
LBtr(&adam_task->task_flags,TASKf_AWAITING_MSG);
|
||||
if (Bt(&cpu_structs[target_cpu].cpu_flags,CPUf_SETH_SLEEP)) //In case went back to sleep
|
||||
cpu_structs[target_cpu].seth_task->wake_jiffy=0;
|
||||
PopFD;
|
||||
}
|
||||
}
|
||||
|
||||
U0 MPAPICInit()
|
||||
@@ -231,148 +223,88 @@ U0 MPAPICInit()
|
||||
}
|
||||
}
|
||||
|
||||
#assert !offset(CMPCmdCtrl.next_waiting)
|
||||
|
||||
Bool MPCmdCtrlDo(CMPCmdCtrl *ctrl)
|
||||
{ //Called while locked
|
||||
CMPCmd *tempm=ctrl->next_waiting;
|
||||
while (tempm!=ctrl && !Bt(&tempm->target_cpu_mask,Gs->num))
|
||||
tempm=tempm->next;
|
||||
if (tempm!=ctrl) {
|
||||
QueRem(tempm);
|
||||
LBts(&tempm->flags,MPCf_DISPATCHED);
|
||||
tempm->handler_cpu=Gs->num;
|
||||
LBtr(&ctrl->flags,MPCCf_LOCKED);
|
||||
switch (tempm->cmd_code) {
|
||||
case MPCT_CALL:
|
||||
tempm->result=(*tempm->add)(tempm->data);
|
||||
Preempt(OFF);
|
||||
Sti;
|
||||
break;
|
||||
case MPCT_SPAWN_TASK:
|
||||
if (tempm->desc)
|
||||
tempm->task=Spawn(tempm->add,tempm->data,tempm->desc);
|
||||
else
|
||||
tempm->task=Spawn(tempm->add,tempm->data,"MP Job");
|
||||
break;
|
||||
}
|
||||
if (Bt(&tempm->flags,MPCf_FREE_ON_COMPLETE)) {
|
||||
Free(tempm->desc);
|
||||
Free(tempm);
|
||||
} else {
|
||||
while (LBts(&ctrl->flags,MPCCf_LOCKED))
|
||||
Yield;
|
||||
QueIns(tempm,ctrl->last_done);
|
||||
LBts(&tempm->flags,MPCf_DONE);
|
||||
LBtr(&ctrl->flags,MPCCf_LOCKED);
|
||||
}
|
||||
return TRUE;
|
||||
} else {
|
||||
LBtr(&ctrl->flags,MPCCf_LOCKED);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
#assert !offset(CSrvCtrl.next_waiting)
|
||||
|
||||
U0 MPSethServerTask()
|
||||
{
|
||||
CMPCmdCtrl *my_ctrl=&Gs->cmd_ctrl;
|
||||
CSrvCtrl *my_ctrl=&Fs->srv_ctrl;
|
||||
CSrvCmd *tempc,*tempc1=&my_ctrl->next_waiting;
|
||||
Sti;
|
||||
while (TRUE) {
|
||||
TaskFinishOffDying;
|
||||
if (!LBts(&my_ctrl->flags,MPCCf_LOCKED) &&
|
||||
!MPCmdCtrlDo(my_ctrl) && //Jobs for this core are highest priority.
|
||||
!LBts(&mp_ctrl->flags,MPCCf_LOCKED))
|
||||
MPCmdCtrlDo(mp_ctrl);
|
||||
if (my_ctrl->next_waiting==my_ctrl &&
|
||||
mp_ctrl->next_waiting==mp_ctrl) {
|
||||
LBts(&Gs->cpu_flags,CPUf_SETH_SLEEP);
|
||||
Sleep(20); //We don't want this too long because of need for $LK,"TaskFinishOffDying","MN:TaskFinishOffDying"$().
|
||||
LBtr(&Gs->cpu_flags,CPUf_SETH_SLEEP);
|
||||
if (!LBts(&my_ctrl->flags,SVCRf_LOCKED)) {
|
||||
tempc=tempc1->next;
|
||||
//Jobs for this core are highest priority.
|
||||
if (tempc==tempc1 || !SrvCmdRun(tempc,GetFlags)) {
|
||||
LBtr(&my_ctrl->flags,SVCRf_LOCKED) ;
|
||||
if (my_ctrl->next_waiting==my_ctrl) {
|
||||
LBts(&Gs->cpu_flags,CPUf_SETH_SLEEP);
|
||||
Sleep(20); //We don't want this too long because of need for $LK,"TaskFinishOffDying","MN:TaskFinishOffDying"$().
|
||||
LBtr(&Gs->cpu_flags,CPUf_SETH_SLEEP);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CMPCmd *MPQueJob(I64 (*fp_add)(U8 *data),U8 *data=NULL,
|
||||
U8 *desc=NULL,
|
||||
I64 flags=1<<MPCf_FREE_ON_COMPLETE,
|
||||
Bool spawn=FALSE,I64 target_cpu_mask=ALL_MASK)
|
||||
CSrvCmd *JobQue(I64 (*fp_add)(U8 *data),U8 *data=NULL,
|
||||
I64 target_cpu=1,I64 flags=1<<SVCf_FREE_ON_COMPLETE,
|
||||
I64 cmd_code=SVCT_CALL,U8 *aux_str=NULL,I64 aux1=0,I64 aux2=0)
|
||||
//This is to queue multicore jobs, handled by Seth tasks.
|
||||
//Set flags to zero if you wish to get the result.
|
||||
{
|
||||
I64 i=Bsf(target_cpu_mask);
|
||||
CMPCmdCtrl *ctrl;
|
||||
CMPCmd *tempm;
|
||||
if (mp_cnt<2 || i<0) throw(EXCEPT_MULTICORE,1);
|
||||
tempm=ACAlloc(sizeof(CMPCmd));
|
||||
if (desc)
|
||||
tempm->desc=AStrNew(desc);
|
||||
if (spawn)
|
||||
tempm->cmd_code=MPCT_SPAWN_TASK;
|
||||
else
|
||||
tempm->cmd_code=MPCT_CALL;
|
||||
tempm->add=fp_add;
|
||||
tempm->data=data;
|
||||
tempm->target_cpu_mask=target_cpu_mask;
|
||||
tempm->flags=flags;
|
||||
if (i==Bsr(target_cpu_mask))
|
||||
tempm->ctrl=ctrl=&cpu_structs[i].cmd_ctrl;
|
||||
else
|
||||
tempm->ctrl=ctrl=mp_ctrl;
|
||||
CSrvCtrl *ctrl;
|
||||
CSrvCmd *tempc;
|
||||
if (!(0<=target_cpu<mp_cnt))
|
||||
throw(EXCEPT_MULTICORE,2);
|
||||
tempc=ACAlloc(sizeof(CSrvCmd));
|
||||
if (aux_str)
|
||||
tempc->aux_str=AStrNew(aux_str);
|
||||
tempc->cmd_code=cmd_code;
|
||||
tempc->add=fp_add;
|
||||
tempc->fun_arg=data;
|
||||
tempc->target_cpu=target_cpu;
|
||||
tempc->flags=flags;
|
||||
tempc->aux1=aux1;
|
||||
tempc->aux2=aux2;
|
||||
tempc->ctrl=ctrl=&cpu_structs[target_cpu].seth_task->srv_ctrl;
|
||||
PushFD;
|
||||
Cli;
|
||||
while (LBts(&ctrl->flags,MPCCf_LOCKED))
|
||||
while (LBts(&ctrl->flags,SVCRf_LOCKED))
|
||||
Yield;
|
||||
QueIns(tempm,ctrl->last_waiting);
|
||||
LBtr(&ctrl->flags,MPCCf_LOCKED);
|
||||
QueIns(tempc,ctrl->last_waiting);
|
||||
LBtr(&ctrl->flags,SVCRf_LOCKED);
|
||||
PopFD;
|
||||
MPWake(target_cpu_mask);
|
||||
return tempm;
|
||||
MPWake(target_cpu);
|
||||
return tempc;
|
||||
}
|
||||
|
||||
CMPCmd *MPJob(I64 (*fp_add)(U8 *data),U8 *data=NULL,
|
||||
I64 target_cpu=1,I64 flags=1<<MPCf_FREE_ON_COMPLETE)
|
||||
//Set flags to zero if you wish to
|
||||
//get the result.
|
||||
{
|
||||
return MPQueJob(fp_add,data,NULL,flags,FALSE,1<<target_cpu);
|
||||
}
|
||||
|
||||
I64 MPJobResult(CMPCmd *tempm)
|
||||
{
|
||||
I64 result;
|
||||
CMPCmdCtrl *ctrl=tempm->ctrl;
|
||||
if (mp_cnt<2) throw(EXCEPT_MULTICORE,2);
|
||||
while (!Bt(&tempm->flags,MPCf_DONE))
|
||||
Yield;
|
||||
PushFD;
|
||||
Cli;
|
||||
while (LBts(&ctrl->flags,MPCCf_LOCKED))
|
||||
Yield;
|
||||
QueRem(tempm);
|
||||
LBtr(&ctrl->flags,MPCCf_LOCKED);
|
||||
PopFD;
|
||||
result=tempm->result;
|
||||
Free(tempm->desc);
|
||||
Free(tempm);
|
||||
return result;
|
||||
}
|
||||
|
||||
CTask *MPSpawn(U0 (*fp_add)(U8 *data),U8 *data=NULL,U8 *name=NULL,I64 target_cpu=1)
|
||||
CTask *SpawnQue(U0 (*fp_add)(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)
|
||||
{
|
||||
CTask *result;
|
||||
CMPCmd *tempm=MPQueJob(fp_add,data,name,0,TRUE,1<<target_cpu);
|
||||
CMPCmdCtrl *ctrl;
|
||||
while (!Bt(&tempm->flags,MPCf_DONE))
|
||||
CSrvCmd *tempc=JobQue(fp_add,data,target_cpu,flags,SVCT_SPAWN_TASK,task_name,parent,stk_size);
|
||||
CSrvCtrl *ctrl;
|
||||
|
||||
while (!Bt(&tempc->flags,SVCf_DONE)) {
|
||||
LBts(&Fs->task_flags,TASKf_IDLE);
|
||||
Yield;
|
||||
result=tempm->task;
|
||||
ctrl=tempm->ctrl;
|
||||
}
|
||||
LBtr(&Fs->task_flags,TASKf_IDLE);
|
||||
|
||||
result=tempc->spawned_task;
|
||||
ctrl=tempc->ctrl;
|
||||
PushFD;
|
||||
Cli;
|
||||
while (LBts(&ctrl->flags,MPCCf_LOCKED))
|
||||
while (LBts(&ctrl->flags,SVCRf_LOCKED))
|
||||
Yield;
|
||||
QueRem(tempm);
|
||||
LBtr(&ctrl->flags,MPCCf_LOCKED);
|
||||
QueRem(tempc);
|
||||
LBtr(&ctrl->flags,SVCRf_LOCKED);
|
||||
PopFD;
|
||||
Free(tempm->desc);
|
||||
Free(tempm);
|
||||
SrvCmdDel(tempc);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -385,18 +317,6 @@ U0 MPCPUTaskInit()
|
||||
TaskContextRestore;
|
||||
}
|
||||
|
||||
U0 MPCmdQueDel(CMPCmd *root)
|
||||
{
|
||||
CMPCmd *tempm=root->next,*tempm1;
|
||||
while (tempm!=root) {
|
||||
tempm1=tempm->next;
|
||||
QueRem(tempm);
|
||||
Free(tempm->desc);
|
||||
Free(tempm);
|
||||
tempm=tempm1;
|
||||
}
|
||||
}
|
||||
|
||||
U0 MPStart()
|
||||
{ //Called by adam during start-up
|
||||
//and can be called again to rst multicores.
|
||||
@@ -420,11 +340,9 @@ U0 MPStart()
|
||||
MPHalt; //sets mp_cnt to 1
|
||||
for (i=1;i<my_mp_cnt;i++) {
|
||||
c=&cpu_structs[i];
|
||||
MPCmdQueDel(&c->cmd_ctrl.next_waiting);
|
||||
MPCmdQueDel(&c->cmd_ctrl.next_done);
|
||||
SrvCmdQueDel(&c->seth_task->srv_ctrl.next_waiting);
|
||||
SrvCmdQueDel(&c->seth_task->srv_ctrl.next_done);
|
||||
}
|
||||
MPCmdQueDel(&mp_ctrl->next_waiting);
|
||||
MPCmdQueDel(&mp_ctrl->next_done);
|
||||
}
|
||||
MemSet(&cpu_structs[1],0,sizeof(CCPU)*(MP_MAX_PROCESSORS-1));
|
||||
|
||||
@@ -457,10 +375,8 @@ U0 MPStart()
|
||||
|
||||
for (i=1;i<my_mp_cnt;i++) {
|
||||
c =&cpu_structs[i];
|
||||
//SPrintF not available yet.
|
||||
StrCpy(buf,"Seth Task CPU#0");
|
||||
buf[14]+=i;
|
||||
task=Spawn(&MPCPUTaskInit,NULL,buf,NULL,SETH_STK,0);
|
||||
SPrintF(buf,"Seth Task CPU#%d",i);
|
||||
task=Spawn(&MPCPUTaskInit,NULL,buf,,,SETH_STK,0);
|
||||
task->rflags=SYS_START_RFLAGS;
|
||||
//$LK,"CTask","MN:CTask"$ allocated off this core's seth_task's heap (Which is Adam)
|
||||
task->task_in_que_signature=TASK_IN_QUE_SIGNATURE_VAL;
|
||||
@@ -490,9 +406,6 @@ U0 MPInit()
|
||||
mp_cnt_initial=mp_cnt=1;
|
||||
mp_cnt_lock=0;
|
||||
|
||||
mp_ctrl=AMAlloc(sizeof(CMPCmdCtrl));
|
||||
MPCmdCtrlInit(mp_ctrl);
|
||||
|
||||
mp_crash=ACAlloc(sizeof(CMPCrash));
|
||||
|
||||
//Must be in code heap because init code uses 32 bit addr of cpu_struct
|
||||
|
||||
+73
-54
@@ -11,35 +11,40 @@ CHash *PSectFind(U8 *add,I64 *_offset)
|
||||
{ //See $LK,"::/TempleOS/Kernel/Hash1a.CPP","FL:::/TempleOS/Kernel/Hash1a.CPP,1"$
|
||||
CHash *result=NULL;
|
||||
CHashExport *tempess;
|
||||
CHashTable *h=Fs->hash_table;
|
||||
Bool has_lower=FALSE;
|
||||
U64 best=0x8000,j;
|
||||
if (!ChkPtr(add)) {
|
||||
CHashTable *h=Fs->hash_table;
|
||||
U64 best=0xFFFF,j;
|
||||
if (!ChkCodePtr(add)) {
|
||||
*_offset=best;
|
||||
return NULL;
|
||||
}
|
||||
while (h) {
|
||||
tempess=h->next_added;
|
||||
while (tempess!=h) {
|
||||
if (tempess->type&HTT_FUN)
|
||||
j=tempess(CHashFun *)->executable_addr;
|
||||
else if (tempess->type&HTT_EXPORT_SYS_SYM)
|
||||
j=0;
|
||||
if (tempess->type&HTT_FUN) {
|
||||
if (!Bt(&tempess(CHashFun *)->flags,Cf_EXTERN) &&
|
||||
!Bt(&tempess(CHashFun *)->flags,Ff_INTERNAL))
|
||||
j=tempess(CHashFun *)->executable_addr;
|
||||
} else if (tempess->type&HTT_EXPORT_SYS_SYM)
|
||||
j=tempess->val;
|
||||
else
|
||||
j=0;
|
||||
j=add(I64)-j;
|
||||
if (tempess->type&HTT_EXPORT_SYS_SYM) {
|
||||
if (j<best || j==best && !has_lower) {
|
||||
has_lower=HasLower(tempess->str);
|
||||
best=j;
|
||||
result=tempess;
|
||||
}
|
||||
} else if (tempess->type&HTT_FUN) {
|
||||
if (j<best || j==best &&
|
||||
(result && result->type&HTT_EXPORT_SYS_SYM||!has_lower)) {
|
||||
has_lower=HasLower(tempess->str);
|
||||
best=j;
|
||||
result=tempess;
|
||||
if (j) {
|
||||
j=add(I64)-j;
|
||||
if (0<=j<=best) {
|
||||
if (tempess->type&HTT_EXPORT_SYS_SYM) {
|
||||
if (j<best || j==best && !has_lower) {
|
||||
has_lower=HasLower(tempess->str);
|
||||
best=j;
|
||||
result=tempess;
|
||||
}
|
||||
} else if (tempess->type&HTT_FUN) {
|
||||
if (j<best || j==best &&
|
||||
(result && result->type&HTT_EXPORT_SYS_SYM||!has_lower)) {
|
||||
has_lower=HasLower(tempess->str);
|
||||
best=j;
|
||||
result=tempess;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
tempess=tempess->next_added;
|
||||
@@ -114,20 +119,19 @@ U0 SPrintFPSect(U8 *buf,I64 add,I64 field_len)
|
||||
}
|
||||
}
|
||||
if (str) {
|
||||
if (offset<=0xFFFF) {
|
||||
if (is_fun) {
|
||||
str2=MSPrintF("&%s",str);
|
||||
if (field_len>7)
|
||||
SPrintF(buf,"%*ts+0x%04X",field_len-7,str2,offset);
|
||||
else
|
||||
SPrintF(buf,"%s+0x%04X",str2,offset);
|
||||
Free(str2);
|
||||
} else {
|
||||
if (field_len>7)
|
||||
SPrintF(buf,"%*ts+0x%04X",field_len-7,str,offset);
|
||||
else
|
||||
SPrintF(buf,"%s+0x%04X",str,offset);
|
||||
}
|
||||
if (offset>0xFFFF) offset=0xFFFF;
|
||||
if (is_fun) {
|
||||
str2=MSPrintF("&%s",str);
|
||||
if (field_len>7)
|
||||
SPrintF(buf,"%*ts+0x%04X",field_len-7,str2,offset);
|
||||
else
|
||||
SPrintF(buf,"%s+0x%04X",str2,offset);
|
||||
Free(str2);
|
||||
} else {
|
||||
if (field_len>7)
|
||||
SPrintF(buf,"%*ts+0x%04X",field_len-7,str,offset);
|
||||
else
|
||||
SPrintF(buf,"%s+0x%04X",str,offset);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -142,40 +146,55 @@ U0 SPrintFPSect(U8 *buf,I64 add,I64 field_len)
|
||||
I64 SrcLineNum(U8 *add,I64 cnt=1)
|
||||
{
|
||||
CHashSrcSym *temph;
|
||||
I64 i,ii,j,offset,best=-1,d,best_d;
|
||||
I64 cur_line,first_line,last_line,num_lines,offset;
|
||||
CDbgInfo *dbg;
|
||||
U8 **body,*src,*src2;
|
||||
if (temph=PSectFind(add,&offset)) {
|
||||
if (temph->type&(HTT_FUN|HTT_EXPORT_SYS_SYM)) {
|
||||
if (dbg=temph->debug) {
|
||||
j=dbg->max_line-dbg->min_line+1;
|
||||
num_lines=dbg->max_line-dbg->min_line+1;
|
||||
body=dbg->body;
|
||||
best_d=MAX_I64;
|
||||
for (i=0;i<j;i++) {
|
||||
if (0<body[i]<=add<body[i]+cnt) {
|
||||
ii=i+1;
|
||||
while (!body[ii])
|
||||
ii++;
|
||||
if (add<body[ii]) {
|
||||
d=add(I64)-body[i];
|
||||
if (d<best_d) {
|
||||
best_d=d;
|
||||
best=i+dbg->min_line;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//find first nonzero
|
||||
first_line=0;
|
||||
while (!body[first_line]) {
|
||||
first_line++;
|
||||
if (first_line>=num_lines)
|
||||
return -1;
|
||||
}
|
||||
} else if (temph->src_link && !offset) {
|
||||
|
||||
//find last nonzero
|
||||
last_line=num_lines-1;
|
||||
while (!body[last_line] && last_line>first_line)
|
||||
last_line--;
|
||||
|
||||
//interpolate to guess line num
|
||||
cur_line=LimitI64(ToF64(add-body[first_line])*(last_line-first_line+1)/
|
||||
(body[last_line]-body[first_line]+1),first_line,last_line);
|
||||
|
||||
//retreat while too high
|
||||
while ((!body[cur_line] || body[cur_line]>=add) && cur_line>first_line)
|
||||
cur_line--;
|
||||
|
||||
//advance while to low
|
||||
while ((!body[cur_line] || body[cur_line]<add) && cur_line<last_line)
|
||||
cur_line++;
|
||||
|
||||
if (add<body[cur_line]+cnt)
|
||||
return cur_line+dbg->min_line;
|
||||
|
||||
} else if (temph->src_link) {
|
||||
src =StrNew(temph->src_link);
|
||||
src2=StrNew(temph->src_link);
|
||||
StrLastRem(src,",",src2);
|
||||
best=A2I(src2);
|
||||
cur_line=A2I(src2);
|
||||
Free(src);
|
||||
Free(src2);
|
||||
return cur_line;
|
||||
}
|
||||
}
|
||||
}
|
||||
return best;
|
||||
return -1;
|
||||
}
|
||||
|
||||
U8 *SrcFileName(U8 *add,I64 cnt=1,CTask *mem_task=NULL)
|
||||
|
||||
@@ -5,8 +5,7 @@ For assending strings: Compare can return StrCmp(e1,e2);
|
||||
For assending ints : Compare can return e1-e2;
|
||||
Don't use e1-e2 if numbers can overflow, return -1,0 or 1 with if's.
|
||||
|
||||
Maybe, look at $LK-A,"::/TempleOS/Demo/MultiCore/Sort.CPP"$ or
|
||||
$LK-A,"::/TempleOS/Demo/MultiCore/RadixSort.CPP"$.
|
||||
Maybe, look at $LK-A,"::/TempleOS/Demo/MultiCore/RadixSort.CPP"$.
|
||||
*/
|
||||
I64 i,*less,*greater,pivot;
|
||||
if (num>1) {
|
||||
@@ -150,8 +149,7 @@ For assending strings: Compare can return StrCmp(*e1,*e2);
|
||||
For assending ints : Compare can return *e1-*e2;
|
||||
Don't use e1-e2 if numbers can overflow, return -1,0 or 1 with if's.
|
||||
|
||||
Maybe, look at $LK-A,"::/TempleOS/Demo/MultiCore/Sort.CPP"$ or
|
||||
$LK-A,"::/TempleOS/Demo/MultiCore/RadixSort.CPP"$.
|
||||
Maybe, look at $LK-A,"::/TempleOS/Demo/MultiCore/RadixSort.CPP"$.
|
||||
*/
|
||||
I64 i;
|
||||
U8 *less,*greater,*temp,*pivot;
|
||||
|
||||
@@ -184,7 +184,7 @@ SYS_YIELD::
|
||||
PUSH RAX
|
||||
MOV RAX,SYS_SEMAS
|
||||
BT U32 SYS_SEMA_SINGLE_USER*SEMA_STRUCT_SIZE[RAX],0
|
||||
JC @@05
|
||||
JC @@05 //If single user, don't change task.
|
||||
POP RAX
|
||||
|
||||
CLI
|
||||
@@ -192,12 +192,12 @@ SYS_YIELD::
|
||||
XOR RSI,RSI
|
||||
MOV RSI,FS:CTask.addr[RSI]
|
||||
CMP U64 CTask.next_task[RSI],RSI
|
||||
JNE @@15
|
||||
JNE @@15 //Jmp if not just one task on core.
|
||||
|
||||
PUSH RAX
|
||||
MOV RAX,U64 [SYS_JIFFIES]
|
||||
CMP U64 CTask.wake_jiffy[RSI],RAX
|
||||
JA @@10
|
||||
JA @@10 //If needs to sleep, jmp and swap-out.
|
||||
|
||||
POP RAX
|
||||
POP RSI
|
||||
@@ -233,7 +233,7 @@ RESTORE_RSI_TASK_NO_KEY_CHECK:
|
||||
|
||||
MOV RAX,U64 [SYS_JIFFIES]
|
||||
CMP U64 CTask.wake_jiffy[RSI],RAX
|
||||
JA @@25
|
||||
JA @@25 //Jmp if not ready, yet.
|
||||
|
||||
CMP U32 CTask.task_in_que_signature[RSI],TASK_IN_QUE_SIGNATURE_VAL
|
||||
JNE SWAP_IN_SETH_TASK
|
||||
@@ -244,15 +244,15 @@ RESTORE_RSI_TASK_NO_KEY_CHECK:
|
||||
@@25: MOV RSI,U64 CTask.next_task[RSI]
|
||||
XOR RAX,RAX
|
||||
CMP U64 GS:CCPU.seth_task[RAX],RSI
|
||||
JNE @@20
|
||||
JNE @@20 //Jmp if not Seth
|
||||
LOCK
|
||||
BTR U32 GS:CCPU.cpu_flags[RAX],CPUf_HAD_IRQ_OPPORTUNITY
|
||||
JC @@20
|
||||
JC @@20 //Jmp if had chance for IRQ already
|
||||
MOV RAX,U64 GS:CCPU.idle_task[RAX]
|
||||
MOV RSP,U64 CTask.stk[RAX]
|
||||
ADD RSP,DFT_STK+CTaskStk.stk_base //Rst to top
|
||||
CALL SET_FS_BASE
|
||||
STI
|
||||
STI //Swap-in idle task so we can unmask IRQs.
|
||||
HLT
|
||||
SYS_IDLE_PT::
|
||||
CLI
|
||||
|
||||
@@ -0,0 +1,522 @@
|
||||
U0 SrvCmdDel(CSrvCmd *tempc)
|
||||
{
|
||||
Free(tempc->aux_str);
|
||||
Free(tempc);
|
||||
}
|
||||
|
||||
U0 SrvCmdQueDel(CSrvCmd *root)
|
||||
{
|
||||
CSrvCmd *tempc=root->next,*tempc1;
|
||||
while (tempc!=root) {
|
||||
tempc1=tempc->next;
|
||||
QueRem(tempc);
|
||||
SrvCmdDel(tempc);
|
||||
tempc=tempc1;
|
||||
}
|
||||
}
|
||||
|
||||
U0 SrvCtrlInit(CSrvCtrl *ctrl)
|
||||
{
|
||||
QueInit(&ctrl->next_waiting);
|
||||
QueInit(&ctrl->next_done);
|
||||
ctrl->flags=0;
|
||||
}
|
||||
|
||||
U0 TaskRstAwaitingMsg(CTask *task=NULL)
|
||||
{ //Pop-ups get parent messages so wake-up our pop-ups if we got a msg.
|
||||
Bool old_preempt=Preempt(OFF);
|
||||
if (!task) task=Fs;
|
||||
if (TaskValidate(task)) {
|
||||
LBtr(&task->task_flags,TASKf_AWAITING_MSG);
|
||||
while (task=task->popup_task)
|
||||
if (TaskValidate(task))
|
||||
LBtr(&task->task_flags,TASKf_AWAITING_MSG);
|
||||
else
|
||||
break;
|
||||
}
|
||||
Preempt(old_preempt);
|
||||
}
|
||||
|
||||
CSrvCmd *TaskExeStrQue(CTask *srv,CTask *master,
|
||||
U8 *data,I64 flags)
|
||||
{
|
||||
CSrvCmd *result;
|
||||
if (!data || !TaskValidate(srv) ||
|
||||
master && !TaskValidate(master) ||
|
||||
srv->popup_task && !Bt(&srv->task_flags,TASKf_FILTER_INPUT))
|
||||
return NULL;
|
||||
result=ACAlloc(sizeof(CSrvCmd));
|
||||
result->master_task=master;
|
||||
result->cmd_code=SVCT_EXE_STR;
|
||||
result->flags=flags;
|
||||
result->aux_str=AStrNew(data);
|
||||
result->ctrl=&srv->srv_ctrl;
|
||||
|
||||
PushFD;
|
||||
Cli;
|
||||
while (LBts(&srv->srv_ctrl.flags,SVCRf_LOCKED))
|
||||
Pause;
|
||||
if (!TaskValidate(srv)) {
|
||||
PopFD;
|
||||
SrvCmdDel(result);
|
||||
return NULL;
|
||||
} else {
|
||||
LBtr(&srv->task_flags,TASKf_IDLE);
|
||||
TaskRstAwaitingMsg(srv);
|
||||
QueIns(result,srv->srv_ctrl.last_waiting);
|
||||
LBtr(&srv->srv_ctrl.flags,SVCRf_LOCKED);
|
||||
if (Bt(&flags,SVCf_WAKE_MASTER)) {
|
||||
Suspend(master);
|
||||
Yield;
|
||||
}
|
||||
}
|
||||
PopFD;
|
||||
return result;
|
||||
}
|
||||
|
||||
CSrvCmd *TaskTextInputQue(CTask *srv,CTask *master,
|
||||
U8 *data,I64 flags)
|
||||
{
|
||||
CSrvCmd *result;
|
||||
Bool old_preempt=Preempt(OFF);
|
||||
CTask *task;
|
||||
if (!data || !TaskValidate(srv) ||
|
||||
master && !TaskValidate(master) ||
|
||||
srv->popup_task && !Bt(&srv->task_flags,TASKf_FILTER_INPUT)) {
|
||||
Preempt(old_preempt);
|
||||
return NULL;
|
||||
}
|
||||
result=ACAlloc(sizeof(CSrvCmd));
|
||||
result->master_task=master; //in case somebody cares
|
||||
result->cmd_code=SVCT_TEXT_INPUT;
|
||||
result->flags=flags;
|
||||
result->aux_str=AStrNew(data);
|
||||
|
||||
PushFD;
|
||||
if (Bt(&flags,SVCf_HIGHEST_PRIORITY) ||
|
||||
srv->next_input_filter_task==srv) {
|
||||
task=Spawn(&InputFilterTask,NULL,"Input Filter",,srv);
|
||||
Cli;
|
||||
task->next_input_filter_task=srv->next_input_filter_task;
|
||||
task->last_input_filter_task=srv;
|
||||
srv->next_input_filter_task=task;
|
||||
task->next_input_filter_task->last_input_filter_task=task;
|
||||
} else
|
||||
task=srv->next_input_filter_task;
|
||||
result->ctrl=&task->srv_ctrl;
|
||||
Cli;
|
||||
while (LBts(&task->srv_ctrl.flags,SVCRf_LOCKED))
|
||||
Pause;
|
||||
if (!TaskValidate(task)) {
|
||||
SrvCmdDel(result);
|
||||
result=NULL;
|
||||
} else {
|
||||
LBtr(&task->task_flags,TASKf_IDLE);
|
||||
TaskRstAwaitingMsg(task);
|
||||
QueIns(result,task->srv_ctrl.last_waiting);
|
||||
LBtr(&task->srv_ctrl.flags,SVCRf_LOCKED);
|
||||
}
|
||||
PopFD;
|
||||
Preempt(old_preempt);
|
||||
return result;
|
||||
}
|
||||
|
||||
CSrvCmd *TaskMsgQue(CTask *_srv,CTask *master,
|
||||
I64 msg_code,I64 p1,I64 p2,I64 flags)
|
||||
{
|
||||
CSrvCmd *tempc1,*tempc;
|
||||
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=p1;
|
||||
tempc->aux2=p2;
|
||||
tempc->flags=flags;
|
||||
PushFD;
|
||||
if (Bt(&sys_semas[SYS_SEMA_RECORD_MACRO],0) &&
|
||||
srv!=sys_macro_util_task &&
|
||||
msg_code==MSG_KEY_DOWN) {
|
||||
tempc1=AMAllocIdentical(tempc);
|
||||
Cli;
|
||||
QueIns(tempc1,sys_macro_root.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;
|
||||
while (LBts(&srv->srv_ctrl.flags,SVCRf_LOCKED))
|
||||
Pause;
|
||||
if (!TaskValidate(srv)) {
|
||||
SrvCmdDel(tempc);
|
||||
tempc=NULL;
|
||||
} else {
|
||||
LBtr(&srv->task_flags,TASKf_IDLE);
|
||||
TaskRstAwaitingMsg(srv);
|
||||
QueIns(tempc,srv->srv_ctrl.last_waiting);
|
||||
LBtr(&srv->srv_ctrl.flags,SVCRf_LOCKED);
|
||||
}
|
||||
PopFD;
|
||||
if (msg_code<0) //Down-Up
|
||||
TaskMsgQue(_srv,master,-msg_code+1,p1,p2,flags);
|
||||
return tempc;
|
||||
}
|
||||
|
||||
Bool ScanResult(CSrvCmd *rqst=NULL,I64 *_result=NULL)
|
||||
{
|
||||
CSrvCtrl *ctrl;
|
||||
CSrvCmd *tempc,*tempc1;
|
||||
if (!rqst || Bt(&rqst->flags,SVCf_DONE)) {
|
||||
if (!rqst || rqst->master_task)
|
||||
ctrl=&Fs->srv_ctrl;
|
||||
else
|
||||
ctrl=rqst->ctrl;
|
||||
PushFD;
|
||||
Cli;
|
||||
while (LBts(&ctrl->flags,SVCRf_LOCKED))
|
||||
Pause;
|
||||
tempc1=&ctrl->next_done;
|
||||
tempc=tempc1->next;
|
||||
while (tempc!=tempc1) {
|
||||
if (!rqst || rqst==tempc) {
|
||||
QueRem(tempc);
|
||||
LBtr(&ctrl->flags,SVCRf_LOCKED);
|
||||
PopFD;
|
||||
if (_result)
|
||||
*_result=tempc->result;
|
||||
SrvCmdDel(tempc);
|
||||
return TRUE;
|
||||
}
|
||||
tempc=tempc->next;
|
||||
}
|
||||
LBtr(&ctrl->flags,SVCRf_LOCKED);
|
||||
PopFD;
|
||||
}
|
||||
if (_result)
|
||||
*_result=0;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
I64 GetResult(CSrvCmd *rqst=NULL)
|
||||
{
|
||||
I64 result;
|
||||
CSrvCmd *tempc1;
|
||||
if (!rqst) {
|
||||
tempc1=&Fs->srv_ctrl.next_done;
|
||||
while (tempc1==tempc1->next) {
|
||||
LBts(&Fs->task_flags,TASKf_IDLE);
|
||||
Yield;
|
||||
}
|
||||
} else {
|
||||
while (!Bt(&rqst->flags,SVCf_DONE)) {
|
||||
LBts(&Fs->task_flags,TASKf_IDLE);
|
||||
Yield;
|
||||
}
|
||||
}
|
||||
LBtr(&Fs->task_flags,TASKf_IDLE);
|
||||
//Could get taken by someone else.
|
||||
ScanResult(rqst,&result);
|
||||
return result;
|
||||
}
|
||||
|
||||
U0 TaskWait(CTask *task=NULL)
|
||||
{
|
||||
CTask *task1;
|
||||
CSrvCmd *tempc1;
|
||||
if (!task) task=Fs;
|
||||
if (TaskValidate(task)) {
|
||||
PushFD;
|
||||
Cli;
|
||||
while (TRUE) {
|
||||
task1=task->last_input_filter_task;
|
||||
tempc1=&task1->srv_ctrl.next_waiting;
|
||||
if (TaskValidate(task1) && tempc1==tempc1->next &&
|
||||
(task1==Fs || Bt(&task1->task_flags,TASKf_IDLE)))
|
||||
break;
|
||||
Yield;
|
||||
}
|
||||
PopFD;
|
||||
}
|
||||
}
|
||||
|
||||
U0 PostMsg(CTask *task,I64 msg_code,I64 p1,I64 p2,I64 flags=0)
|
||||
{
|
||||
if (TaskValidate(task)) {
|
||||
if (Bt(&task->task_flags,TASKf_INPUT_FILTER_TASK))
|
||||
TaskMsgQue(task->last_input_filter_task,NULL,msg_code,p1,p2,
|
||||
flags|1<<SVCf_DONT_FILTER);
|
||||
else
|
||||
TaskMsgQue(task,NULL,msg_code,p1,p2,flags);
|
||||
}
|
||||
}
|
||||
|
||||
U0 SendMsg(CTask *task,I64 msg_code,I64 p1,I64 p2,I64 flags=0)
|
||||
{
|
||||
PostMsg(task,msg_code,p1,p2,flags);
|
||||
TaskWait(task);
|
||||
}
|
||||
|
||||
U0 Msg(I64 msg_code,I64 p1,I64 p2,I64 flags=0)
|
||||
{
|
||||
PostMsg(Fs,msg_code,p1,p2,flags);
|
||||
}
|
||||
|
||||
#define SCR_DONE 0
|
||||
#define SCR_CONT 1
|
||||
#define SCR_EXIT 2
|
||||
|
||||
I64 SrvCmdRun(CSrvCmd *tempc,I64 old_flags)
|
||||
{
|
||||
CSrvCtrl *ctrl=tempc->ctrl;
|
||||
CTask *master;
|
||||
Bool old_preempt=IsPreempt;
|
||||
I64 result,flags=tempc->flags;
|
||||
if (Bt(&flags,SVCf_EXIT_ON_COMPLETE))
|
||||
result=SCR_EXIT;
|
||||
else
|
||||
result=SCR_CONT;
|
||||
switch (tempc->cmd_code) {
|
||||
case SVCT_SPAWN_TASK:
|
||||
QueRem(tempc);
|
||||
LBts(&tempc->flags,SVCf_DISPATCHED);
|
||||
tempc->servant_cpu_num=Gs->num;
|
||||
LBtr(&ctrl->flags,SVCRf_LOCKED);
|
||||
if (tempc->aux_str)
|
||||
tempc->spawned_task=Spawn(tempc->add,tempc->fun_arg,tempc->aux_str,,tempc->aux1,tempc->aux2,tempc->flags);
|
||||
else
|
||||
tempc->spawned_task=Spawn(tempc->add,tempc->fun_arg,"Unnamed",,tempc->aux1,tempc->aux2,tempc->flags);
|
||||
break;
|
||||
case SVCT_CALL:
|
||||
QueRem(tempc);
|
||||
LBts(&tempc->flags,SVCf_DISPATCHED);
|
||||
tempc->servant_cpu_num=Gs->num;
|
||||
LBtr(&ctrl->flags,SVCRf_LOCKED);
|
||||
SetFlags(old_flags);
|
||||
LBtr(&Fs->task_flags,TASKf_IDLE);
|
||||
try
|
||||
tempc->result=(*tempc->add)(tempc->fun_arg);
|
||||
catch
|
||||
Fs->catch_except=TRUE;
|
||||
SetFlags(old_flags);
|
||||
break;
|
||||
case SVCT_EXE_STR:
|
||||
QueRem(tempc);
|
||||
LBts(&tempc->flags,SVCf_DISPATCHED);
|
||||
tempc->servant_cpu_num=Gs->num;
|
||||
LBtr(&ctrl->flags,SVCRf_LOCKED);
|
||||
SetFlags(old_flags);
|
||||
LBtr(&Fs->task_flags,TASKf_IDLE);
|
||||
try
|
||||
tempc->result=ExePutS(tempc->aux_str);
|
||||
catch
|
||||
Fs->catch_except=TRUE;
|
||||
SetFlags(old_flags);
|
||||
break;
|
||||
default:
|
||||
result=SCR_DONE;
|
||||
}
|
||||
if (result) {
|
||||
if (master=tempc->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);
|
||||
LBtr(&master->srv_ctrl.flags,SVCRf_LOCKED);
|
||||
SetFlags(old_flags);
|
||||
}
|
||||
if (Bt(&flags,SVCf_FOCUS_MASTER) &&
|
||||
Bt(&master->task_flags,TASKf_USER))
|
||||
sys_focus_task=master;
|
||||
if (Bt(&flags,SVCf_WAKE_MASTER))
|
||||
Suspend(master,FALSE);
|
||||
}
|
||||
if (Bt(&flags,SVCf_FREE_ON_COMPLETE))
|
||||
SrvCmdDel(tempc);
|
||||
else if (!master) {
|
||||
Cli;
|
||||
while (LBts(&ctrl->flags,SVCRf_LOCKED))
|
||||
Yield;
|
||||
QueIns(tempc,ctrl->last_done);
|
||||
LBts(&tempc->flags,SVCf_DONE);
|
||||
LBtr(&ctrl->flags,SVCRf_LOCKED);
|
||||
SetFlags(old_flags);
|
||||
}
|
||||
}
|
||||
Preempt(old_preempt);
|
||||
return result;
|
||||
}
|
||||
|
||||
I64 SrvCmdsHandler(CTask *task=NULL)
|
||||
{
|
||||
I64 cnt=0,old_flags=GetFlags;
|
||||
CSrvCmd *tempc,*tempc1;
|
||||
if (!task) task=Fs;
|
||||
while (TRUE) {
|
||||
Cli;
|
||||
while (LBts(&task->srv_ctrl.flags,SVCRf_LOCKED))
|
||||
Pause;
|
||||
tempc1=&task->srv_ctrl.next_waiting;
|
||||
tempc=tempc1->next;
|
||||
if (tempc==tempc1)
|
||||
goto sch_done;
|
||||
else
|
||||
switch (SrvCmdRun(tempc,old_flags)) {
|
||||
case SCR_CONT:
|
||||
cnt++;
|
||||
break;
|
||||
case SCR_EXIT:
|
||||
Exit;
|
||||
case SCR_DONE:
|
||||
goto sch_done;
|
||||
}
|
||||
}
|
||||
sch_done:
|
||||
LBtr(&task->srv_ctrl.flags,SVCRf_LOCKED);
|
||||
SetFlags(old_flags);
|
||||
return cnt;
|
||||
}
|
||||
|
||||
I64 Adam(U8 *fmt,...)
|
||||
//Sends text to the adam task which gets
|
||||
//compiled and run.
|
||||
{
|
||||
I64 result;
|
||||
U8 *st=SPrintFJoin(NULL,fmt,argc,argv);
|
||||
Bool old_preempt=Preempt(OFF);
|
||||
CSrvCmd *tempc;
|
||||
if (Fs==adam_task) {
|
||||
tempc=TaskExeStrQue(adam_task,Fs,st,0);
|
||||
SrvCmdsHandler;
|
||||
} else {
|
||||
TaskWait(adam_task);
|
||||
tempc=TaskExeStrQue(adam_task,Fs,st,1<<SVCf_WAKE_MASTER);
|
||||
}
|
||||
Preempt(old_preempt);
|
||||
ScanResult(tempc,&result);
|
||||
Free(st);
|
||||
return result;
|
||||
}
|
||||
|
||||
U0 AdamLog(U8 *fmt,...)
|
||||
//Sends text to the adam task which gets
|
||||
//displayed.
|
||||
{
|
||||
U8 *st=SPrintFJoin(NULL,fmt,argc,argv);
|
||||
if (Fs==adam_task)
|
||||
"" st;
|
||||
else if (!IsSingleUser)
|
||||
Adam("\"%Q\";",st);
|
||||
Free(st);
|
||||
}
|
||||
|
||||
U0 AdamErr(U8 *fmt,...)
|
||||
//Sends text to the adam task which gets
|
||||
//displayed as red and blinking.
|
||||
{
|
||||
U8 *st=SPrintFJoin(NULL,fmt,argc,argv),
|
||||
*st2=MSPrintF("%S%s","ST_ERR",st);
|
||||
if (Fs==adam_task)
|
||||
"" st2;
|
||||
else if (!IsSingleUser)
|
||||
Adam("\"%Q\";",st2);
|
||||
Free(st2);
|
||||
Free(st);
|
||||
}
|
||||
|
||||
U0 XTalk(CTask *task,U8 *fmt,...)
|
||||
//Sends text to another task's input
|
||||
//buffer.
|
||||
{
|
||||
U8 *st=SPrintFJoin(NULL,fmt,argc,argv),
|
||||
*st2=MSPrintF("\"%Q\";",st);
|
||||
TaskTextInputQue(task,0,st2,0);
|
||||
Free(st2);
|
||||
Free(st);
|
||||
}
|
||||
|
||||
U0 XTalkWait(CTask *task,U8 *fmt,...)
|
||||
{
|
||||
U8 *st=SPrintFJoin(NULL,fmt,argc,argv),
|
||||
*st2=MSPrintF("\"%Q\";",st);
|
||||
TaskTextInputQue(task,0,st2,0);
|
||||
Free(st2);
|
||||
Free(st);
|
||||
TaskWait(task);
|
||||
}
|
||||
|
||||
U0 Auto(U8 *fmt,...)
|
||||
//Sends text to one's own input buffer
|
||||
{
|
||||
U8 *st=SPrintFJoin(NULL,fmt,argc,argv),
|
||||
*st2=MSPrintF("\"%Q\";",st);
|
||||
if (Bt(&Fs->task_flags,TASKf_INPUT_FILTER_TASK))
|
||||
ExePutS(st2);
|
||||
else
|
||||
TaskTextInputQue(Fs,0,st2,1<<SVCf_HIGHEST_PRIORITY);
|
||||
Free(st2);
|
||||
Free(st);
|
||||
}
|
||||
|
||||
I64 SrvUser(U8 *fmt,...)
|
||||
//Spawns a visible task and sends text
|
||||
//which gets compiled and run.
|
||||
{
|
||||
U8 *st=SPrintFJoin(NULL,fmt,argc,argv);
|
||||
I64 result=0;
|
||||
CSrvCmd *tempc;
|
||||
CTask *task=Spawn(&SrvUserCmdLine,NULL,"Servant",,Fs);
|
||||
Fs->popup_task=task;
|
||||
tempc=TaskExeStrQue(task,Fs,st,1<<SVCf_WAKE_MASTER|1<<SVCf_FOCUS_MASTER);
|
||||
ScanResult(tempc,&result);
|
||||
Fs->popup_task=NULL;
|
||||
Kill(task,FALSE);
|
||||
Free(st);
|
||||
return result;
|
||||
}
|
||||
|
||||
U0 AutoStr(U8 *fmt,...)
|
||||
//Sends text in the nature of an AutoFile to one's
|
||||
//own input buffer.
|
||||
{
|
||||
U8 *st=SPrintFJoin(NULL,fmt,argc,argv);
|
||||
if (Bt(&Fs->task_flags,TASKf_INPUT_FILTER_TASK))
|
||||
ExePutS(st);
|
||||
else
|
||||
TaskTextInputQue(Fs,0,st,1<<SVCf_HIGHEST_PRIORITY);
|
||||
Free(st);
|
||||
}
|
||||
|
||||
U0 AutoFile(U8 *filename)
|
||||
{
|
||||
U8 *name2=DftExt(filename,"AUT.Z");
|
||||
if (Bt(&Fs->task_flags,TASKf_INPUT_FILTER_TASK))
|
||||
ExeFile(name2);
|
||||
else
|
||||
AutoStr("%F",name2);
|
||||
Free(name2);
|
||||
}
|
||||
|
||||
|
||||
//This sends text of an AutoFile nature to a
|
||||
//task's input buffer.
|
||||
U0 XTalkStr(CTask *task,U8 *fmt,...)
|
||||
{
|
||||
U8 *st=SPrintFJoin(NULL,fmt,argc,argv);
|
||||
TaskTextInputQue(task,0,st,0);
|
||||
Free(st);
|
||||
}
|
||||
|
||||
U0 XTalkStrWait(CTask *task,U8 *fmt,...)
|
||||
{
|
||||
U8 *st=SPrintFJoin(NULL,fmt,argc,argv);
|
||||
TaskTextInputQue(task,0,st,0);
|
||||
Free(st);
|
||||
TaskWait(task);
|
||||
}
|
||||
+24
-30
@@ -535,7 +535,7 @@ U0 GetOutOfDollar()
|
||||
if (sys_raw_dc_flags&RDCF_IN_DOLLAR)
|
||||
'$$';
|
||||
} else {
|
||||
if (fp_doc_cur && (doc=(*fp_doc_cur)(Fs)) && doc->flags&DOCF_IN_DOLLAR)
|
||||
if (fp_doc_put && (doc=(*fp_doc_put)(Fs)) && doc->flags&DOCF_IN_DOLLAR)
|
||||
'$$';
|
||||
}
|
||||
}
|
||||
@@ -589,12 +589,12 @@ Bool YorN()
|
||||
I64 ch;
|
||||
"(y or n)? ";
|
||||
while (TRUE) {
|
||||
ch=ToUpper(GetChar(NULL,FALSE));
|
||||
ch=ToUpper(GetChar(,FALSE));
|
||||
if (ch=='Y') {
|
||||
"$$FU$$YES$$FG$$\n";
|
||||
"$$PT$$YES$$FG$$\n";
|
||||
return TRUE;
|
||||
} else if (ch=='N') {
|
||||
"$$FU$$NO$$FG$$\n";
|
||||
"$$PT$$NO$$FG$$\n";
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
@@ -604,19 +604,7 @@ Bool PressAKey()
|
||||
{
|
||||
I64 ch;
|
||||
PutDefine("ST_PRESS_A_KEY");
|
||||
ch=GetChar(NULL,FALSE);
|
||||
if (ch==CH_SHIFT_ESC || ch==CH_ESC)
|
||||
return FALSE;
|
||||
else
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Bool ExitAllApplications()
|
||||
{
|
||||
I64 ch;
|
||||
PutDefine("ST_EXIT_ALL_APPLICATIONS");
|
||||
PutDefine("ST_PRESS_A_KEY");
|
||||
ch=GetChar(NULL,FALSE);
|
||||
ch=GetChar(,FALSE);
|
||||
if (ch==CH_SHIFT_ESC || ch==CH_ESC)
|
||||
return FALSE;
|
||||
else
|
||||
@@ -1019,7 +1007,7 @@ I64 A2I(U8 *st,I64 radix=10,U8 **_end_ptr=NULL)
|
||||
Bool neg=FALSE;
|
||||
U8 ch;
|
||||
I64 result=0,k=0;
|
||||
if (radix<2||radix>36) return 0;
|
||||
if (!(2<=radix<=36)) return 0;
|
||||
while (Bt(white_space_bitmap,*st))
|
||||
st++;
|
||||
if (*st=='-') {
|
||||
@@ -1060,7 +1048,10 @@ ai_skip:
|
||||
k++;
|
||||
}
|
||||
if (_end_ptr) *_end_ptr=st-1;
|
||||
return neg ? -result:result;
|
||||
if (neg)
|
||||
return -result;
|
||||
else
|
||||
return result;
|
||||
}
|
||||
|
||||
U0 GetFFlags(U8 *f,U8 *lst,U8 *st)
|
||||
@@ -1187,7 +1178,7 @@ U8 *MSPrintFQ(U8 *ptr,Bool dollar_flag)
|
||||
SPrintFPutChar(_dst,'\\',_buf);
|
||||
SPrintFPutChar(_dst,'n',_buf);
|
||||
break;
|
||||
case CH_CARRIAGE_RETURN:
|
||||
case '\r':
|
||||
SPrintFPutChar(_dst,'\\',_buf);
|
||||
SPrintFPutChar(_dst,'r',_buf);
|
||||
break;
|
||||
@@ -1234,7 +1225,7 @@ U8 *MSPrintFq(U8 *ptr)
|
||||
ptr++;
|
||||
break;
|
||||
case 'r':
|
||||
SPrintFPutChar(_dst,CH_CARRIAGE_RETURN,_buf);
|
||||
SPrintFPutChar(_dst,'\r',_buf);
|
||||
ptr++;
|
||||
break;
|
||||
case '"':
|
||||
@@ -1335,7 +1326,7 @@ U8 *sprintf_neg_powers_lets=
|
||||
#define SLOP 8
|
||||
|
||||
U8 *SPrintFJoin(U8 *dst,U8 *src,I64 argc,I64 *argv)
|
||||
{ //$LK,"printF codes","FA:::/TempleOS/Doc/Differences.TXT,PrintF_Codes"$
|
||||
{ //$LK,"printF codes","FA:::/TempleOS/Doc/HolyC.TXT,PrintF_Codes"$
|
||||
/*
|
||||
In float formatting, do not exceed 18-digits
|
||||
before or after the decimal point
|
||||
@@ -2058,7 +2049,7 @@ U8 *SPrintF(U8 *dst,U8 *fmt,...)
|
||||
}
|
||||
|
||||
/*
|
||||
A2CDate()
|
||||
A2Date()
|
||||
This routine recognizes the following formats:
|
||||
1) "*+nnnn" "*-nnnn"
|
||||
2) mm/dd
|
||||
@@ -2076,7 +2067,7 @@ the start of mon for seven days before
|
||||
today.
|
||||
|
||||
*/
|
||||
CDate A2CDate(U8 *_src)
|
||||
CDate A2Date(U8 *_src)
|
||||
//ASCII date to CDate
|
||||
{
|
||||
CDate result=0;
|
||||
@@ -2106,7 +2097,7 @@ CDate A2CDate(U8 *_src)
|
||||
p1++;
|
||||
if (*p1=='+' || *p1=='-')
|
||||
result.date=A2I(p1,10,&p1);
|
||||
result+=GetCurTimeCDate+local_time_offset;
|
||||
result+=GetCurTimeDate+local_time_offset;
|
||||
} else {
|
||||
StrFirstRem(p1,"/",v); //Put mon into v
|
||||
ds.mon=A2I(v);
|
||||
@@ -2118,10 +2109,10 @@ CDate A2CDate(U8 *_src)
|
||||
ds.year+=2000;
|
||||
} else {
|
||||
ds.day_of_mon=A2I(p1,10,&p1);
|
||||
CDate2CDateStruct(&ds1,GetCurTimeCDate+local_time_offset);
|
||||
Date2DateStruct(&ds1,GetCurTimeDate+local_time_offset);
|
||||
ds.year=ds1.year;
|
||||
}
|
||||
result=CDateStruct2CDate(&ds);
|
||||
result=DateStruct2Date(&ds);
|
||||
}
|
||||
if (*p1==')') p1++;
|
||||
|
||||
@@ -2220,7 +2211,10 @@ to avoid this.
|
||||
}
|
||||
a2f_end:
|
||||
if (_end_ptr) *_end_ptr=src-1;
|
||||
return neg ? -d:d;
|
||||
if (neg)
|
||||
return -d;
|
||||
else
|
||||
return d;
|
||||
}
|
||||
|
||||
U8 *GetFJoin(U8 *src,U8 *fmt,I64i argc,I64i *argv)
|
||||
@@ -2340,7 +2334,7 @@ U8 *GetFJoin(U8 *src,U8 *fmt,I64i argc,I64i *argv)
|
||||
if (cur_arg>=argc)
|
||||
throw(EXCEPT_GETF,1);
|
||||
i_ptr=argv[cur_arg++];
|
||||
*i_ptr=A2CDate(buf);
|
||||
*i_ptr=A2Date(buf);
|
||||
break;
|
||||
}
|
||||
Free(buf);
|
||||
@@ -2361,7 +2355,7 @@ U8 *GetF(U8 *src,U8 *fmt,...)
|
||||
|
||||
|
||||
U0 PrintF(U8 *fmt,...)
|
||||
{//$LK,"PrintF Extended Codes","FA:::/TempleOS/Doc/Differences.TXT,PrintF_Codes"$
|
||||
{//$LK,"PrintF Extended Codes","FA:::/TempleOS/Doc/HolyC.TXT,PrintF_Codes"$
|
||||
//See $LK,"SPrintFJoin","MN:SPrintFJoin"$()
|
||||
U8 *buf=SPrintFJoin(NULL,fmt,argc,argv);
|
||||
"" buf;
|
||||
|
||||
+41
-48
@@ -181,12 +181,7 @@ I64 TaskInit(CTask *task,I64 stk_size)
|
||||
task->last_child_task=
|
||||
(&task->next_child_task)(U8 *)-offset(CTask.next_sibling_task);
|
||||
|
||||
task->next_doc=
|
||||
task->last_doc=
|
||||
(&task->next_doc)(U8 *)-offset(CDoc.next_doc);
|
||||
|
||||
QueInit(&task->next_servant_cmd);
|
||||
QueInit(&task->next_master_cmd);
|
||||
SrvCtrlInit(&task->srv_ctrl);
|
||||
QueInit(&task->next_lex);
|
||||
QueInit(&task->next_except);
|
||||
QueInit(&task->next_ctrl);
|
||||
@@ -215,8 +210,10 @@ I64 TaskInit(CTask *task,I64 stk_size)
|
||||
task->rsp=(&temps->stk_base)(U8 *)+temps->stk_size;
|
||||
|
||||
task->answers_displayed=1; //from 0-8
|
||||
task->text_attr =WHITE<<4+BLUE;
|
||||
task->border_attr=WHITE<<4+LTBLUE;
|
||||
task->text_attr =TERM_ATTR_TEXT;
|
||||
task->border_attr=TERM_ATTR_BORDER;
|
||||
task->border_src =BDS_CONST;
|
||||
task->title_src =TTS_CONST;
|
||||
task->win_left =1;
|
||||
task->win_right =text_cols-2;
|
||||
task->win_top =1;
|
||||
@@ -227,13 +224,17 @@ I64 TaskInit(CTask *task,I64 stk_size)
|
||||
|
||||
CTask *Spawn(U0 (*fp_start_add)(U8 *data),U8 *data=NULL,
|
||||
U8 *task_name=NULL,
|
||||
I64 target_cpu=-1, //-1 means current CPU
|
||||
CTask *parent=NULL, //NULL means adam
|
||||
I64 stk_size=0, //0=default
|
||||
I64 flags=SPAWNF_ADD_TO_QUE)
|
||||
I64 flags=1<<SVCf_ADD_TO_QUE)
|
||||
{
|
||||
//We alloc from code heap so addr will be short
|
||||
//Could be allocated off of data heap
|
||||
CTask *task=CAlloc(sizeof(CTask),adam_task->code_heap);
|
||||
CTask *task;
|
||||
if (target_cpu>=0)
|
||||
return SpawnQue(fp_start_add,data,task_name,target_cpu,parent,stk_size,flags);
|
||||
task=CAlloc(sizeof(CTask),adam_task->code_heap);
|
||||
task->task_signature=TASK_SIGNATURE_VAL;
|
||||
if (!task_name) task_name="Unnamed Task";
|
||||
if (!parent) parent=Gs->seth_task;
|
||||
@@ -252,11 +253,12 @@ CTask *Spawn(U0 (*fp_start_add)(U8 *data),U8 *data=NULL,
|
||||
task->rsp(U8 *)-=8;
|
||||
*task->rsp=&Exit;
|
||||
task->hash_table->next=parent->hash_table;
|
||||
MemCpy(task->task_title,task_name,TASK_TITLE_LEN+1);
|
||||
MemCpy(task->task_name,task_name,TASK_NAME_LEN+1);
|
||||
StrCpy(task->task_title,task->task_name);
|
||||
task->title_src=TTS_TASK_NAME;
|
||||
PushFD;
|
||||
Cli;
|
||||
if (flags&SPAWNF_ADD_TO_QUE) {
|
||||
if (Bt(&flags,SVCf_ADD_TO_QUE)) {
|
||||
TaskQueInsChild(task);
|
||||
TaskQueIns(task);
|
||||
}
|
||||
@@ -264,13 +266,12 @@ CTask *Spawn(U0 (*fp_start_add)(U8 *data),U8 *data=NULL,
|
||||
return task;
|
||||
}
|
||||
|
||||
U0 ServantTaskCont()
|
||||
U0 SrvTaskCont()
|
||||
{
|
||||
FlushMsgs;
|
||||
while (TRUE) {
|
||||
if (ServantCmdsHandler)
|
||||
if (!Bt(&Fs->task_flags,TASKf_LOCK_TITLE))
|
||||
MemCpy(Fs->task_title,Fs->task_name,TASK_NAME_LEN+1);
|
||||
if (SrvCmdsHandler && Fs->title_src==TTS_TASK_NAME)
|
||||
MemCpy(Fs->task_title,Fs->task_name,TASK_NAME_LEN+1);
|
||||
FlushMsgs;
|
||||
LBts(&Fs->task_flags,TASKf_IDLE);
|
||||
LBts(&Fs->task_flags,TASKf_AWAITING_MSG);
|
||||
@@ -300,8 +301,6 @@ U0 TaskInitExt(Bool from_dbg=FALSE)
|
||||
return;
|
||||
if (!from_dbg) {
|
||||
LBts(&Fs->display_flags,DISPLAYf_HAS_CLOSE_WIN);
|
||||
Fs->text_attr =WHITE<<4+BLUE;
|
||||
Fs->border_attr=WHITE<<4+LTBLUE;
|
||||
Fs->win_top =13;
|
||||
Fs->win_bottom=text_rows-2;
|
||||
TaskDerivedValsUpdate;
|
||||
@@ -312,21 +311,23 @@ U0 TaskInitExt(Bool from_dbg=FALSE)
|
||||
|
||||
I64 ExeCmdLine(CLex *lx)
|
||||
{
|
||||
I64 result=0,i,type;
|
||||
U8 *ptr,*ptr2,*ptr3,*code;
|
||||
I64 result=0,i,type,old_title_src=Fs->title_src;
|
||||
U8 *ptr,*ptr2,*ptr3,*code,*old_task_title=StrNew(Fs->task_title);
|
||||
F64 t0;
|
||||
CDocEntry *doc_e;
|
||||
CDoc *doc;
|
||||
if (Fs->title_src!=TTS_LOCKED_CONST)
|
||||
Fs->title_src=TTS_CUR_LEX;
|
||||
while (lx->token &&
|
||||
(lx->token!='}' || !(lx->flags & LF_EXE_BLK)) ) {
|
||||
if (!Bt(&Fs->task_flags,TASKf_LOCK_TITLE)) {
|
||||
if (Fs->title_src==TTS_CUR_LEX) {
|
||||
ptr2=&Fs->task_title;
|
||||
ptr3=ptr2+TASK_TITLE_LEN;
|
||||
if (lx->cur_lfn->flags & LFSF_IS_DOC) {
|
||||
doc_e=lx->cur_lfn->line_start;
|
||||
doc_e=lx->cur_lfn->cur_entry;
|
||||
doc=lx->cur_lfn->doc;
|
||||
while (doc_e!=doc && ptr2<ptr3) {
|
||||
switch (doc_e->type_u8 && ptr2<ptr3) {
|
||||
switch (doc_e->type_u8) {
|
||||
case DOCT_TEXT:
|
||||
ptr=doc_e->tag;
|
||||
while (*ptr && ptr2<ptr3)
|
||||
@@ -339,8 +340,9 @@ I64 ExeCmdLine(CLex *lx)
|
||||
}
|
||||
doc_e=doc_e->next;
|
||||
}
|
||||
if (ptr2<ptr3) *ptr2=0;
|
||||
} else
|
||||
if (ptr=lx->cur_lfn->line_start)
|
||||
if ((ptr=lx->cur_lfn->line_start) && *ptr)
|
||||
MemCpy(ptr2,ptr,TASK_TITLE_LEN);
|
||||
}
|
||||
lx->flags&=~LF_HAS_MISC_DATA;
|
||||
@@ -362,6 +364,11 @@ I64 ExeCmdLine(CLex *lx)
|
||||
Free(code);
|
||||
}
|
||||
}
|
||||
if (Fs->title_src!=TTS_LOCKED_CONST) {
|
||||
Fs->title_src=old_title_src;
|
||||
StrCpy(Fs->task_title,old_task_title);
|
||||
}
|
||||
Free(old_task_title);
|
||||
if (lx->flags&LF_JUST_LOAD) {
|
||||
if (lx->error_cnt)
|
||||
return FALSE;
|
||||
@@ -386,9 +393,7 @@ U0 UserTaskCont()
|
||||
QueRem(lx);
|
||||
LexDel(lx);
|
||||
} catch {
|
||||
doc=Fs->last_doc;
|
||||
if (doc!=(&Fs->next_doc)(U8 *)-offset(CDoc.next_doc) &&
|
||||
doc->doc_in_que_signature==DOC_IN_QUE_SIGNATURE_VAL)
|
||||
if ((doc=Fs->put_doc) && doc->doc_signature==DOC_SIGNATURE_VAL)
|
||||
DocUnlock(doc);
|
||||
CatchAll;
|
||||
}
|
||||
@@ -408,14 +413,14 @@ U0 UserCmdLine(I64 dummy=0)
|
||||
UserTaskCont;
|
||||
}
|
||||
|
||||
U0 ServantUserCmdLine(I64 dummy=0)
|
||||
U0 SrvUserCmdLine(I64 dummy=0)
|
||||
{
|
||||
nounusedwarn dummy;
|
||||
LBts(&Fs->task_flags,TASKf_USER);
|
||||
TaskInitExt;
|
||||
if (HashFind("ServantStartUp",adam_task->hash_table,HTT_FUN))
|
||||
CallExtStr("ServantStartUp");
|
||||
ServantTaskCont;
|
||||
if (HashFind("SrvStartUp",adam_task->hash_table,HTT_FUN))
|
||||
CallExtStr("SrvStartUp");
|
||||
SrvTaskCont;
|
||||
}
|
||||
|
||||
CTask *SpawnUser(U8 *fmt=NULL,...)
|
||||
@@ -443,7 +448,6 @@ U0 TaskFinishOff(CTask *task)
|
||||
I64 TaskEnd()
|
||||
{ //called with irq's off
|
||||
CTask *task=Fs,*tempt,*tempt1;
|
||||
CTaskCmd *tempc,*tempc1,*tempc2;
|
||||
if (task==sys_task_being_screen_updated) {
|
||||
LBts(&task->task_flags,TASKf_KILL_TASK);
|
||||
return task->next_task;
|
||||
@@ -483,23 +487,11 @@ I64 TaskEnd()
|
||||
|
||||
while (LBts(&task->locked_flags,TASKLf_TASK_LOCK))
|
||||
Pause;
|
||||
tempc1=&task->next_servant_cmd;
|
||||
tempc=tempc1->next;
|
||||
while (tempc!=tempc1) {
|
||||
tempc2=tempc->next;
|
||||
Free(tempc->data);
|
||||
Free(tempc);
|
||||
tempc=tempc2;
|
||||
}
|
||||
while (LBts(&task->srv_ctrl.flags,SVCRf_LOCKED))
|
||||
Pause;
|
||||
|
||||
tempc1=&task->next_master_cmd;
|
||||
tempc=tempc1->next;
|
||||
while (tempc!=tempc1) {
|
||||
tempc2=tempc->next;
|
||||
Free(tempc->data);
|
||||
Free(tempc);
|
||||
tempc=tempc2;
|
||||
}
|
||||
SrvCmdQueDel(&task->srv_ctrl.next_waiting);
|
||||
SrvCmdQueDel(&task->srv_ctrl.next_done);
|
||||
|
||||
if (IsRaw)
|
||||
VGAFlush;
|
||||
@@ -528,6 +520,7 @@ I64 TaskEnd()
|
||||
tempt =task->next_task; //save to return
|
||||
TaskQueRem(task);
|
||||
|
||||
LBtr(&task->srv_ctrl.flags,SVCRf_LOCKED);
|
||||
LBtr(&task->locked_flags,TASKLf_TASK_LOCK);
|
||||
|
||||
if (sys_winmgr_task) {
|
||||
|
||||
@@ -1,422 +0,0 @@
|
||||
U0 TaskRstAwaitingMsg(CTask *task=NULL)
|
||||
{ //Pop-ups get parent messages so wake-up our pop-ups if we got a msg.
|
||||
Bool old_preempt=Preempt(OFF);
|
||||
if (!task) task=Fs;
|
||||
if (TaskValidate(task)) {
|
||||
LBtr(&task->task_flags,TASKf_AWAITING_MSG);
|
||||
while (task=task->popup_task)
|
||||
if (TaskValidate(task))
|
||||
LBtr(&task->task_flags,TASKf_AWAITING_MSG);
|
||||
else
|
||||
break;
|
||||
}
|
||||
Preempt(old_preempt);
|
||||
}
|
||||
|
||||
CTaskCmd *TaskRqstQue(CTask *servant,CTask *master,
|
||||
U8 *data,I64 flags)
|
||||
{
|
||||
CTaskCmd *result;
|
||||
if (!data || !TaskValidate(servant) ||
|
||||
master && !TaskValidate(master) ||
|
||||
servant->popup_task && !Bt(&servant->task_flags,TASKf_FILTER_INPUT))
|
||||
return NULL;
|
||||
result=AMAlloc(sizeof(CTaskCmd));
|
||||
result->master_task=master;
|
||||
result->cmd_code=TASKCT_EXECUTE_STR;
|
||||
result->flags=flags;
|
||||
result->data=AStrNew(data);
|
||||
result->result=NULL;
|
||||
|
||||
PushFD;
|
||||
Cli;
|
||||
while (LBts(&servant->locked_flags,TASKLf_TASK_LOCK))
|
||||
Pause;
|
||||
if (!TaskValidate(servant)) {
|
||||
PopFD;
|
||||
Free(result->data);
|
||||
Free(result);
|
||||
return NULL;
|
||||
} else {
|
||||
LBtr(&servant->task_flags,TASKf_IDLE);
|
||||
TaskRstAwaitingMsg(servant);
|
||||
QueIns(result,servant->last_servant_cmd);
|
||||
LBtr(&servant->locked_flags,TASKLf_TASK_LOCK);
|
||||
if (Bt(&flags,TASKCf_WAKE_MASTER)) {
|
||||
Suspend(master);
|
||||
Yield;
|
||||
}
|
||||
}
|
||||
PopFD;
|
||||
return result;
|
||||
}
|
||||
|
||||
CTaskCmd *TextInputQue(CTask *servant,CTask *master,
|
||||
U8 *data,I64 flags)
|
||||
{
|
||||
CTaskCmd *result;
|
||||
Bool old_preempt=Preempt(OFF);
|
||||
CTask *task;
|
||||
if (!data || !TaskValidate(servant) ||
|
||||
master && !TaskValidate(master) ||
|
||||
servant->popup_task && !Bt(&servant->task_flags,TASKf_FILTER_INPUT)) {
|
||||
Preempt(old_preempt);
|
||||
return NULL;
|
||||
}
|
||||
result=AMAlloc(sizeof(CTaskCmd));
|
||||
result->master_task=master; //in case somebody cares
|
||||
result->cmd_code=TASKCT_TEXT_INPUT;
|
||||
result->flags=flags;
|
||||
result->data=AStrNew(data);
|
||||
result->result=NULL;
|
||||
|
||||
PushFD;
|
||||
if (flags&1<<TASKCf_HIGHEST_PRIORITY ||
|
||||
servant->next_input_filter_task==servant) {
|
||||
task=Spawn(&InputFilterTask,NULL,
|
||||
"Input Filter",servant);
|
||||
Cli;
|
||||
task->next_input_filter_task=servant->next_input_filter_task;
|
||||
task->last_input_filter_task=servant;
|
||||
servant->next_input_filter_task=task;
|
||||
task->next_input_filter_task->last_input_filter_task=task;
|
||||
} else
|
||||
task=servant->next_input_filter_task;
|
||||
Cli;
|
||||
while (LBts(&task->locked_flags,TASKLf_TASK_LOCK))
|
||||
Pause;
|
||||
if (!TaskValidate(task)) {
|
||||
Free(result->data);
|
||||
Free(result);
|
||||
result=NULL;
|
||||
} else {
|
||||
LBtr(&task->task_flags,TASKf_IDLE);
|
||||
TaskRstAwaitingMsg(task);
|
||||
QueIns(result,task->last_servant_cmd);
|
||||
LBtr(&task->locked_flags,TASKLf_TASK_LOCK);
|
||||
}
|
||||
PopFD;
|
||||
Preempt(old_preempt);
|
||||
return result;
|
||||
}
|
||||
|
||||
CTaskCmd *QueMsg(CTask *_servant,CTask *master,
|
||||
I64 msg_code,I64 p1,I64 p2,I64 flags)
|
||||
{
|
||||
CTaskCmd *tempc1,*tempc;
|
||||
CTask *servant=_servant;
|
||||
if (!TaskValidate(servant) ||
|
||||
master && !TaskValidate(master)||
|
||||
servant->popup_task && !Bt(&servant->task_flags,TASKf_FILTER_INPUT))
|
||||
return NULL;
|
||||
tempc=AMAlloc(sizeof(CTaskCmd));
|
||||
tempc->master_task=master;
|
||||
tempc->cmd_code=TASKCT_MSG;
|
||||
tempc->msg_code=AbsI64(msg_code); //negative means do a down and up
|
||||
tempc->p1=p1;
|
||||
tempc->p2=p2;
|
||||
tempc->flags=flags;
|
||||
tempc->data=NULL;
|
||||
tempc->result=NULL;
|
||||
PushFD;
|
||||
if (Bt(&sys_semas[SYS_SEMA_RECORD_MACRO],0) &&
|
||||
servant!=sys_macro_util_task &&
|
||||
msg_code==MSG_KEY_DOWN) {
|
||||
tempc1=AMAllocIdentical(tempc);
|
||||
Cli;
|
||||
QueIns(tempc1,sys_macro_root.last);
|
||||
}
|
||||
Cli;
|
||||
while (Bt(&servant->task_flags,TASKf_FILTER_INPUT) &&
|
||||
!Bt(&flags,TASKCf_DONT_FILTER))
|
||||
servant=servant->next_input_filter_task;
|
||||
while (LBts(&servant->locked_flags,TASKLf_TASK_LOCK))
|
||||
Pause;
|
||||
if (!TaskValidate(servant)) {
|
||||
Free(tempc);
|
||||
tempc=NULL;
|
||||
} else {
|
||||
LBtr(&servant->task_flags,TASKf_IDLE);
|
||||
TaskRstAwaitingMsg(servant);
|
||||
QueIns(tempc,servant->last_servant_cmd);
|
||||
LBtr(&servant->locked_flags,TASKLf_TASK_LOCK);
|
||||
}
|
||||
PopFD;
|
||||
if (msg_code<0) //Down-Up
|
||||
QueMsg(_servant,master,-msg_code+1,p1,p2,flags);
|
||||
return tempc;
|
||||
}
|
||||
|
||||
Bool GetRqstResult(CTaskCmd *rqst=NULL,I64 *_result=NULL)
|
||||
{
|
||||
CTaskCmd *tempc,*tempc1;
|
||||
PushFD;
|
||||
Cli;
|
||||
while (LBts(&Fs->locked_flags,TASKLf_TASK_LOCK))
|
||||
Pause;
|
||||
tempc1=&Fs->next_master_cmd;
|
||||
tempc=tempc1->next;
|
||||
while (tempc!=tempc1) {
|
||||
if (!rqst || rqst==tempc) {
|
||||
QueRem(tempc);
|
||||
LBtr(&Fs->locked_flags,TASKLf_TASK_LOCK);
|
||||
PopFD;
|
||||
if (_result)
|
||||
*_result=tempc->result;
|
||||
Free(tempc->data);
|
||||
Free(tempc);
|
||||
return TRUE;
|
||||
}
|
||||
tempc=tempc->next;
|
||||
}
|
||||
LBtr(&Fs->locked_flags,TASKLf_TASK_LOCK);
|
||||
PopFD;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
U0 TaskWait(CTask *task=NULL)
|
||||
{
|
||||
CTask *task1;
|
||||
CTaskCmd *tempc;
|
||||
if (!task) task=Fs;
|
||||
if (TaskValidate(task)) {
|
||||
PushFD;
|
||||
Cli;
|
||||
while (TRUE) {
|
||||
task1=task->last_input_filter_task;
|
||||
tempc=&task1->next_servant_cmd;
|
||||
if (TaskValidate(task1) && tempc==*tempc &&
|
||||
(task1==Fs || Bt(&task1->task_flags,TASKf_IDLE)))
|
||||
break;
|
||||
Yield;
|
||||
}
|
||||
PopFD;
|
||||
}
|
||||
}
|
||||
|
||||
U0 PostMsg(CTask *task,I64 msg_code,I64 p1,I64 p2,I64 flags=0)
|
||||
{
|
||||
if (TaskValidate(task)) {
|
||||
if (Bt(&task->task_flags,TASKf_INPUT_FILTER_TASK))
|
||||
QueMsg(task->last_input_filter_task,NULL,msg_code,p1,p2,
|
||||
flags| 1<<TASKCf_DONT_FILTER);
|
||||
else
|
||||
QueMsg(task,NULL,msg_code,p1,p2,flags);
|
||||
}
|
||||
}
|
||||
|
||||
U0 SendMsg(CTask *task,I64 msg_code,I64 p1,I64 p2,I64 flags=0)
|
||||
{
|
||||
PostMsg(task,msg_code,p1,p2,flags);
|
||||
TaskWait(task);
|
||||
}
|
||||
|
||||
U0 Msg(I64 msg_code,I64 p1,I64 p2,I64 flags=0)
|
||||
{
|
||||
PostMsg(Fs,msg_code,p1,p2,flags);
|
||||
}
|
||||
|
||||
I64 ServantCmdsHandler(CTask *task=NULL)
|
||||
{
|
||||
I64 cnt=0,old_flags=GetFlags;
|
||||
CTaskCmd *tempc,*tempc1;
|
||||
CTask *master;
|
||||
if (!task) task=Fs;
|
||||
start_over:
|
||||
Cli;
|
||||
while (LBts(&task->locked_flags,TASKLf_TASK_LOCK))
|
||||
Pause;
|
||||
tempc1=&task->next_servant_cmd;
|
||||
tempc=tempc1->next;
|
||||
while (tempc!=tempc1) {
|
||||
tempc=tempc1->next;
|
||||
if (tempc->cmd_code==TASKCT_EXECUTE_STR ||
|
||||
tempc->cmd_code==TASKCT_EXECUTE_FILE) {
|
||||
cnt++;
|
||||
QueRem(tempc);
|
||||
LBtr(&task->locked_flags,TASKLf_TASK_LOCK);
|
||||
SetFlags(old_flags);
|
||||
try {
|
||||
if (tempc->cmd_code==TASKCT_EXECUTE_STR)
|
||||
tempc->result=ExePutS(tempc->data,sys_temp_filename);
|
||||
else
|
||||
tempc->result=ExeFile(tempc->data);
|
||||
} catch
|
||||
Fs->catch_except=TRUE;
|
||||
if (master=tempc->master_task) {
|
||||
if (!Bt(&tempc->flags,TASKCf_EXIT_ON_COMPLETE)) {
|
||||
Cli;
|
||||
while (LBts(&master->locked_flags,TASKLf_TASK_LOCK))
|
||||
Pause;
|
||||
QueIns(tempc,master->last_master_cmd);
|
||||
LBtr(&master->locked_flags,TASKLf_TASK_LOCK);
|
||||
SetFlags(old_flags);
|
||||
}
|
||||
if (Bt(&tempc->flags,TASKCf_FOCUS_MASTER) &&
|
||||
Bt(&master->task_flags,TASKf_USER))
|
||||
sys_focus_task=master;
|
||||
if (Bt(&tempc->flags,TASKCf_WAKE_MASTER))
|
||||
Suspend(master,FALSE);
|
||||
if (!Bt(&tempc->flags,TASKCf_EXIT_ON_COMPLETE))
|
||||
goto start_over;
|
||||
else {
|
||||
Free(tempc->data);
|
||||
Free(tempc);
|
||||
Exit;
|
||||
}
|
||||
} else {
|
||||
if (!Bt(&tempc->flags,TASKCf_EXIT_ON_COMPLETE)) {
|
||||
Free(tempc->data);
|
||||
Free(tempc);
|
||||
goto start_over;
|
||||
} else {
|
||||
Free(tempc->data);
|
||||
Free(tempc);
|
||||
Exit;
|
||||
}
|
||||
}
|
||||
} else
|
||||
break;
|
||||
}
|
||||
LBtr(&task->locked_flags,TASKLf_TASK_LOCK);
|
||||
SetFlags(old_flags);
|
||||
return cnt;
|
||||
}
|
||||
|
||||
I64 Adam(U8 *fmt,...)
|
||||
//Sends text to the adam task which gets
|
||||
//compiled and run.
|
||||
{
|
||||
I64 result;
|
||||
U8 *st=SPrintFJoin(NULL,fmt,argc,argv);
|
||||
Bool old_preempt=Preempt(OFF);
|
||||
CTaskCmd *tempc;
|
||||
if (Fs==adam_task) {
|
||||
tempc=TaskRqstQue(adam_task,Fs,st,0);
|
||||
ServantCmdsHandler;
|
||||
} else {
|
||||
TaskWait(adam_task);
|
||||
tempc=TaskRqstQue(adam_task,Fs,st,1<<TASKCf_WAKE_MASTER);
|
||||
}
|
||||
Preempt(old_preempt);
|
||||
GetRqstResult(tempc,&result);
|
||||
Free(st);
|
||||
return result;
|
||||
}
|
||||
|
||||
U0 AdamLog(U8 *fmt,...)
|
||||
//Sends text to the adam task which gets
|
||||
//displayed.
|
||||
{
|
||||
U8 *st=SPrintFJoin(NULL,fmt,argc,argv);
|
||||
if (Fs==adam_task)
|
||||
"" st;
|
||||
else if (!IsSingleUser)
|
||||
Adam("\"%Q\";",st);
|
||||
Free(st);
|
||||
}
|
||||
|
||||
U0 AdamErr(U8 *fmt,...)
|
||||
//Sends text to the adam task which gets
|
||||
//displayed as red and blinking.
|
||||
{
|
||||
U8 *st=SPrintFJoin(NULL,fmt,argc,argv),
|
||||
*st2=MSPrintF("%S%s","ST_ERR",st);
|
||||
if (Fs==adam_task)
|
||||
"" st2;
|
||||
else if (!IsSingleUser)
|
||||
Adam("\"%Q\";",st2);
|
||||
Free(st2);
|
||||
Free(st);
|
||||
}
|
||||
|
||||
U0 XTalk(CTask *task,U8 *fmt,...)
|
||||
//Sends text to another task's input
|
||||
//buffer.
|
||||
{
|
||||
U8 *st=SPrintFJoin(NULL,fmt,argc,argv),
|
||||
*st2=MSPrintF("\"%Q\";",st);
|
||||
TextInputQue(task,0,st2,0);
|
||||
Free(st2);
|
||||
Free(st);
|
||||
}
|
||||
|
||||
U0 XTalkWait(CTask *task,U8 *fmt,...)
|
||||
{
|
||||
U8 *st=SPrintFJoin(NULL,fmt,argc,argv),
|
||||
*st2=MSPrintF("\"%Q\";",st);
|
||||
TextInputQue(task,0,st2,0);
|
||||
Free(st2);
|
||||
Free(st);
|
||||
TaskWait(task);
|
||||
}
|
||||
|
||||
U0 Auto(U8 *fmt,...)
|
||||
//Sends text to one's own input buffer
|
||||
{
|
||||
U8 *st=SPrintFJoin(NULL,fmt,argc,argv),
|
||||
*st2=MSPrintF("\"%Q\";",st);
|
||||
if (Bt(&Fs->task_flags,TASKf_INPUT_FILTER_TASK))
|
||||
ExePutS(st2);
|
||||
else
|
||||
TextInputQue(Fs,0,st2,1<<TASKCf_HIGHEST_PRIORITY);
|
||||
Free(st2);
|
||||
Free(st);
|
||||
}
|
||||
|
||||
I64 ServantUser(U8 *fmt,...)
|
||||
//Spawns a visible task and sends text
|
||||
//which gets compiled and run.
|
||||
{
|
||||
U8 *st=SPrintFJoin(NULL,fmt,argc,argv);
|
||||
I64 result=0;
|
||||
CTaskCmd *tempc;
|
||||
CTask *task=Spawn(&ServantUserCmdLine,NULL,"Servant",Fs);
|
||||
Fs->popup_task=task;
|
||||
tempc=TaskRqstQue(task,Fs,st,1<<TASKCf_WAKE_MASTER|1<<TASKCf_FOCUS_MASTER);
|
||||
GetRqstResult(tempc,&result);
|
||||
Fs->popup_task=NULL;
|
||||
Kill(task,FALSE);
|
||||
Free(st);
|
||||
return result;
|
||||
}
|
||||
|
||||
U0 AutoStr(U8 *fmt,...)
|
||||
//Sends text in the nature of an AutoFile to one's
|
||||
//own input buffer.
|
||||
{
|
||||
U8 *st=SPrintFJoin(NULL,fmt,argc,argv);
|
||||
if (Bt(&Fs->task_flags,TASKf_INPUT_FILTER_TASK))
|
||||
ExePutS(st);
|
||||
else
|
||||
TextInputQue(Fs,0,st,1<<TASKCf_HIGHEST_PRIORITY);
|
||||
Free(st);
|
||||
}
|
||||
|
||||
U0 AutoFile(U8 *filename)
|
||||
{
|
||||
U8 *name2=DftExt(filename,"AUT.Z");
|
||||
if (Bt(&Fs->task_flags,TASKf_INPUT_FILTER_TASK))
|
||||
ExeFile(name2);
|
||||
else
|
||||
AutoStr("%F",name2);
|
||||
Free(name2);
|
||||
}
|
||||
|
||||
|
||||
//This sends text of an AutoFile nature to a
|
||||
//task's input buffer.
|
||||
U0 XTalkStr(CTask *task,U8 *fmt,...)
|
||||
{
|
||||
U8 *st=SPrintFJoin(NULL,fmt,argc,argv);
|
||||
TextInputQue(task,0,st,0);
|
||||
Free(st);
|
||||
}
|
||||
|
||||
U0 XTalkStrWait(CTask *task,U8 *fmt,...)
|
||||
{
|
||||
U8 *st=SPrintFJoin(NULL,fmt,argc,argv);
|
||||
TextInputQue(task,0,st,0);
|
||||
Free(st);
|
||||
TaskWait(task);
|
||||
}
|
||||
@@ -1,10 +1,78 @@
|
||||
asm {
|
||||
USE64
|
||||
// ************************************
|
||||
_MEMSET::
|
||||
ENTER 0
|
||||
PUSH RDI
|
||||
CLD
|
||||
MOV RDI,U64 SF_ARG1[RBP]
|
||||
MOV RAX,U64 SF_ARG2[RBP]
|
||||
MOV RCX,U64 SF_ARG3[RBP]
|
||||
REP_STOSB
|
||||
MOV RAX,RDI
|
||||
POP RDI
|
||||
LEAVE
|
||||
RET1 24
|
||||
// ************************************
|
||||
_MEMSET_U16::
|
||||
ENTER 0
|
||||
PUSH RDI
|
||||
CLD
|
||||
MOV RDI,U64 SF_ARG1[RBP]
|
||||
MOV RAX,U64 SF_ARG2[RBP]
|
||||
MOV RCX,U64 SF_ARG3[RBP]
|
||||
REP_STOSW
|
||||
MOV RAX,RDI
|
||||
POP RDI
|
||||
LEAVE
|
||||
RET1 24
|
||||
// ************************************
|
||||
_MEMSET_U32::
|
||||
ENTER 0
|
||||
PUSH RDI
|
||||
CLD
|
||||
MOV RDI,U64 SF_ARG1[RBP]
|
||||
MOV RAX,U64 SF_ARG2[RBP]
|
||||
MOV RCX,U64 SF_ARG3[RBP]
|
||||
REP_STOSD
|
||||
MOV RAX,RDI
|
||||
POP RDI
|
||||
LEAVE
|
||||
RET1 24
|
||||
// ************************************
|
||||
_MEMSET_U64::
|
||||
ENTER 0
|
||||
PUSH RDI
|
||||
CLD
|
||||
MOV RDI,U64 SF_ARG1[RBP]
|
||||
MOV RAX,U64 SF_ARG2[RBP]
|
||||
MOV RCX,U64 SF_ARG3[RBP]
|
||||
REP_STOSQ
|
||||
MOV RAX,RDI
|
||||
POP RDI
|
||||
LEAVE
|
||||
RET1 24
|
||||
// ************************************
|
||||
_MEMCPY::
|
||||
ENTER 0
|
||||
PUSH RSI
|
||||
PUSH RDI
|
||||
CLD
|
||||
MOV RDI,U64 SF_ARG1[RBP]
|
||||
MOV RSI,U64 SF_ARG2[RBP]
|
||||
MOV RCX,U64 SF_ARG3[RBP]
|
||||
REP_MOVSB
|
||||
MOV RAX,RDI
|
||||
POP RDI
|
||||
POP RSI
|
||||
LEAVE
|
||||
RET1 24
|
||||
// ************************************
|
||||
_MEMCMP::
|
||||
ENTER 0
|
||||
PUSH RSI
|
||||
PUSH RDI
|
||||
CLD
|
||||
MOV RSI,U64 SF_ARG1[RBP]
|
||||
MOV RDI,U64 SF_ARG2[RBP]
|
||||
MOV RCX,U64 SF_ARG3[RBP]
|
||||
@@ -19,6 +87,62 @@ _MEMCMP::
|
||||
LEAVE
|
||||
RET1 24
|
||||
// ************************************
|
||||
_BEQU::
|
||||
ENTER 0
|
||||
XOR RAX,RAX
|
||||
MOV RDX,U64 SF_ARG3[RBP]
|
||||
MOV RBX,U64 SF_ARG1[RBP]
|
||||
MOV RCX,U64 SF_ARG2[RBP]
|
||||
OR RDX,RDX
|
||||
JZ @@5
|
||||
BTS U64 [RBX],RCX
|
||||
JMP @@10
|
||||
@@5: BTR U64 [RBX],RCX
|
||||
@@10: ADC AL,0
|
||||
LEAVE
|
||||
RET1 24
|
||||
// ************************************
|
||||
_LBEQU::
|
||||
ENTER 0
|
||||
XOR RAX,RAX
|
||||
MOV RDX,U64 SF_ARG3[RBP]
|
||||
MOV RBX,U64 SF_ARG1[RBP]
|
||||
MOV RCX,U64 SF_ARG2[RBP]
|
||||
OR RDX,RDX
|
||||
JZ @@5
|
||||
LOCK
|
||||
BTS U64 [RBX],RCX
|
||||
JMP @@10
|
||||
@@5: LOCK
|
||||
BTR U64 [RBX],RCX
|
||||
@@10: ADC AL,0
|
||||
LEAVE
|
||||
RET1 24
|
||||
// ************************************
|
||||
_LIMIT_I64::
|
||||
ENTER 0
|
||||
MOV RAX,U64 SF_ARG1[RBP]
|
||||
MOV RCX,U64 SF_ARG2[RBP]
|
||||
MOV RDX,U64 SF_ARG3[RBP]
|
||||
CMP RAX,RCX
|
||||
CMOVL RAX,RCX
|
||||
CMP RAX,RDX
|
||||
CMOVG RAX,RDX
|
||||
LEAVE
|
||||
RET1 24
|
||||
// ************************************
|
||||
_LIMIT_U64::
|
||||
ENTER 0
|
||||
MOV RAX,U64 SF_ARG1[RBP]
|
||||
MOV RCX,U64 SF_ARG2[RBP]
|
||||
MOV RDX,U64 SF_ARG3[RBP]
|
||||
CMP RAX,RCX
|
||||
CMOVB RAX,RCX
|
||||
CMP RAX,RDX
|
||||
CMOVA RAX,RDX
|
||||
LEAVE
|
||||
RET1 24
|
||||
// ************************************
|
||||
_CALL::
|
||||
ENTER 0
|
||||
MOV RAX,U64 SF_ARG1[RBP]
|
||||
|
||||
Reference in new issue
Block a user