Usage of struct.inc from fasm in trunk kernel.

git-svn-id: svn://kolibrios.org@2381 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2012-02-22 15:46:09 +00:00
parent 31a62f12b5
commit 58fe32f210
16 changed files with 636 additions and 478 deletions

View File

@ -33,18 +33,18 @@ MAX_NUM_PARTITIONS = 256
; This structure defines all callback functions for working with the physical
; device. They are implemented by a driver. Objects with this structure reside
; in a driver.
struct DISKFUNC
.strucsize dd ?
struct DISKFUNC
strucsize dd ?
; Size of the structure. This field is intended for possible extensions of
; this structure. If a new function is added to this structure and a driver
; implements an old version, the caller can detect this by checking .strucsize,
; so the driver remains compatible.
.close dd ?
close dd ?
; The pointer to the function which frees all driver-specific resources for
; the disk.
; Optional, may be NULL.
; void close(void* userdata);
.closemedia dd ?
closemedia dd ?
; The pointer to the function which informs the driver that the kernel has
; finished all processing with the current media. If media is removed, the
; driver should decline all requests to that media with DISK_STATUS_NO_MEDIA,
@ -53,24 +53,24 @@ struct DISKFUNC
; function is called.
; Optional, may be NULL (if media is not removable).
; void closemedia(void* userdata);
.querymedia dd ?
querymedia dd ?
; The pointer to the function which determines capabilities of the media.
; int querymedia(void* userdata, DISKMEDIAINFO* info);
; Return value: one of DISK_STATUS_*
.read dd ?
read dd ?
; The pointer to the function which reads data from the device.
; int read(void* userdata, void* buffer, __int64 startsector, int* numsectors);
; input: *numsectors = number of sectors to read
; output: *numsectors = number of sectors which were successfully read
; Return value: one of DISK_STATUS_*
.write dd ?
write dd ?
; The pointer to the function which writes data to the device.
; Optional, may be NULL.
; int write(void* userdata, void* buffer, __int64 startsector, int* numsectors);
; input: *numsectors = number of sectors to write
; output: *numsectors = number of sectors which were successfully written
; Return value: one of DISK_STATUS_*
.flush dd ?
flush dd ?
; The pointer to the function which flushes the internal device cache.
; Optional, may be NULL.
; int flush(void* userdata);
@ -78,7 +78,7 @@ struct DISKFUNC
; Note that read/write are called by the cache manager, so a driver should not
; create a software cache. This function is implemented for flushing a hardware
; cache, if it exists.
.adjust_cache_size dd ?
adjust_cache_size dd ?
; The pointer to the function which returns the cache size for this device.
; Optional, may be NULL.
; unsigned int adjust_cache_size(unsigned int suggested_size);
@ -88,51 +88,51 @@ ends
; This structure holds information on a medium.
; Objects with this structure are allocated by the kernel as a part of the DISK
; structure and are filled by a driver in the 'querymedia' callback.
struct DISKMEDIAINFO
.Flags dd ?
struct DISKMEDIAINFO
Flags dd ?
; Combination of DISK_MEDIA_* bits.
.SectorSize dd ?
SectorSize dd ?
; Size of the sector.
.Capacity dq ?
Capacity dq ?
; Size of the media in sectors.
ends
; This structure represents the disk cache. To follow the old implementation,
; there are two distinct caches for a disk, one for "system" data,and the other
; for "application" data.
struct DISKCACHE
.Lock MUTEX
struct DISKCACHE
mutex MUTEX
; Lock to protect the cache.
; The following fields are inherited from data32.inc:cache_ideX.
.pointer rd 1
.data_size rd 1 ; not use
.data rd 1
.sad_size rd 1
.search_start rd 1
pointer dd ?
data_size dd ? ; unused
data dd ?
sad_size dd ?
search_start dd ?
ends
; This structure represents a disk device and its media for the kernel.
; This structure is allocated by the kernel in the 'disk_add' function,
; freed in the 'disk_dereference' function.
struct DISK
struct DISK
; Fields of disk object
.Next dd ?
.Prev dd ?
Next dd ?
Prev dd ?
; All disk devices are linked in one list with these two fields.
; Head of the list is the 'disk_list' variable.
.Functions dd ?
Functions dd ?
; Pointer to the 'DISKFUNC' structure with driver functions.
.Name dd ?
Name dd ?
; Pointer to the string used for accesses through the global filesystem.
.UserData dd ?
UserData dd ?
; This field is passed to all callback functions so a driver can decide which
; physical device is addressed.
.DriverFlags dd ?
DriverFlags dd ?
; Bitfield. Currently only DISK_NO_INSERT_NOTIFICATION bit is defined.
; If it is set, the driver will never issue 'disk_media_changed' notification
; with argument set to true, so the kernel must try to detect media during
; requests from the file system.
.RefCount dd ?
RefCount dd ?
; Count of active references to this structure. One reference is kept during
; the lifetime of the structure between 'disk_add' and 'disk_del'.
; Another reference is taken during any filesystem operation for this disk.
@ -140,51 +140,51 @@ struct DISK
; The structure is destroyed when the reference count decrements to zero:
; this usually occurs in 'disk_del', but can be delayed to the end of last
; filesystem operation, if one is active.
.MediaLock MUTEX
MediaLock MUTEX
; Lock to protect the MEDIA structure. See the description after
; 'disk_list_mutex' for the locking strategy.
; Fields of media object
.MediaInserted db ?
MediaInserted db ?
; 0 if media is not inserted, nonzero otherwise.
.MediaUsed db ?
MediaUsed db ?
; 0 if media fields are not used, nonzero otherwise. If .MediaRefCount is
; nonzero, this field is nonzero too; however, when .MediaRefCount goes
; to zero, there is some time interval during which media object is still used.
align 4
align 4
; The following fields are not valid unless either .MediaInserted is nonzero
; or they are accessed from a code which has obtained the reference when
; .MediaInserted was nonzero.
.MediaRefCount dd ?
MediaRefCount dd ?
; Count of active references to the media object. One reference is kept during
; the lifetime of the media between two calls to 'disk_media_changed'.
; Another reference is taken during any filesystem operation for this media.
; The callback 'closemedia' is called when the reference count decrements to
; zero: this usually occurs in 'disk_media_changed', but can be delayed to the
; end of the last filesystem operation, if one is active.
.MediaInfo DISKMEDIAINFO
MediaInfo DISKMEDIAINFO
; This field keeps information on the current media.
.NumPartitions dd ?
NumPartitions dd ?
; Number of partitions on this media.
.Partitions dd ?
Partitions dd ?
; Pointer to array of .NumPartitions pointers to PARTITION structures.
.cache_size dd ?
cache_size dd ?
; inherited from cache_ideX_size
.SysCache DISKCACHE
.AppCache DISKCACHE
SysCache DISKCACHE
AppCache DISKCACHE
; Two caches for the disk.
ends
; This structure represents one partition for the kernel. This is a base
; template, the actual contents after common fields is determined by the
; file system code for this partition.
struct PARTITION
.FirstSector dq ?
struct PARTITION
FirstSector dq ?
; First sector of the partition.
.Length dq ?
Length dq ?
; Length of the partition in sectors.
.Disk dd ?
Disk dd ?
; Pointer to parent DISK structure.
.FSUserFunctions dd ?
FSUserFunctions dd ?
; Handlers for the sysfunction 70h. This field is a pointer to the following
; array. The first dword is a number of supported subfunctions, other dwords
; point to handlers of corresponding subfunctions.
@ -193,24 +193,24 @@ struct PARTITION
ends
; This is an external structure, it represents an entry in the partition table.
struct PARTITION_TABLE_ENTRY
.Bootable db ?
struct PARTITION_TABLE_ENTRY
Bootable db ?
; 80h = bootable partition, 0 = non-bootable partition, other values = invalid
.FirstHead db ?
.FirstSector db ?
.FirstTrack db ?
FirstHead db ?
FirstSector db ?
FirstTrack db ?
; Coordinates of first sector in CHS.
.Type db ?
Type db ?
; Partition type, one of predefined constants. 0 = empty, several types denote
; extended partition (see process_partition_table_entry), we are not interested
; in other values.
.LastHead db ?
.LastSector db ?
.LastTrack db ?
LastHead db ?
LastSector db ?
LastTrack db ?
; Coordinates of last sector in CHS.
.FirstAbsSector dd ?
FirstAbsSector dd ?
; Coordinate of first sector in LBA.
.Length dd ?
Length dd ?
; Length of the partition in sectors.
ends

View File

@ -520,9 +520,9 @@ disk_init_cache:
@@:
; 3. Fill two DISKCACHE structures.
mov [esi+DISK.SysCache.pointer], eax
lea ecx, [esi+DISK.SysCache.Lock]
lea ecx, [esi+DISK.SysCache.mutex]
call mutex_init
lea ecx, [esi+DISK.AppCache.Lock]
lea ecx, [esi+DISK.AppCache.mutex]
call mutex_init
; The following code is inherited from getcache.inc.
mov edx, [esi+DISK.SysCache.pointer]

View File

@ -146,43 +146,38 @@ SSE_INIT equ (SSE_IM+SSE_DM+SSE_ZM+SSE_OM+SSE_UM+SSE_PM)
IRQ_PIC equ 0
IRQ_APIC equ 1
struc TSS
{
._back rw 2
._esp0 rd 1
._ss0 rw 2
._esp1 rd 1
._ss1 rw 2
._esp2 rd 1
._ss2 rw 2
._cr3 rd 1
._eip rd 1
._eflags rd 1
._eax rd 1
._ecx rd 1
._edx rd 1
._ebx rd 1
._esp rd 1
._ebp rd 1
._esi rd 1
._edi rd 1
._es rw 2
._cs rw 2
._ss rw 2
._ds rw 2
._fs rw 2
._gs rw 2
._ldt rw 2
._trap rw 1
._io rw 1
rb 24
._io_map_0 rb 4096
._io_map_1 rb 4096
}
virtual at 0
TSS TSS
end virtual
struct TSS
_back rw 2
_esp0 rd 1
_ss0 rw 2
_esp1 rd 1
_ss1 rw 2
_esp2 rd 1
_ss2 rw 2
_cr3 rd 1
_eip rd 1
_eflags rd 1
_eax rd 1
_ecx rd 1
_edx rd 1
_ebx rd 1
_esp rd 1
_ebp rd 1
_esi rd 1
_edi rd 1
_es rw 2
_cs rw 2
_ss rw 2
_ds rw 2
_fs rw 2
_gs rw 2
_ldt rw 2
_trap rw 1
_io rw 1
rb 24
_io_map_0 rb 4096
_io_map_1 rb 4096
ends
TSS_SIZE equ (128+8192)

View File

@ -223,23 +223,17 @@ do_change_task:
struc MUTEX_WAITER
{
.list LHEAD
.task rd 1
.sizeof:
};
virtual at 0
MUTEX_WAITER MUTEX_WAITER
end virtual
struct MUTEX_WAITER
list LHEAD
task dd ?
ends
;void __fastcall mutex_init(struct mutex *lock)
align 4
mutex_init:
mov [ecx+MUTEX.wait.next], ecx
mov [ecx+MUTEX.wait.prev], ecx
mov [ecx+MUTEX.lhead.next], ecx
mov [ecx+MUTEX.lhead.prev], ecx
mov [ecx+MUTEX.count], 1
ret
@ -255,7 +249,7 @@ mutex_lock:
pushfd
cli
sub esp, MUTEX_WAITER.sizeof
sub esp, sizeof.MUTEX_WAITER
list_add_tail esp, ecx ;esp= new waiter, ecx= list head
@ -278,12 +272,12 @@ mutex_lock:
mov [eax+MUTEX_WAITER.list.next], edx
mov [edx+MUTEX_WAITER.list.prev], eax
cmp [ecx+MUTEX.wait.next], ecx
cmp [ecx+MUTEX.lhead.next], ecx
jne @F
mov [ecx+MUTEX.count], 0
@@:
add esp, MUTEX_WAITER.sizeof
add esp, sizeof.MUTEX_WAITER
popfd
.done:
@ -297,7 +291,7 @@ mutex_unlock:
pushfd
cli
mov eax, [ecx+MUTEX.wait.next]
mov eax, [ecx+MUTEX.lhead.next]
cmp eax, ecx
mov [ecx+MUTEX.count], 1
je @F

View File

@ -11,17 +11,17 @@ $Revision$
; list, and the OS loop after every timer tick processes the list.
; This structure describes a timer for the kernel.
struct TIMER
.Next dd ?
.Prev dd ?
struct TIMER
Next dd ?
Prev dd ?
; These fields organize a double-linked list of all timers.
.TimerFunc dd ?
TimerFunc dd ?
; Function to be called when the timer is activated.
.UserData dd ?
UserData dd ?
; The value that is passed as is to .TimerFunc.
.Time dd ?
Time dd ?
; Time at which the timer should be activated.
.Interval dd ?
Interval dd ?
; Interval between activations of the timer, in 0.01s.
ends

View File

@ -51,97 +51,97 @@ uglobal
EXT2_read_in_folder dd ? ;сколько файлов "считали"
EXT2_end_block dd ? ;конец очередного блока папки
EXT2_counter_blocks dd ?
EXT2_filename db 256 dup ?
EXT2_parent_name db 256 dup ?
EXT2_filename rb 256
EXT2_parent_name rb 256
EXT2_name_len dd ?
endg
struct EXT2_INODE_STRUC
.i_mode dw ?
.i_uid dw ?
.i_size dd ?
.i_atime dd ?
.i_ctime dd ?
.i_mtime dd ?
.i_dtime dd ?
.i_gid dw ?
.i_links_count dw ?
.i_blocks dd ?
.i_flags dd ?
.i_osd1 dd ?
.i_block dd 15 dup ?
.i_generation dd ?
.i_file_acl dd ?
.i_dir_acl dd ?
.i_faddr dd ?
.i_osd2 dd ? ; 1..12
struct EXT2_INODE_STRUC
i_mode dw ?
i_uid dw ?
i_size dd ?
i_atime dd ?
i_ctime dd ?
i_mtime dd ?
i_dtime dd ?
i_gid dw ?
i_links_count dw ?
i_blocks dd ?
i_flags dd ?
i_osd1 dd ?
i_block rd 15
i_generation dd ?
i_file_acl dd ?
i_dir_acl dd ?
i_faddr dd ?
i_osd2 dd ? ; 1..12
ends
struct EXT2_DIR_STRUC
.inode dd ?
.rec_len dw ?
.name_len db ?
.file_type db ?
.name db ? ; 0..255
struct EXT2_DIR_STRUC
inode dd ?
rec_len dw ?
name_len db ?
file_type db ?
name db ? ; 0..255
ends
struct EXT2_BLOCK_GROUP_DESC
.block_bitmap dd ?
.inode_bitmap dd ?
.inode_table dd ?
.free_blocks_count dw ?
.free_inodes_count dw ?
.used_dirs_count dw ?
struct EXT2_BLOCK_GROUP_DESC
block_bitmap dd ?
inode_bitmap dd ?
inode_table dd ?
free_blocks_count dw ?
free_inodes_count dw ?
used_dirs_count dw ?
ends
struct EXT2_SB_STRUC
.inodes_count dd ? ;+0
.blocks_count dd ? ;+4
.r_block_count dd ? ;+8
.free_block_count dd ? ;+12
.free_inodes_count dd ? ;+16
.first_data_block dd ? ;+20
.log_block_size dd ? ;+24
.log_frag_size dd ? ;+28
.blocks_per_group dd ? ;+32
.frags_per_group dd ? ;+36
.inodes_per_group dd ? ;+40
.mtime dd ? ;+44
.wtime dd ? ;+48
.mnt_count dw ? ;+52
.max_mnt_count dw ? ;+54
.magic dw ? ;+56
.state dw ? ;+58
.errors dw ? ;+60
.minor_rev_level dw ? ;+62
.lastcheck dd ? ;+64
.check_intervals dd ? ;+68
.creator_os dd ? ;+72
.rev_level dd ? ;+76
.def_resuid dw ? ;+80
.def_resgid dw ? ;+82
.first_ino dd ? ;+84
.inode_size dw ? ;+88
.block_group_nr dw ? ;+90
.feature_compat dd ? ;+92
.feature_incompat dd ? ;+96
.feature_ro_compat dd ? ;+100
.uuid db 16 dup ? ;+104
.volume_name db 16 dup ? ;+120
.last_mounted db 64 dup ? ;+136
.algo_bitmap dd ? ;+200
.prealloc_blocks db ? ;+204
.preallock_dir_blocks db ? ;+205
dw ? ;+206 alignment
.journal_uuid db 16 dup ? ;+208
.journal_inum dd ? ;+224
.journal_dev dd ? ;+228
.last_orphan dd ? ;+232
.hash_seed dd 4 dup ? ;+236
.def_hash_version db ? ;+252
db 3 dup ? ;+253 reserved
.default_mount_options dd ? ;+256
.first_meta_bg dd ? ;+260
struct EXT2_SB_STRUC
inodes_count dd ? ;+0
blocks_count dd ? ;+4
r_block_count dd ? ;+8
free_block_count dd ? ;+12
free_inodes_count dd ? ;+16
first_data_block dd ? ;+20
log_block_size dd ? ;+24
log_frag_size dd ? ;+28
blocks_per_group dd ? ;+32
frags_per_group dd ? ;+36
inodes_per_group dd ? ;+40
mtime dd ? ;+44
wtime dd ? ;+48
mnt_count dw ? ;+52
max_mnt_count dw ? ;+54
magic dw ? ;+56
state dw ? ;+58
errors dw ? ;+60
minor_rev_level dw ? ;+62
lastcheck dd ? ;+64
check_intervals dd ? ;+68
creator_os dd ? ;+72
rev_level dd ? ;+76
def_resuid dw ? ;+80
def_resgid dw ? ;+82
first_ino dd ? ;+84
inode_size dw ? ;+88
block_group_nr dw ? ;+90
feature_compat dd ? ;+92
feature_incompat dd ? ;+96
feature_ro_compat dd ? ;+100
uuid rb 16 ;+104
volume_name rb 16 ;+120
last_mounted rb 64 ;+136
algo_bitmap dd ? ;+200
prealloc_blocks db ? ;+204
preallock_dir_blocks db ? ;+205
dw ? ;+206 alignment
journal_uuid rb 16 ;+208
journal_inum dd ? ;+224
journal_dev dd ? ;+228
last_orphan dd ? ;+232
hash_seed rd 4 ;+236
def_hash_version db ? ;+252
rb 3 ;+253 reserved
default_mount_options dd ? ;+256
first_meta_bg dd ? ;+260
ends
ext2_test_superblock:

View File

@ -231,7 +231,7 @@ mouse._.left_button_press_handler: ;///////////////////////////////////////////
mov [mouse.active_sys_window.pslot], esi
lea eax, [edi + WDATA.box]
mov ebx, mouse.active_sys_window.old_box
mov ecx, BOX.sizeof
mov ecx, sizeof.BOX
call memmove
mov ebx, mouse.active_sys_window.new_box
call memmove
@ -305,7 +305,7 @@ mouse._.left_button_release_handler: ;/////////////////////////////////////////
shl eax, 5
add eax, window_data + WDATA.box
mov ebx, mouse.active_sys_window.old_box
mov ecx, BOX.sizeof
mov ecx, sizeof.BOX
call memmove
mov eax, mouse.active_sys_window.old_box
@ -377,7 +377,7 @@ mouse._.move_handler: ;////////////////////////////////////////////////////////
mov eax, mouse.active_sys_window.new_box
mov ebx, mouse.active_sys_window.old_box
mov ecx, BOX.sizeof
mov ecx, sizeof.BOX
call memmove
mov dl, [mouse.active_sys_window.action]
@ -505,7 +505,7 @@ mouse._.move_handler: ;////////////////////////////////////////////////////////
push esi
mov esi, mouse.active_sys_window.old_box
mov edi, mouse.active_sys_window.new_box
mov ecx, BOX.sizeof / 4
mov ecx, sizeof.BOX / 4
repe
cmpsd
pop esi

View File

@ -42,44 +42,44 @@ read_skin_file:
pop eax
ret
struct SKIN_HEADER
.ident dd ?
.version dd ?
.params dd ?
.buttons dd ?
.bitmaps dd ?
struct SKIN_HEADER
ident dd ?
version dd ?
params dd ?
buttons dd ?
bitmaps dd ?
ends
struct SKIN_PARAMS
.skin_height dd ?
.margin.right dw ?
.margin.left dw ?
.margin.bottom dw ?
.margin.top dw ?
.colors.inner dd ?
.colors.outer dd ?
.colors.frame dd ?
.colors_1.inner dd ?
.colors_1.outer dd ?
.colors_1.frame dd ?
.dtp.size dd ?
.dtp.data db 40 dup (?)
struct SKIN_PARAMS
skin_height dd ?
margin.right dw ?
margin.left dw ?
margin.bottom dw ?
margin.top dw ?
colors.inner dd ?
colors.outer dd ?
colors.frame dd ?
colors_1.inner dd ?
colors_1.outer dd ?
colors_1.frame dd ?
dtp.size dd ?
dtp.data rb 40
ends
struct SKIN_BUTTONS
.type dd ?
.pos:
.left dw ?
.top dw ?
.size:
.width dw ?
.height dw ?
struct SKIN_BUTTONS
type dd ?
; position
left dw ?
top dw ?
; size
width dw ?
height dw ?
ends
struct SKIN_BITMAPS
.kind dw ?
.type dw ?
.data dd ?
struct SKIN_BITMAPS
kind dw ?
type dw ?
data dd ?
ends
load_default_skin:

View File

@ -16,26 +16,26 @@ iglobal
_skin_file_default db '/sys/DEFAULT.SKN',0
endg
struct SKIN_DATA
.colors.inner dd ?
.colors.outer dd ?
.colors.frame dd ?
.left.data dd ?
.left.left dd ?
.left.width dd ?
.oper.data dd ?
.oper.left dd ?
.oper.width dd ?
.base.data dd ?
.base.left dd ?
.base.width dd ?
struct SKIN_DATA
colors.inner dd ?
colors.outer dd ?
colors.frame dd ?
left.data dd ?
left.left dd ?
left.width dd ?
oper.data dd ?
oper.left dd ?
oper.width dd ?
base.data dd ?
base.left dd ?
base.width dd ?
ends
struct SKIN_BUTTON
.left dd ?
.top dd ?
.width dd ?
.height dd ?
struct SKIN_BUTTON
left dd ?
top dd ?
width dd ?
height dd ?
ends
uglobal

View File

@ -354,7 +354,7 @@ syscall_move_window: ;///// system function 67 ////////////////////////////////
mov eax, esp
mov bl, [edi + WDATA.fl_wstate]
call window._.set_window_box
add esp, BOX.sizeof
add esp, sizeof.BOX
; NOTE: do we really need this? to be reworked
; mov byte[DONT_DRAW_MOUSE], 0 ; mouse pointer
@ -518,7 +518,7 @@ repos_windows: ;///////////////////////////////////////////////////////////////
;? <description>
;------------------------------------------------------------------------------
mov ecx, [TASK_COUNT]
mov edi, window_data + WDATA.sizeof * 2
mov edi, window_data + sizeof.WDATA * 2
call force_redraw_background
dec ecx
jle .exit
@ -573,7 +573,7 @@ repos_windows: ;///////////////////////////////////////////////////////////////
.fix_client_box:
call window._.set_window_clientbox
add edi, WDATA.sizeof
add edi, sizeof.WDATA
loop .next_window
.exit:
@ -1111,7 +1111,7 @@ sys_window_maximize_handler: ;/////////////////////////////////////////////////
@@:
call window._.set_window_box
add esp, BOX.sizeof
add esp, sizeof.BOX
.exit:
ret
@ -1147,7 +1147,7 @@ sys_window_rollup_handler: ;///////////////////////////////////////////////////
.restore_size:
test bl, WSTATE_MAXIMIZED
jnz @f
add esp, -BOX.sizeof
add esp, -sizeof.BOX
lea eax, [edx + APPDATA.saved_box]
jmp .set_box
@ -1162,7 +1162,7 @@ sys_window_rollup_handler: ;///////////////////////////////////////////////////
.set_box:
call window._.set_window_box
add esp, BOX.sizeof
add esp, sizeof.BOX
ret
@ -1341,7 +1341,7 @@ end if
jz .exit
@@:
add esp, -BOX.sizeof
add esp, -sizeof.BOX
mov ebx, esp
if WDATA.box
@ -1350,7 +1350,7 @@ else
mov esi, edi ; optimization for WDATA.box = 0
end if
xchg eax, esi
mov ecx, BOX.sizeof
mov ecx, sizeof.BOX
call memmove
xchg eax, esi
xchg ebx, esi
@ -1362,7 +1362,7 @@ end if
call window._.set_window_clientbox
call window._.invalidate_screen
add esp, BOX.sizeof
add esp, sizeof.BOX
mov cl, [esp + 4]
mov ch, cl

View File

@ -67,6 +67,7 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
include 'macros.inc'
include 'struct.inc'
$Revision$

View File

@ -15,69 +15,31 @@
$Revision$
struct POINT
x dd ?
y dd ?
ends
;struc db [a] { common . db a
; if ~used .
; display 'not used db: ',`.,13,10
; end if }
;struc dw [a] { common . dw a
; if ~used .
; display 'not used dw: ',`.,13,10
; end if }
;struc dd [a] { common . dd a
; if ~used .
; display 'not used dd: ',`.,13,10
; end if }
;struc dp [a] { common . dp a
; if ~used .
; display 'not used dp: ',`.,13,10
; end if }
;struc dq [a] { common . dq a
; if ~used .
; display 'not used dq: ',`.,13,10
; end if }
;struc dt [a] { common . dt a
; if ~used .
; display 'not used dt: ',`.,13,10
; end if }
struct RECT
left dd ?
top dd ?
right dd ?
bottom dd ?
ends
struc POINT {
.x dd ?
.y dd ?
.sizeof:
}
virtual at 0
POINT POINT
end virtual
struct BOX
left dd ?
top dd ?
width dd ?
height dd ?
ends
struc RECT {
.left dd ?
.top dd ?
.right dd ?
.bottom dd ?
.sizeof:
}
virtual at 0
RECT RECT
end virtual
struc BOX {
.left dd ?
.top dd ?
.width dd ?
.height dd ?
.sizeof:
}
virtual at 0
BOX BOX
end virtual
struc DISPMODE {
.width rw 1
.height rw 1
.bpp rw 1
.freq rw 1
}
struct DISPMODE
width dw ?
height dw ?
bpp dw ?
freq dw ?
ends
; constants definition
WSTATE_NORMAL = 00000000b
@ -91,24 +53,20 @@ WSTATE_WNDDRAWN = 00000010b
WSTYLE_HASCAPTION = 00010000b
WSTYLE_CLIENTRELATIVE = 00100000b
struc TASKDATA
{
.event_mask dd ?
.pid dd ?
dw ?
.state db ?
db ?
dw ?
.wnd_number db ?
db ?
.mem_start dd ?
.counter_sum dd ?
.counter_add dd ?
.cpu_usage dd ?
}
virtual at 0
TASKDATA TASKDATA
end virtual
struct TASKDATA
event_mask dd ?
pid dd ?
dw ?
state db ?
db ?
dw ?
wnd_number db ?
db ?
mem_start dd ?
counter_sum dd ?
counter_add dd ?
cpu_usage dd ?
ends
TSTATE_RUNNING = 0
TSTATE_RUN_SUSPENDED = 1
@ -119,90 +77,85 @@ TSTATE_WAITING = 5
TSTATE_FREE = 9
; structures definition
struc WDATA {
.box BOX
.cl_workarea dd ?
.cl_titlebar dd ?
.cl_frames dd ?
.reserved db ?
.fl_wstate db ?
.fl_wdrawn db ?
.fl_redraw db ?
.sizeof:
}
virtual at 0
WDATA WDATA
end virtual
struct WDATA
box BOX
cl_workarea dd ?
cl_titlebar dd ?
cl_frames dd ?
reserved db ?
fl_wstate db ?
fl_wdrawn db ?
fl_redraw db ?
ends
label WDATA.fl_wstyle byte at WDATA.cl_workarea + 3
struc APPDATA
{
.app_name db 11 dup(?)
db 5 dup(?)
struct DBG_REGS
dr0 dd ?
dr1 dd ?
dr2 dd ?
dr3 dd ?
dr7 dd ?
ends
struct APPDATA
app_name rb 11
rb 5
fpu_state dd ? ;+16
ev_count_ dd ? ;unused ;+20
exc_handler dd ? ;+24
except_mask dd ? ;+28
pl0_stack dd ? ;+32
heap_base dd ? ;+36
heap_top dd ? ;+40
cursor dd ? ;+44
fd_ev dd ? ;+48
bk_ev dd ? ;+52
fd_obj dd ? ;+56
bk_obj dd ? ;+60
saved_esp dd ? ;+64
io_map rd 2 ;+68
dbg_state dd ? ;+76
cur_dir dd ? ;+80
wait_timeout dd ? ;+84
saved_esp0 dd ? ;+88
wait_begin dd ? ;+92 +++
wait_test dd ? ;+96 +++
wait_param dd ? ;+100 +++
tls_base dd ? ;+104
dlls_list_ptr dd ? ;+108
rb 16 ;+112
wnd_shape dd ? ;+128
wnd_shape_scale dd ? ;+132
dd ? ;+136
mem_size dd ? ;+140
saved_box BOX
ipc_start dd ?
ipc_size dd ?
event_mask dd ?
debugger_slot dd ?
dd ?
keyboard_mode db ?
rb 3
dir_table dd ?
dbg_event_mem dd ?
dbg_regs DBG_REGS
wnd_caption dd ?
wnd_clientbox BOX
ends
.fpu_state dd ? ;+16
.ev_count_ dd ? ;unused ;+20
.exc_handler dd ? ;+24
.except_mask dd ? ;+28
.pl0_stack dd ? ;+32
.heap_base dd ? ;+36
.heap_top dd ? ;+40
.cursor dd ? ;+44
.fd_ev dd ? ;+48
.bk_ev dd ? ;+52
.fd_obj dd ? ;+56
.bk_obj dd ? ;+60
.saved_esp dd ? ;+64
.io_map rd 2 ;+68
.dbg_state dd ? ;+76
.cur_dir dd ? ;+80
.wait_timeout dd ? ;+84
.saved_esp0 dd ? ;+88
.wait_begin dd ? ;+92 +++
.wait_test dd ? ;+96 +++
.wait_param dd ? ;+100 +++
.tls_base dd ? ;+104
.dlls_list_ptr dd ? ;+108
db 16 dup(?) ;+112
.wnd_shape dd ? ;+128
.wnd_shape_scale dd ? ;+132
dd ? ;+136
.mem_size dd ? ;+140
.saved_box BOX
.ipc_start dd ?
.ipc_size dd ?
.event_mask dd ?
.debugger_slot dd ?
dd ?
.keyboard_mode db ?
db 3 dup(?)
.dir_table dd ?
.dbg_event_mem dd ?
.dbg_regs:
.dbg_regs.dr0 dd ?
.dbg_regs.dr1 dd ?
.dbg_regs.dr2 dd ?
.dbg_regs.dr3 dd ?
.dbg_regs.dr7 dd ?
.wnd_caption dd ?
.wnd_clientbox BOX
}
virtual at 0
APPDATA APPDATA
end virtual
;// mike.dld, 2006-29-01 ]
struc MUTEX
{
.wait LHEAD
.count rd 1
}
virtual at 0
MUTEX MUTEX
end virtual
struct MUTEX
lhead LHEAD
count dd ?
ends
; Core functions

View File

@ -12,31 +12,6 @@ macro $Revision a {
$Revision$
; structure definition helper
macro struct name, [arg]
{
common
name@struct equ name
struc name arg {
}
macro declare_sizeof xname,value
{ sizeof.#xname = value }
macro struct_helper name
{
match xname,name
\{
virtual at 0
xname xname
declare_sizeof xname, $ - xname
name equ sizeof.#xname
end virtual
\}
}
ends fix } struct_helper name@struct
;// mike.dld, 2006-29-01 [
; macros definition

View File

@ -30,32 +30,32 @@
$Revision$
; socket data structure
struct SOCKET
.PrevPtr dd ? ; pointer to previous socket in list
.NextPtr dd ? ; pointer to next socket in list
.Number dd ? ; socket number (unique within single process)
.PID dd ? ; application process id
.LocalIP dd ? ; local IP address
.LocalPort dw ? ; local port
.RemoteIP dd ? ; remote IP address
.RemotePort dw ? ; remote port
.OrigRemoteIP dd ? ; original remote IP address (used to reset to LISTEN state)
.OrigRemotePort dw ? ; original remote port (used to reset to LISTEN state)
.rxDataCount dd ? ; rx data count
.TCBState dd ? ; TCB state
.TCBTimer dd ? ; TCB timer (seconds)
.ISS dd ? ; initial send sequence
.IRS dd ? ; initial receive sequence
.SND_UNA dd ? ; sequence number of unack'ed sent packets
.SND_NXT dd ? ; bext send sequence number to use
.SND_WND dd ? ; send window
.RCV_NXT dd ? ; next receive sequence number to use
.RCV_WND dd ? ; receive window
.SEG_LEN dd ? ; segment length
.SEG_WND dd ? ; segment window
.wndsizeTimer dd ? ; window size timer
.lock MUTEX ; lock mutex
.rxData dd ? ; receive data buffer here
struct SOCKET
PrevPtr dd ? ; pointer to previous socket in list
NextPtr dd ? ; pointer to next socket in list
Number dd ? ; socket number (unique within single process)
PID dd ? ; application process id
LocalIP dd ? ; local IP address
LocalPort dw ? ; local port
RemoteIP dd ? ; remote IP address
RemotePort dw ? ; remote port
OrigRemoteIP dd ? ; original remote IP address (used to reset to LISTEN state)
OrigRemotePort dw ? ; original remote port (used to reset to LISTEN state)
rxDataCount dd ? ; rx data count
TCBState dd ? ; TCB state
TCBTimer dd ? ; TCB timer (seconds)
ISS dd ? ; initial send sequence
IRS dd ? ; initial receive sequence
SND_UNA dd ? ; sequence number of unack'ed sent packets
SND_NXT dd ? ; bext send sequence number to use
SND_WND dd ? ; send window
RCV_NXT dd ? ; next receive sequence number to use
RCV_WND dd ? ; receive window
SEG_LEN dd ? ; segment length
SEG_WND dd ? ; segment window
wndsizeTimer dd ? ; window size timer
mutex MUTEX ; lock mutex
rxData dd ? ; receive data buffer here
ends
; TCP opening modes
@ -100,7 +100,7 @@ proc net_socket_alloc stdcall uses ebx ecx edx edi
pop eax
mov ebx, eax
lea ecx, [eax+SOCKET.lock]
lea ecx, [eax+SOCKET.mutex]
call mutex_init
mov eax, ebx
@ -711,7 +711,7 @@ proc socket_read stdcall
jz .error
mov ebx, eax
lea ecx, [eax + SOCKET.lock]
lea ecx, [eax + SOCKET.mutex]
call mutex_lock
mov eax, [ebx + SOCKET.rxDataCount] ; get count of bytes
@ -734,14 +734,14 @@ proc socket_read stdcall
and ecx, 3
rep movsb
lea ecx, [ebx + SOCKET.lock]
lea ecx, [ebx + SOCKET.mutex]
mov ebx, eax
call mutex_unlock
mov eax, ebx
ret
.error_release:
lea ecx, [ebx + SOCKET.lock]
lea ecx, [ebx + SOCKET.mutex]
call mutex_unlock
.error:
xor ebx, ebx
@ -769,7 +769,7 @@ proc socket_read_packet stdcall
mov ebx, eax
push ecx edx
lea ecx, [eax + SOCKET.lock]
lea ecx, [eax + SOCKET.mutex]
call mutex_lock
pop edx ecx
@ -802,7 +802,7 @@ proc socket_read_packet stdcall
rep movsb ; copy remaining bytes
.exit:
lea ecx, [ebx + SOCKET.lock]
lea ecx, [ebx + SOCKET.mutex]
mov ebx, eax
call mutex_unlock
mov eax, ebx
@ -816,7 +816,7 @@ proc socket_read_packet stdcall
xor esi, esi
mov [ebx + SOCKET.rxDataCount], esi ; store new count (zero)
call .start_copy
lea ecx, [ebx + SOCKET.lock]
lea ecx, [ebx + SOCKET.mutex]
mov ebx, eax
call mutex_unlock
mov eax, ebx

View File

@ -967,7 +967,7 @@ proc stateTCB_ESTABLISHED stdcall, sockAddr:DWORD
.data:
push ecx
push ecx edx
lea ecx, [ebx+SOCKET.lock]
lea ecx, [ebx+SOCKET.mutex]
call mutex_lock
pop edx ecx
@ -989,7 +989,7 @@ proc stateTCB_ESTABLISHED stdcall, sockAddr:DWORD
cld
rep movsb ; copy the data across
lea ecx, [ebx + SOCKET.lock]
lea ecx, [ebx + SOCKET.mutex]
call mutex_unlock
; flag an event to the application
@ -1035,7 +1035,7 @@ proc stateTCB_ESTABLISHED stdcall, sockAddr:DWORD
.overflow:
; no place in buffer
; so simply restore stack and exit
lea ecx, [ebx + SOCKET.lock]
lea ecx, [ebx + SOCKET.mutex]
call mutex_unlock
pop eax ecx
ret

240
kernel/trunk/struct.inc Normal file
View File

@ -0,0 +1,240 @@
; Macroinstructions for defining data structures
macro struct name
{ virtual at 0
fields@struct equ name
match child parent, name \{ fields@struct equ child,fields@\#parent \}
sub@struct equ
struc db [val] \{ \common define field@struct .,db,<val>
fields@struct equ fields@struct,field@struct \}
struc dw [val] \{ \common define field@struct .,dw,<val>
fields@struct equ fields@struct,field@struct \}
struc du [val] \{ \common define field@struct .,du,<val>
fields@struct equ fields@struct,field@struct \}
struc dd [val] \{ \common define field@struct .,dd,<val>
fields@struct equ fields@struct,field@struct \}
struc dp [val] \{ \common define field@struct .,dp,<val>
fields@struct equ fields@struct,field@struct \}
struc dq [val] \{ \common define field@struct .,dq,<val>
fields@struct equ fields@struct,field@struct \}
struc dt [val] \{ \common define field@struct .,dt,<val>
fields@struct equ fields@struct,field@struct \}
struc rb count \{ define field@struct .,db,count dup (?)
fields@struct equ fields@struct,field@struct \}
struc rw count \{ define field@struct .,dw,count dup (?)
fields@struct equ fields@struct,field@struct \}
struc rd count \{ define field@struct .,dd,count dup (?)
fields@struct equ fields@struct,field@struct \}
struc rp count \{ define field@struct .,dp,count dup (?)
fields@struct equ fields@struct,field@struct \}
struc rq count \{ define field@struct .,dq,count dup (?)
fields@struct equ fields@struct,field@struct \}
struc rt count \{ define field@struct .,dt,count dup (?)
fields@struct equ fields@struct,field@struct \}
macro db [val] \{ \common \local anonymous
define field@struct anonymous,db,<val>
fields@struct equ fields@struct,field@struct \}
macro dw [val] \{ \common \local anonymous
define field@struct anonymous,dw,<val>
fields@struct equ fields@struct,field@struct \}
macro du [val] \{ \common \local anonymous
define field@struct anonymous,du,<val>
fields@struct equ fields@struct,field@struct \}
macro dd [val] \{ \common \local anonymous
define field@struct anonymous,dd,<val>
fields@struct equ fields@struct,field@struct \}
macro dp [val] \{ \common \local anonymous
define field@struct anonymous,dp,<val>
fields@struct equ fields@struct,field@struct \}
macro dq [val] \{ \common \local anonymous
define field@struct anonymous,dq,<val>
fields@struct equ fields@struct,field@struct \}
macro dt [val] \{ \common \local anonymous
define field@struct anonymous,dt,<val>
fields@struct equ fields@struct,field@struct \}
macro rb count \{ \local anonymous
define field@struct anonymous,db,count dup (?)
fields@struct equ fields@struct,field@struct \}
macro rw count \{ \local anonymous
define field@struct anonymous,dw,count dup (?)
fields@struct equ fields@struct,field@struct \}
macro rd count \{ \local anonymous
define field@struct anonymous,dd,count dup (?)
fields@struct equ fields@struct,field@struct \}
macro rp count \{ \local anonymous
define field@struct anonymous,dp,count dup (?)
fields@struct equ fields@struct,field@struct \}
macro rq count \{ \local anonymous
define field@struct anonymous,dq,count dup (?)
fields@struct equ fields@struct,field@struct \}
macro rt count \{ \local anonymous
define field@struct anonymous,dt,count dup (?)
fields@struct equ fields@struct,field@struct \}
macro union \{ fields@struct equ fields@struct,,union,<
sub@struct equ union \}
macro struct \{ fields@struct equ fields@struct,,substruct,<
sub@struct equ substruct \} }
macro ends
{ match , sub@struct \{ restruc db,dw,du,dd,dp,dq,dt
restruc rb,rw,rd,rp,rq,rt
purge db,dw,du,dd,dp,dq,dt
purge rb,rw,rd,rp,rq,rt
purge union,struct
match name tail,fields@struct, \\{ if $
display 'Error: definition of ',\\`name,' contains illegal instructions.',0Dh,0Ah
err
end if \\}
match name=,fields,fields@struct \\{ fields@struct equ
make@struct name,fields
define fields@\\#name fields \\}
end virtual \}
match any, sub@struct \{ fields@struct equ fields@struct> \}
restore sub@struct }
macro make@struct name,[field,type,def]
{ common
local define
define equ name
forward
local sub
match , field \{ make@substruct type,name,sub def
define equ define,.,sub, \}
match any, field \{ define equ define,.#field,type,<def> \}
common
match fields, define \{ define@struct fields \} }
macro define@struct name,[field,type,def]
{ common
virtual
db `name
load initial@struct byte from 0
if initial@struct = '.'
display 'Error: name of structure should not begin with a dot.',0Dh,0Ah
err
end if
end virtual
local list
list equ
forward
if ~ field eq .
name#field type def
sizeof.#name#field = $ - name#field
else
label name#.#type
rb sizeof.#type
end if
local value
match any, list \{ list equ list, \}
list equ list <value>
common
sizeof.#name = $
restruc name
match values, list \{
struc name value \\{ \\local \\..base
match any, fields@struct \\\{ fields@struct equ fields@struct,.,name,<values> \\\}
match , fields@struct \\\{ label \\..base
forward
match , value \\\\{ field type def \\\\}
match any, value \\\\{ field type value
if ~ field eq .
rb sizeof.#name#field - ($-field)
end if \\\\}
common label . at \\..base \\\}
\\}
macro name value \\{
match any, fields@struct \\\{ \\\local anonymous
fields@struct equ fields@struct,anonymous,name,<values> \\\}
match , fields@struct \\\{
forward
match , value \\\\{ type def \\\\}
match any, value \\\\{ \\\\local ..field
..field = $
type value
if ~ field eq .
rb sizeof.#name#field - ($-..field)
end if \\\\}
common \\\} \\} \} }
macro enable@substruct
{ macro make@substruct substruct,parent,name,[field,type,def]
\{ \common
\local define
define equ parent,name
\forward
\local sub
match , field \\{ match any, type \\\{ enable@substruct
make@substruct type,parent,sub def
purge make@substruct
define equ define,.,sub, \\\} \\}
match any, field \\{ define equ define,.\#field,type,<def> \\}
\common
match fields, define \\{ define@\#substruct fields \\} \} }
enable@substruct
macro define@union parent,name,[field,type,def]
{ common
virtual at parent#.#name
forward
if ~ field eq .
virtual at parent#.#name
parent#field type def
sizeof.#parent#field = $ - parent#field
end virtual
if sizeof.#parent#field > $ - parent#.#name
rb sizeof.#parent#field - ($ - parent#.#name)
end if
else
virtual at parent#.#name
label parent#.#type
type def
end virtual
label name#.#type at parent#.#name
if sizeof.#type > $ - parent#.#name
rb sizeof.#type - ($ - parent#.#name)
end if
end if
common
sizeof.#name = $ - parent#.#name
end virtual
struc name [value] \{ \common
label .\#name
last@union equ
forward
match any, last@union \\{ virtual at .\#name
field type def
end virtual \\}
match , last@union \\{ match , value \\\{ field type def \\\}
match any, value \\\{ field type value \\\} \\}
last@union equ field
common rb sizeof.#name - ($ - .\#name) \}
macro name [value] \{ \common \local ..anonymous
..anonymous name value \} }
macro define@substruct parent,name,[field,type,def]
{ common
virtual at parent#.#name
forward
if ~ field eq .
parent#field type def
sizeof.#parent#field = $ - parent#field
else
label parent#.#type
rb sizeof.#type
end if
common
sizeof.#name = $ - parent#.#name
end virtual
struc name value \{
label .\#name
forward
match , value \\{ field type def \\}
match any, value \\{ field type value
if ~ field eq .
rb sizeof.#parent#field - ($-field)
end if \\}
common \}
macro name value \{ \local ..anonymous
..anonymous name \} }