?? linux.hhf
字號:
#if( ! @defined( linux_hhf ))?linux_hhf := true;#includeonce( "hla.hhf" )#if( ! @defined( errno_hhf ))?errno_hhf := true;namespace errno; //@fast; const eperm := -1; enoent := -2; esrch := -3; eintr := -4; eio := -5; enxio := -6; e2big := -7; enoexec := -8; ebadf := -9; echild := -10; eagain := -11; enomem := -12; eacces := -13; efault := -14; enotblk := -15; ebusy := -16; eexist := -17; exdev := -18; enodev := -19; enotdir := -20; eisdir := -21; einval := -22; enfile := -23; emfile := -24; enotty := -25; etxtbsy := -26; efbig := -27; enospc := -28; espipe := -29; erofs := -30; emlink := -31; epipe := -32; edom := -33; erange := -34; edeadlk := -35; enametoolong := -36; enolck := -37; enosys := -38; enotempty := -39; eloop := -40; ewouldblock := eagain; enomsg := -42; eidrm := -43; echrng := -44; el2nsync := -45; el3hlt := -46; el3rst := -47; elnrng := -48; eunatch := -49; enocsi := -50; el2hlt := -51; ebade := -52; ebadr := -53; exfull := -54; enoano := -55; ebadrqc := -56; ebadslt := -57; edeadlock := edeadlk; ebfont := -59; enostr := -60; enodata := -61; etime := -62; enosr := -63; enonet := -64; enopkg := -65; eremote := -66; enolink := -67; eadv := -68; esrmnt := -69; ecomm := -70; eproto := -71; emultihop := -72; edotdot := -73; ebadmsg := -74; eoverflow := -75; enotuniq := -76; ebadfd := -77; eremchg := -78; elibacc := -79; elibbad := -80; elibscn := -81; elibmax := -82; elibexec := -83; eilseq := -84; erestart := -85; estrpipe := -86; eusers := -87; enotsock := -88; edestaddrreq := -89; emsgsize := -90; eprototype := -91; enoprotoopt := -92; eprotonosupport := -93; esocktnosupport := -94; eopnotsupp := -95; epfnosupport := -96; eafnosupport := -97; eaddrinuse := -98; eaddrnotavail := -99; enetdown := -100; enetunreach := -101; enetreset := -102; econnaborted := -103; econnreset := -104; enobufs := -105; eisconn := -106; enotconn := -107; eshutdown := -108; etoomanyrefs := -109; etimedout := -110; econnrefused := -111; ehostdown := -112; ehostunreach := -113; ealready := -114; einprogress := -115; estale := -116; euclean := -117; enotnam := -118; enavail := -119; eisnam := -120; eremoteio := -121; edquot := -122; enomedium := -123; emediumtype := -124; #if( @defined( __kernel__ )) erestartsys := -512; erestartnointr := -513; erestartnohand := -514; enoioctlcmd := -515; #endif end errno;#endif#if( ! @defined( types_hhf ))?types_hhf := true;namespace linux; //@fast;const // Some generic constants: int_max := int32( $7FFF_FFFF ); uint_max := uns32( $FFFF_FFFF ); int_min := !int_max; ssize_max := int_max; page_size := 4096; bits_per_long := 32; type umode_t :word; dev_t :word; ipc_pid_t :word; uid_t :word; gid_t :word; sid_t :word; mode_t :word; nlink_t :word; uid16_t :word; gid16_t :word; sa_family_t :word; ino_t :dword; off_t :dword; pid_t :dword; dma_addr_t :dword; size_t :dword; ptrdiff_t :dword; time_t :dword; suseconds_t :dword; clock_t :dword; daddr_t :dword; uid32_t :dword; gid32_t :dword; key_t :dword; kernel_cap_t:dword; caddr_t :pointer to char; ssize_t :int32; uint :uns32; __u32 :uns32; loff_t :qword; // Kernel related types: kdev_t :word; __kernel_daddr_t :int32; __kernel_fsid_t: record __val :int32[2]; endrecord; __kernel_ino_t :dword; __kernel_size_t :uns32; // These don't really belong here, // but what the heck. fd_set: record fds_bits :dword[ 32 ]; endrecord; fd_set_ptr :pointer to fd_set; __user_cap_user_header_struct: record version :uns32; pid :int32; endrecord; cap_user_header_t :pointer to __user_cap_user_header_struct; __user_cap_data_struct: record effective :uns32; permitted :uns32; inheritable :uns32; endrecord; cap_user_data_t :pointer to __user_cap_data_struct; old_sigset_t :dword; mmap_arg_struct: record addr :dword; len :uns32; prot :dword; flags :dword; fd :dword; offset :uns32; endrecord; sel_arg_struct: record n :uns32; inp :dword; outp :dword; exp :dword; tvp :dword; //pointer to timeval; endrecord; #macro pushregs; push( ebx ); push( ecx ); push( edx ); push( esi ); push( edi ); #endmacro #macro popregs; pop( edi ); pop( esi ); pop( edx ); pop( ecx ); pop( ebx ); #endmacro end linux;#endif //types_hhf#if( ! @defined( aout_hhf ))?aout_hhf := true;namespace linux; //@fast; type exec: record a_info :dword; a_text :dword; // length of text, in bytes a_data :dword; // length of data, in bytes a_bss :dword; // length of uninitialized data a_syms :dword; // length of symbol table data a_entry :dword; // start address a_drsize:dword; // length of relocation info for data endrecord;end linux;#endif //aout_hhf#if( ! @defined( atomic_hhf ))?atomic_hhf := true;namespace linux; //@fast; type atomic_t:record counter :dword; endrecord;end linux;#endif //atomic_hhf#if( ! @defined( list_hhf ))?list_hhf := true;namespace linux; //@fast; type list_head_pt: pointer to list_head; list_head:record; next :list_head_pt; prev :list_head_pt; endrecord; // The following creates an initialized list_head constant. #macro list_head_init(__name); @global:linux.list_head:[ &__name, &__name ] #endmacro // The following is an approximation of the LIST_HEAD macro defined // in C. The name and usage are quite different because of namespace // pollution and features that HLA provides. In C, you'd declare an // initialized list head object by LIST_HEAD(var_name), in HLA you // do the following: // // var_name:list_head_t; // // Note that this declaration is only legal in static, storage, and readonly // declaration sections. Also note that this is not legal inside a namespace. #macro list_head_t:var_name; forward(var_name); var_name: @global:linux.list_head := @global:linux.list_head:[ &var_name, &var_name] #endmacro // Run-time initialization of a list_head (useful for var objects!) // lvar must be a list_head variable (this is slightly different than // the C macro, which expects a pointer to a list_head variable). #macro init_list_head(__lvar); returns ({ #if( @class( __lvar ) = @global:hla.cStatic ) mov( &__lvar, __lvar.next ); mov( &__lvar, __lvar.prev ); #else push( eax ); lea( eax, __lvar ); mov( eax, __lvar.next ); mov( eax, __lvar.prev ); pop( eax ); #endif }, "") #endmacro // Note: no macros for list manipulation for two reasons: // (1) the discrete code to do it is trivial // (2) the generalized code would extremely long and inefficient. end linux;#endif //list_hhf#if( ! @defined( wait_hhf ))?wait_hhf := true;#if( ! @defined( spinlock_hhf ))?spinlock_hhf := true;// Note: since this is assembly language, not C, we'll// dispense with all the spin lock macros that preserve// flags (because it's much easier to preserve the flags// directly in assembly.namespace linux; //@fast;type spinlock_t: record _lock :dword; endrecord; wq_lock_t :spinlock_t; rw_lock_t :spinlock_t; rwlock_t :rw_lock_t;const spin_lock_unlocked :spinlock_t := spinlock_t:[0]; #if( @defined( __SMP__ )) #error( "Need to add SMP support to spinlock.hhf" ) #else // On single processor systems, spinlocks are empty // since we can't preempt the kernel. // Really, this should be an empty macro since we // don't really use spinlocks in a single processor // system. However, since this *is* assembly language, // some assembly programmer might actually poke around // with the internal structure, so it's best to go ahead // and initialize the spinlock. #macro spin_lock_init(__x); returns ( { mov( 0, __x._lock ); }, "" ) #endmacro // spin_lock returns the value of the spinlock // object passed as an argument. This macro // uses an empty "returns" statement rather than // simply specifying "theLock._lock" as the macro // body to allow the caller to specify this as // a statement (as well as an instruction operand). // If the user does this, HLA ignores the "rtn" // value. // // Note that this macro can be used as a destination // operand of an instruction, even though the caller // should never really do that. // // In theory, this macro should spin until the lock // is available, but since locks are never held in // a uniprocessor system, there is no waiting. #macro spin_lock(__Lock):rtn; ?rtn := @string:__Lock + "._lock"; returns({},rtn) #endmacro // On a uniprocessor system, bottom halves are automatically // disabled since we can't preempt the kernel. #macro spin_lock_bh(__x):rtn; ?rtn := @string:__x + "._lock"; returns({},rtn) #endmacro // Since this is uniprocessor code, the following // macro always returns false (zero) since the // spinlock is never locked (this code ignores // the spinlock value if an assembly programmer // has set it to some value other than zero). // Again, this macro uses the "returns" statement // so that invoking this macro as a statement // is okay. #macro spin_is_locked(__lock); returns({}, "0") #endmacro // spin_trylock attempts to aquire the lock // without waiting. Since we can always aquire // the lock, this code always returns zero to // indicate that the lock is available. #macro spin_trylock(__lock); returns({},"0") #endmacro // spin_unlock_wait waits until the lock // is available, but doesn't take possession of it. // Of course, the lock is always available, so this // macro really does nothing. #macro spin_unlock_wait(__lock); #endmacro // spin_unlock unlocks the specified spinlock. // Since spinlocks in a uniprocessor system // are never held, this macro does nothing. #macro spin_unlock(__lock); #endmacro /* * Read-write spinlocks, allowing multiple readers * but only one writer. * * NOTE! it is quite common to have readers in interrupts * but no interrupt writers. For those circumstances we * can "mix" irq-safe locks - any writer needs to get a * irq-safe write-lock, but readers can get non-irqsafe * read-locks. * * On a uniprocessor system, these macros are identical * to the spinlock macros. See those macros for comments. */ #macro rwlock_init(__x):rtn; ?rtn := @string:__x + "._lock"; returns({},rtn) #endmacro #macro read_lock(__Lock):rtn; ?rtn := @string:__Lock + "._lock"; returns({},rtn) #endmacro #macro read_unlock(__lock); #endmacro #macro write_lock(__Lock):rtn; ?rtn := @string:__Lock + "._lock"; returns({},rtn) #endmacro #macro write_unlock(__lock); #endmacro #endif end linux; #endif // spinlock_hhfnamespace linux; //@fast;type wait_queue_head_t:record _lock :wq_lock_t; task_list :list_head; endrecord; const // constants/macros associated with wait4 wnohang := 1; wuntraced := 2; __wall := $4000_0000; __wclone := $8000_0000; #macro wexitstatus(s); movzx( (type byte s[1]), eax ) #endmacro #macro wifexited(s); returns ( { movzx( (type byte s), eax ); test( $7f, al ); setz( al ); }, "eax" ) #endmacro #macro wifstopped(s); returns ( { movzx( (type byte s), eax ); cmp( eax, $ff ); sete( al ); }, "eax" ) #endmacro // wifsignaled returns false if L.O. byte of // s contains 0, $80, or $ff (!wifstopped && !wifexited). #macro wifsignaled(s); returns ( { movzx( (type byte s), eax ); rol( 1, al ); //0,80,ff-> 0,1,ff inc( al ); //0,80,ff-> 1,2,0 cmp( al, 2 ); setnbe( al ); //0 if originally 0, 80, or ff. }, "eax" ) #endmacro #macro wtermsig(s); returns ( { movzx( (type byte s), eax ); and( $7f, al ); }, "eax" ) #endmacro #macro wstopsig(s); movzx( (type byte s[1]), eax ) #endmacro end linux;#endif //wait_hhf#if( ! @defined( module_hhf ))?module_hhf := true;namespace linux; //@fast;const // Bits of module.flags: mod_uninitialized := 0; mod_running := 1; mod_deleted := 2; mod_autoclean := 4; mod_visited := 8; mod_used_once := $10; mod_just_freed := $20; mod_initializing := $40; // Values for query module's which: qm_modules := 1; qm_deps := 2; qm_refs := 3; qm_symbols := 4; qm_info := 5; type kernel_sym: record value :dword; theName :char[60]; endrecord; module_persist :dword; // Really an empty structure, // But HLA doesn't allow this. module_symbol: record value :dword; theName :pointer to char; endrecord; module_ref: record dep :pointer to module_t; ref :pointer to module_t; next_ref :pointer to module_ref; endrecord; module_info: record addr :dword; size :dword; flags :dword; usecount:uns32; endrecord; module_t: record size_of_struct :uns32; next :pointer to module_t; _name :pointer to char; size :uns32; uc: union usecount :atomic_t; pad :dword; endunion;
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -