3 ** Michael Smith. All rights reserved.
5 ** Redistribution and use in source and binary forms, with or without
6 ** modification, are permitted provided that the following conditions
8 ** 1. Redistributions of source code must retain the above copyright
9 ** notice, this list of conditions and the following disclaimer.
10 ** 2. Redistributions in binary form must reproduce the above copyright
11 ** notice, this list of conditions and the following disclaimer in the
12 ** documentation and/or other materials provided with the distribution.
14 ** THIS SOFTWARE IS PROVIDED BY Michael Smith ``AS IS'' AND
15 ** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 ** ARE DISCLAIMED. IN NO EVENT SHALL Michael Smith BE LIABLE
18 ** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 ** OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 ** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 ** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 ** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 ** $FreeBSD: src/usr.bin/doscmd/register.h,v 1.4 1999/10/08 09:02:38 marcel Exp $
27 ** $DragonFly: src/usr.bin/doscmd/register.h,v 1.5 2006/11/07 06:57:02 dillon Exp $
30 /******************************************************************************
31 ** Abstractions to hide register access methods across different platforms.
37 /* standard register representation */
56 #if defined(__DragonFly__)
58 /* layout must match definition of struct sigcontext in <machine/signal.h> */
90 ** passed around as a reference to the registers. This must be in
91 ** scope for the following register macros to work.
94 /* register shorthands */
95 #define R_ESP (REGS->r.esp.r_ex)
96 #define R_SP (REGS->r.esp.r_w.r_x)
97 #define R_EBP (REGS->r.ebp.r_ex)
98 #define R_BP (REGS->r.ebp.r_w.r_x)
99 #define R_ISP (REGS->r.isp.r_ex)
100 #define R_EIP (REGS->r.eip.r_ex)
101 #define R_IP (REGS->r.eip.r_w.r_x)
102 #define R_EFLAGS (REGS->r.efl.r_ex)
103 #define R_FLAGS (REGS->r.efl.r_w.r_x)
104 #define R_EES (REGS->r.es.r_ex)
105 #define R_ES (REGS->r.es.r_w.r_x)
106 #define R_EDS (REGS->r.ds.r_ex)
107 #define R_DS (REGS->r.ds.r_w.r_x)
108 #define R_ECS (REGS->r.cs.r_ex)
109 #define R_CS (REGS->r.cs.r_w.r_x)
110 #define R_ESS (REGS->r.ss.r_ex)
111 #define R_SS (REGS->r.ss.r_w.r_x)
112 #define R_EDI (REGS->r.edi.r_ex)
113 #define R_DI (REGS->r.edi.r_w.r_x)
114 #define R_ESI (REGS->r.esi.r_ex)
115 #define R_SI (REGS->r.esi.r_w.r_x)
116 #define R_EBX (REGS->r.ebx.r_ex)
117 #define R_BX (REGS->r.ebx.r_w.r_x)
118 #define R_BL (REGS->r.ebx.r_b.r_l)
119 #define R_BH (REGS->r.ebx.r_b.r_h)
120 #define R_EDX (REGS->r.edx.r_ex)
121 #define R_DX (REGS->r.edx.r_w.r_x)
122 #define R_DL (REGS->r.edx.r_b.r_l)
123 #define R_DH (REGS->r.edx.r_b.r_h)
124 #define R_ECX (REGS->r.ecx.r_ex)
125 #define R_CX (REGS->r.ecx.r_w.r_x)
126 #define R_CL (REGS->r.ecx.r_b.r_l)
127 #define R_CH (REGS->r.ecx.r_b.r_h)
128 #define R_EAX (REGS->r.eax.r_ex)
129 #define R_AX (REGS->r.eax.r_w.r_x)
130 #define R_AL (REGS->r.eax.r_b.r_l)
131 #define R_AH (REGS->r.eax.r_b.r_h)
132 #define R_EGS (REGS->r.gs.r_ex)
133 #define R_GS (REGS->r.gs.r_w.r_x)
134 #define R_EFS (REGS->r.fs.r_ex)
135 #define R_FS (REGS->r.fs.r_w.r_x)
146 ** register manipulation macros
149 #define PUTVEC(s, o, x) ((s) = ((x) >> 16), (o) = (x) & 0xffff)
150 #define MAKEVEC(s, o) (((s) << 16) + (o))
152 #define PUTPTR(s, o, x) (((s) = ((x) & 0xf0000) >> 4), (o) = (x) & 0xffff)
153 #define MAKEPTR(s, o) (((s) << 4) + (o))
155 #define VECPTR(x) MAKEPTR((x) >> 16, (x) & 0xffff)
157 #define REGISTERS regcontext_t *REGS
160 PUSH(u_short x
, REGISTERS
)
163 *(u_short
*)MAKEPTR(R_SS
, R_SP
) = (x
);
166 inline static u_short
171 x
= *(u_short
*)MAKEPTR(R_SS
, R_SP
);
176 # ifndef PSL_ALLCC /* Grr, FreeBSD doesn't have this */
177 # define PSL_ALLCC (PSL_C|PSL_PF|PSL_AF|PSL_Z|PSL_N)