Skip to content

Commit

Permalink
chaos: rev 162, Feb 6, 2001
Browse files Browse the repository at this point in the history
  • Loading branch information
inspirer committed Jun 9, 2011
1 parent 03a86f4 commit 3a994be
Show file tree
Hide file tree
Showing 33 changed files with 1,538 additions and 1,570 deletions.
4 changes: 0 additions & 4 deletions chaos/chaos.ini

This file was deleted.

4 changes: 2 additions & 2 deletions chaos/driver.ini
@@ -1,2 +1,2 @@
list,for x

dosfs.drv
filesys.drv
48 changes: 40 additions & 8 deletions chaos/features.txt
Expand Up @@ -7,22 +7,54 @@
.142
- get/set priority
.143
- mini_driver load to 1st Mb
- ring0drivers load to 1st Mb
.144
- NMI enable/disable
- exit with string as error
.145
- mini_drivers loaded to memory and initialized
- ring0drivers loaded to memory and initialized
- sstruct maker
.146
- minidrv.csm
- interface for mini drivers
- interface for ring0drivers
.147
- mini drivers have DS associated with CS (!! defrag doesn't process it)
- ring0drivers have DS associated with CS (!! defrag doesn't process it)
.148
- VM TASK -> minidriver (vmm.sm)
- VM TASK -> ring0driver (vmm.sm)
.149
- HDD driver -> minidriver (vmm.sm)
- HDD driver -> ring0driver (vmm.sm)
.150
- driver loader (driver.ini parser) -> minidriver (drvload.sm)

- driver loader (only driver.ini parser) -> ring0driver (drvload.sm)
.151
- ring0driver functions registered (not checked eq names)
.152
- kernel can process function tables (func #2)
- optimized: minidrv.csm
.153
- driver loader loads ring1driver, process tables & fill mdata
.154
- full load of ring1drivers
! bug: interrupts
.155
- load of ring1function table, but no processing
! fixed: interrupts
.156
- int 0x31 processes task->ring1driver calls
.157
- processing task's tables
.158
- old drivers unlinked
- filesys driver reads filesys.ini
- removed registers
- int21 removed
- added functions dosOpenFile,etc.
- kernel cannot have access to filesystem
- etc.
.159
- filesys: build & show directory tree
.160
- fixed: filesys error
- filesys: show errors in filesys.ini
.161
- dosfs added
- filesys removed
15 changes: 0 additions & 15 deletions chaos/regs.ini

This file was deleted.

File renamed without changes.
233 changes: 118 additions & 115 deletions chaos/source/drv/fsys.csm → chaos/source/_drv/fsys.csm
Expand Up @@ -48,31 +48,48 @@
#org 0
// -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

// Show cpr
push cs;pop ds;esi=cpr;ah=0x31;int 0x21
// Show cpr
push cs;pop ds;esi=cpr;ah=0x31;int 0x21

// Allocate handle buffer
ah=6;ebx=driver_mem;int 0x20;ds=ax
bx=ax;edi=mem;ah=3;int 0x22
// Allocate handle buffer
ah=6;ebx=driver_mem;int 0x20;ds=ax
bx=ax;edi=mem;ah=3;int 0x22

// Allocate int25
ax=0x125;edx=int25;int 0x22
// Allocate int25
ax=0x125;edx=int25;int 0x22

// Set all handles = free
ecx=max_handle_num;esi=_h_task
{ w:[esi]=0;esi=+_h_structure;loop ?^0 }
// Set all handles = free
ecx=max_handle_num;esi=_h_task
{ w:[esi]=0;esi=+_h_structure;loop ?^0 }

iret
iret

// -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
int25:
// Clear CF
clc;cli;cld;push ebp
mov ebp,esp
and b:[~ebp+12],0xFE
pop ebp
cmp ah,0x0 ; jz create_file
jmp int25_f0
int25:
// Clear CF
clc
cli
cld
push ebp
mov ebp,esp
and b:[~ebp+12],0xFE
pop ebp
cmp ah,0x0 ; _jz create_file
cmp ah,0x1 ; _jz open_file
cmp ah,0x2 ; _jz close_file
cmp ah,0x3 ; _jz read_file
cmp ah,0x4 ; _jz write_file
cmp ah,0x5 ; _jz seek_file
cmp ah,0x9 ; _jz find_first
cmp ah,0xA ; _jz find_next
cmp ah,0x10 ; _jz execute
mov ax,err_no_support
set_cf:
push ebp
mov ebp,esp
or d:[~ebp+12],1
pop ebp
iret

#shortdef _file_name_full_ _driver_mem_end_+4096

Expand All @@ -81,91 +98,102 @@
// In: ah=0; cx = attr
// ds:esi - name
// Out: CF or ax=handle
create_file:
if (b:[esi]!='/'){ ax=err_wrong_info;jmp set_cf }
push es;push ds;push esi;push edi;push ecx;push ebx;push ecx

// Copy file name to buffer
eax=d:cs:mem;es=ax;edi=_file_name_full_;push edi
mov eax,'/Roo';stosd;al='t';stosb
{ lodsb;stosb;cmp al,0;jnz ?^0 } push es;pop ds

// set esi to end
pop esi;edi=esi { lodsb;cmp al,0;jnz ?^0 } dec esi;dec esi

// ES:EDI - ptr to start ; DS:ESI to end ; search for last "/"
_while(edi<esi){
_if (b:[esi]=='/'){
push esi;b:[esi]=0;
ah=0x42;int 0x20
_if (~nc){

// Copy to >MEM:_driver_mem_end_< full path + name
edi=_driver_mem_end_
ah=0x43;int 0x20;while(b:[edi]!=0){ inc edi } inc esi
{ lodsb;stosb;cmp al,0;jnz ?^0 } pop esi

// Check driver ID
esi=_driver_mem_end_
_ifelse(d:[esi]=='dos,'){
lodsd;edi=esi

// Redirect to DOS (int 0x21)
xor esi,esi;ecx=max_handle_num;xor eax,eax
{ if(w:[esi._h_task]==0){ dec eax;jmp ?v1 } esi=+_h_structure;loop ?^0 }

// No free handle
if(ax==0){
pop ecx;pop ebx;pop ecx;pop edi;pop esi;pop ds;pop es
ax=err_no_free_desc;jmp set_cf
}

// DS:ESI - block ; ES:EDI - fname ; save fname
push ecx;push esi;push edi;xchg esi,edi;esi=_file_name_full_
{ lodsb;stosb;cmp al,0;jnz ?^0 }

// Save task ID
pop edi;pop esi;str ax;and al,0xF8;w:[esi._h_task]=ax
create_file:
{ cmp b:[esi],'/';jz ?v0;mov ax,err_wrong_info;jmp set_cf }
push es;push ds;push esi;push edi;push ecx;push ebx;push ecx

// Copy file name to buffer
eax=d:cs:mem;es=ax;edi=_file_name_full_;push edi
mov eax,'/Roo';stosd;mov al,'t';stosb
{ lodsb;stosb;cmp al,0;jnz ?^0 } push es;pop ds

// set esi to end
pop esi;mov edi,esi { lodsb;cmp al,0;jnz ?^0 } dec esi;dec esi

// ES:EDI - ptr to start ; DS:ESI to end ; search for last "/"
{ // _while(edi<esi)
cmp edi,esi
_jge ?v0

{ // _if (b:[esi]=='/')
cmp b:[esi],'/'
_jne ?v0

push esi
mov b:[esi],0
mov ah,0x42;int 0x20
{ // _if (~nc)
_jc ?v0

// Copy to >MEM:_driver_mem_end_< full path + name
mov edi,_driver_mem_end_
mov ah,0x43;int 0x20
{ cmp b:[edi],0;jz ?v0;inc edi;jmps ?^0 } inc esi
{ lodsb;stosb;cmp al,0;jnz ?^0 } pop esi

// Check driver ID
mov esi,_driver_mem_end_
_ifelse(d:[esi]=='dos,'){
lodsd;mov edi,esi

// Redirect to DOS (int 0x21)
xor esi,esi;mov ecx,max_handle_num;xor eax,eax
{ if(w:[esi._h_task]==0){ dec eax;jmp ?v1 } add esi,_h_structure;loop ?^0 }

// No free handle
{ // if(ax==0)
cmp ax,0;jnz ?v0
pop ecx;pop ebx;pop ecx;pop edi;pop esi;pop ds;pop es
mov ax,err_no_free_desc;jmp set_cf
}

// Create file & save handle
pop ecx;pop eax;push ecx;ecx=eax;ah=0;push esi;esi=edi;int 0x21
if (~c){
pop esi;w:[esi._h_task]=0;
pop ecx;pop ebx;pop ecx;pop edi;pop esi;pop ds;pop es
ax=err_file_not_found;jmp set_cf
}
pop esi;w:[esi._h_hand]=ax
// DS:ESI - block ; ES:EDI - fname ; save fname
push ecx;push esi;push edi;xchg esi,edi;mov esi,_file_name_full_
{ lodsb;stosb;cmp al,0;jnz ?^0 }

} else {
// Save task ID
pop edi;pop esi;str ax;and al,0xF8;mov w:[esi._h_task],ax

pop ecx;pop ebx;pop ecx;pop edi;pop esi;pop ds;pop es
ax=err_unkn_file_sys;jmp set_cf
// Create file & save handle
pop ecx;pop eax;push ecx;mov ecx,eax;mov ah,0;push esi
mov esi,edi;int 0x21
{
jnc ?v0
pop esi;mov w:[esi._h_task],0
pop ecx;pop ebx;pop ecx;pop edi;pop esi;pop ds;pop es
mov ax,err_file_not_found;jmp set_cf
}
pop esi;mov w:[esi._h_hand],ax

}
} else {

pop eax;pop ebx;pop ecx;pop edi;pop esi;pop ds;pop es
iret
pop ecx;pop ebx;pop ecx;pop edi;pop esi;pop ds;pop es
mov ax,err_unkn_file_sys;jmp set_cf

}
pop esi;b:[esi]=0x2F
}
dec esi
}
pop ecx;pop ebx;pop ecx;pop edi;pop esi;pop ds;pop es
ax=err_file_not_found;jmp set_cf

int25_f0:
cmp ah,0x1 ; jz open_file
jmp int25_f1
pop eax;pop ebx;pop ecx;pop edi;pop esi;pop ds;pop es
iret

}
pop esi
mov b:[esi],0x2F
}
dec esi
jmp ?^0
}
pop ecx;pop ebx;pop ecx;pop edi;pop esi;pop ds;pop es
mov ax,err_file_not_found
jmp set_cf

// -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
// 2. Open file
// In: ah=1; al=access mode (0-read,1-write,2-r/w)
// ds:esi - name
// Out: CF or ax=handle
open_file:
push eax;ah=0xE;int 0x23;ax=0xD0A;int 0x23;pop eax
if (b:[esi]!='/'){ ax=err_wrong_info;jmp set_cf }
open_file:
push eax;mov ah,0xE;int 0x23;mov ax,0xD0A;int 0x23;pop eax
if (b:[esi]!='/'){ ax=err_wrong_info;jmp set_cf }
push es;push ds;push esi;push edi;push ecx;push ebx;push eax

// Copy file name to buffer
Expand Down Expand Up @@ -262,11 +290,6 @@
pop ecx;pop esi;pop ds;pop ebx;pop eax
iret

int25_f1:
cmp ah,0x2 ; jz close_file
cmp ah,0x3 ; jz read_file
jmp int25_f2

// -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
// 4. Read file
// In: ah = 3
Expand Down Expand Up @@ -388,12 +411,6 @@
pop ebx
iret

int25_f2:
cmp ah,0x4 ; _jz write_file
cmp ah,0x5 ; _jz seek_file
cmp ah,0x9 ; jz find_first
jmp int25_f3

#shortdef _file_info_rec_ _file_name_full_

// -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Expand Down Expand Up @@ -533,9 +550,6 @@
pop ecx;pop edi;pop es;pop esi;pop ds;pop ebx;pop ecx;pop edi;pop eax;pop es
ax=err_file_not_found;jmp set_cf

int25_f3:
cmp ah,0xA ; jz find_next
jmp int25_f4

// -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
// 11. FindNext
Expand Down Expand Up @@ -644,17 +658,6 @@

}

// -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
int25_f4:
cmp ah,0x10 ; jz execute
ax=err_no_support
set_cf:
push ebp
mov ebp,esp
or d:[~ebp+12],1
pop ebp
iret

// -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
// 17. Execute
// In: ah = 0x10
Expand Down
1 change: 1 addition & 0 deletions chaos/source/drv/keyb.csm → chaos/source/_drv/keyb.csm
Expand Up @@ -40,6 +40,7 @@

// -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --


// Show device name
push cs;pop ds;esi=cpr;ah=0x31;int 0x21

Expand Down

0 comments on commit 3a994be

Please sign in to comment.