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

View File

@ -520,9 +520,9 @@ disk_init_cache:
@@: @@:
; 3. Fill two DISKCACHE structures. ; 3. Fill two DISKCACHE structures.
mov [esi+DISK.SysCache.pointer], eax mov [esi+DISK.SysCache.pointer], eax
lea ecx, [esi+DISK.SysCache.Lock] lea ecx, [esi+DISK.SysCache.mutex]
call mutex_init call mutex_init
lea ecx, [esi+DISK.AppCache.Lock] lea ecx, [esi+DISK.AppCache.mutex]
call mutex_init call mutex_init
; The following code is inherited from getcache.inc. ; The following code is inherited from getcache.inc.
mov edx, [esi+DISK.SysCache.pointer] 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_PIC equ 0
IRQ_APIC equ 1 IRQ_APIC equ 1
struc TSS struct TSS
{ _back rw 2
._back rw 2 _esp0 rd 1
._esp0 rd 1 _ss0 rw 2
._ss0 rw 2 _esp1 rd 1
._esp1 rd 1 _ss1 rw 2
._ss1 rw 2 _esp2 rd 1
._esp2 rd 1 _ss2 rw 2
._ss2 rw 2 _cr3 rd 1
._cr3 rd 1 _eip rd 1
._eip rd 1 _eflags rd 1
._eflags rd 1 _eax rd 1
._eax rd 1 _ecx rd 1
._ecx rd 1 _edx rd 1
._edx rd 1 _ebx rd 1
._ebx rd 1 _esp rd 1
._esp rd 1 _ebp rd 1
._ebp rd 1 _esi rd 1
._esi rd 1 _edi rd 1
._edi rd 1 _es rw 2
._es rw 2 _cs rw 2
._cs rw 2 _ss rw 2
._ss rw 2 _ds rw 2
._ds rw 2 _fs rw 2
._fs rw 2 _gs rw 2
._gs rw 2 _ldt rw 2
._ldt rw 2 _trap rw 1
._trap rw 1 _io rw 1
._io rw 1 rb 24
rb 24 _io_map_0 rb 4096
._io_map_0 rb 4096 _io_map_1 rb 4096
._io_map_1 rb 4096 ends
}
virtual at 0
TSS TSS
end virtual
TSS_SIZE equ (128+8192) TSS_SIZE equ (128+8192)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -15,69 +15,31 @@
$Revision$ $Revision$
struct POINT
x dd ?
y dd ?
ends
;struc db [a] { common . db a struct RECT
; if ~used . left dd ?
; display 'not used db: ',`.,13,10 top dd ?
; end if } right dd ?
;struc dw [a] { common . dw a bottom dd ?
; if ~used . ends
; 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 }
struc POINT { struct BOX
.x dd ? left dd ?
.y dd ? top dd ?
.sizeof: width dd ?
} height dd ?
virtual at 0 ends
POINT POINT
end virtual
struc RECT { struct DISPMODE
.left dd ? width dw ?
.top dd ? height dw ?
.right dd ? bpp dw ?
.bottom dd ? freq dw ?
.sizeof: ends
}
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
}
; constants definition ; constants definition
WSTATE_NORMAL = 00000000b WSTATE_NORMAL = 00000000b
@ -91,24 +53,20 @@ WSTATE_WNDDRAWN = 00000010b
WSTYLE_HASCAPTION = 00010000b WSTYLE_HASCAPTION = 00010000b
WSTYLE_CLIENTRELATIVE = 00100000b WSTYLE_CLIENTRELATIVE = 00100000b
struc TASKDATA struct TASKDATA
{ event_mask dd ?
.event_mask dd ? pid dd ?
.pid dd ? dw ?
dw ? state db ?
.state db ? db ?
db ? dw ?
dw ? wnd_number db ?
.wnd_number db ? db ?
db ? mem_start dd ?
.mem_start dd ? counter_sum dd ?
.counter_sum dd ? counter_add dd ?
.counter_add dd ? cpu_usage dd ?
.cpu_usage dd ? ends
}
virtual at 0
TASKDATA TASKDATA
end virtual
TSTATE_RUNNING = 0 TSTATE_RUNNING = 0
TSTATE_RUN_SUSPENDED = 1 TSTATE_RUN_SUSPENDED = 1
@ -119,90 +77,85 @@ TSTATE_WAITING = 5
TSTATE_FREE = 9 TSTATE_FREE = 9
; structures definition ; structures definition
struc WDATA { struct WDATA
.box BOX box BOX
.cl_workarea dd ? cl_workarea dd ?
.cl_titlebar dd ? cl_titlebar dd ?
.cl_frames dd ? cl_frames dd ?
.reserved db ? reserved db ?
.fl_wstate db ? fl_wstate db ?
.fl_wdrawn db ? fl_wdrawn db ?
.fl_redraw db ? fl_redraw db ?
.sizeof: ends
}
virtual at 0
WDATA WDATA
end virtual
label WDATA.fl_wstyle byte at WDATA.cl_workarea + 3 label WDATA.fl_wstyle byte at WDATA.cl_workarea + 3
struc APPDATA struct DBG_REGS
{ dr0 dd ?
.app_name db 11 dup(?) dr1 dd ?
db 5 dup(?) 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 ] ;// mike.dld, 2006-29-01 ]
struc MUTEX struct MUTEX
{ lhead LHEAD
.wait LHEAD count dd ?
.count rd 1 ends
}
virtual at 0
MUTEX MUTEX
end virtual
; Core functions ; Core functions

View File

@ -12,31 +12,6 @@ macro $Revision a {
$Revision$ $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 [ ;// mike.dld, 2006-29-01 [
; macros definition ; macros definition

View File

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

View File

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