4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #include <sys/types.h>
28 #include <sys/mkdev.h>
29 #include <sys/regset.h>
42 if (d
!= (dev32_t
)-1L)
43 return (makedev((d
>> NBITSMINOR32
) & MAXMAJ32
, d
& MAXMIN32
));
45 return ((dev_t
)PRNODEV
);
56 major_t maj
= major(d
);
57 minor_t min
= minor(d
);
59 if (maj
== (major_t
)PRNODEV
|| min
== (minor_t
)PRNODEV
)
62 return ((dev32_t
)((maj
<< NBITSMINOR32
) | min
));
72 timestruc_32_to_n(const timestruc32_t
*src
, timestruc_t
*dst
)
74 dst
->tv_sec
= (time_t)(uint32_t)src
->tv_sec
;
75 dst
->tv_nsec
= (long)(uint32_t)src
->tv_nsec
;
79 stack_32_to_n(const stack32_t
*src
, stack_t
*dst
)
81 dst
->ss_sp
= (caddr_t
)(uintptr_t)src
->ss_sp
;
82 dst
->ss_size
= src
->ss_size
;
83 dst
->ss_flags
= src
->ss_flags
;
87 sigaction_32_to_n(const struct sigaction32
*src
, struct sigaction
*dst
)
89 (void) memset(dst
, 0, sizeof (struct sigaction
));
90 dst
->sa_flags
= src
->sa_flags
;
91 dst
->sa_handler
= (void (*)())(uintptr_t)src
->sa_handler
;
92 (void) memcpy(&dst
->sa_mask
, &src
->sa_mask
, sizeof (dst
->sa_mask
));
96 siginfo_32_to_n(const siginfo32_t
*src
, siginfo_t
*dst
)
98 (void) memset(dst
, 0, sizeof (siginfo_t
));
101 * The absolute minimum content is si_signo and si_code.
103 dst
->si_signo
= src
->si_signo
;
104 if ((dst
->si_code
= src
->si_code
) == SI_NOINFO
)
108 * A siginfo generated by user level is structured
109 * differently from one generated by the kernel.
111 if (SI_FROMUSER(src
)) {
112 dst
->si_pid
= src
->si_pid
;
113 dst
->si_ctid
= src
->si_ctid
;
114 dst
->si_zoneid
= src
->si_zoneid
;
115 dst
->si_uid
= src
->si_uid
;
116 if (SI_CANQUEUE(src
->si_code
)) {
117 dst
->si_value
.sival_int
=
118 (long)(uint32_t)src
->si_value
.sival_int
;
123 dst
->si_errno
= src
->si_errno
;
125 switch (src
->si_signo
) {
127 dst
->si_pid
= src
->si_pid
;
128 dst
->si_ctid
= src
->si_ctid
;
129 dst
->si_zoneid
= src
->si_zoneid
;
130 dst
->si_uid
= src
->si_uid
;
131 dst
->si_value
.sival_int
=
132 (long)(uint32_t)src
->si_value
.sival_int
;
135 dst
->si_pid
= src
->si_pid
;
136 dst
->si_ctid
= src
->si_ctid
;
137 dst
->si_zoneid
= src
->si_zoneid
;
138 dst
->si_status
= src
->si_status
;
139 dst
->si_stime
= src
->si_stime
;
140 dst
->si_utime
= src
->si_utime
;
148 dst
->si_addr
= (void *)(uintptr_t)src
->si_addr
;
149 dst
->si_trapno
= src
->si_trapno
;
150 dst
->si_pc
= (void *)(uintptr_t)src
->si_pc
;
154 dst
->si_fd
= src
->si_fd
;
155 dst
->si_band
= src
->si_band
;
158 dst
->si_faddr
= (void *)(uintptr_t)src
->si_faddr
;
159 dst
->si_tstamp
.tv_sec
= src
->si_tstamp
.tv_sec
;
160 dst
->si_tstamp
.tv_nsec
= src
->si_tstamp
.tv_nsec
;
161 dst
->si_syscall
= src
->si_syscall
;
162 dst
->si_nsysarg
= src
->si_nsysarg
;
163 dst
->si_fault
= src
->si_fault
;
169 auxv_32_to_n(const auxv32_t
*src
, auxv_t
*dst
)
172 * This is a little sketchy: we have three types of values stored
173 * in an auxv (long, void *, and void (*)()) so the only sign-extension
174 * issue is with the long. We could case on all possible AT_* types,
175 * but this seems silly since currently none of the types which use
176 * a_un.a_val actually use negative numbers as a value. For this
177 * reason, it seems simpler to just do an unsigned expansion for now.
179 dst
->a_type
= src
->a_type
;
180 dst
->a_un
.a_ptr
= (void *)(uintptr_t)src
->a_un
.a_ptr
;
185 rwindow_32_to_n(const struct rwindow32
*src
, struct rwindow
*dst
)
189 for (i
= 0; i
< 8; i
++) {
190 dst
->rw_local
[i
] = (uint64_t)(uint32_t)src
->rw_local
[i
];
191 dst
->rw_in
[i
] = (uint64_t)(uint32_t)src
->rw_in
[i
];
196 gwindows_32_to_n(const gwindows32_t
*src
, gwindows_t
*dst
)
200 (void) memset(dst
, 0, sizeof (gwindows_t
));
201 dst
->wbcnt
= src
->wbcnt
;
203 for (i
= 0; i
< src
->wbcnt
; i
++) {
204 if (src
->spbuf
[i
] != 0) {
205 rwindow_32_to_n(&src
->wbuf
[i
], &dst
->wbuf
[i
]);
206 dst
->spbuf
[i
] = (greg_t
*)(uintptr_t)src
->spbuf
[i
];
213 prgregset_32_to_n(const prgreg32_t
*src
, prgreg_t
*dst
)
216 (void) memset(dst
, 0, NPRGREG
* sizeof (prgreg_t
));
217 dst
[REG_GS
] = (uint32_t)src
[GS
];
218 dst
[REG_FS
] = (uint32_t)src
[FS
];
219 dst
[REG_DS
] = (uint32_t)src
[DS
];
220 dst
[REG_ES
] = (uint32_t)src
[ES
];
221 dst
[REG_RDI
] = (uint32_t)src
[EDI
];
222 dst
[REG_RSI
] = (uint32_t)src
[ESI
];
223 dst
[REG_RBP
] = (uint32_t)src
[EBP
];
224 dst
[REG_RBX
] = (uint32_t)src
[EBX
];
225 dst
[REG_RDX
] = (uint32_t)src
[EDX
];
226 dst
[REG_RCX
] = (uint32_t)src
[ECX
];
227 dst
[REG_RAX
] = (uint32_t)src
[EAX
];
228 dst
[REG_TRAPNO
] = (uint32_t)src
[TRAPNO
];
229 dst
[REG_ERR
] = (uint32_t)src
[ERR
];
230 dst
[REG_RIP
] = (uint32_t)src
[EIP
];
231 dst
[REG_CS
] = (uint32_t)src
[CS
];
232 dst
[REG_RFL
] = (uint32_t)src
[EFL
];
233 dst
[REG_RSP
] = (uint32_t)src
[UESP
];
234 dst
[REG_SS
] = (uint32_t)src
[SS
];
238 for (i
= 0; i
< NPRGREG
; i
++)
239 dst
[i
] = (prgreg_t
)(uint32_t)src
[i
];
244 prfpregset_32_to_n(const prfpregset32_t
*src
, prfpregset_t
*dst
)
249 (void) memset(dst
, 0, sizeof (prfpregset_t
));
251 for (i
= 0; i
< 32; i
++)
252 dst
->pr_fr
.pr_regs
[i
] = src
->pr_fr
.pr_regs
[i
];
255 * We deliberately do not convert pr_qcnt or pr_q because it is a long-
256 * standing /proc bug that this information is not exported, and another
257 * bug further caused these values to be returned as uninitialized data
258 * when the 64-bit kernel exported them for a 32-bit process with en=0.
260 dst
->pr_filler
= src
->pr_filler
;
261 dst
->pr_fsr
= src
->pr_fsr
;
262 dst
->pr_q_entrysize
= src
->pr_q_entrysize
;
263 dst
->pr_en
= src
->pr_en
;
265 #elif defined(__amd64)
267 struct _fpstate32
*src32
= (struct _fpstate32
*)src
;
268 struct _fpchip_state
*dst64
= (struct _fpchip_state
*)dst
;
271 (void) memcpy(dst64
->st
, src32
->_st
, sizeof (src32
->_st
));
272 (void) memcpy(dst64
->xmm
, src32
->xmm
, sizeof (src32
->xmm
));
273 (void) memset((caddr_t
)dst64
->xmm
+ sizeof (src32
->xmm
), 0,
274 sizeof (dst64
->xmm
) - sizeof (src32
->xmm
));
275 dst64
->cw
= (uint16_t)src32
->cw
;
276 dst64
->sw
= (uint16_t)src32
->sw
;
278 dst64
->rip
= src32
->ipoff
;
279 dst64
->rdp
= src32
->dataoff
;
280 dst64
->mxcsr
= src32
->mxcsr
;
281 dst64
->mxcsr_mask
= 0;
282 dst64
->status
= src32
->status
;
283 dst64
->xstatus
= src32
->xstatus
;
286 * Converting from the tag field to the compressed fctw is easy.
287 * If the two tag bits are 3, then the register is empty and we
288 * clear the bit in fctw. Otherwise we set the bit.
292 for (i
= 0; i
< 8; i
++)
293 if (((src32
->tag
>> (i
* 2)) & 3) != 3)
294 dst64
->fctw
|= 1 << i
;
296 #error "unrecognized ISA"
301 lwpstatus_32_to_n(const lwpstatus32_t
*src
, lwpstatus_t
*dst
)
305 dst
->pr_flags
= src
->pr_flags
;
306 dst
->pr_lwpid
= src
->pr_lwpid
;
307 dst
->pr_why
= src
->pr_why
;
308 dst
->pr_what
= src
->pr_what
;
309 dst
->pr_cursig
= src
->pr_cursig
;
311 siginfo_32_to_n(&src
->pr_info
, &dst
->pr_info
);
313 dst
->pr_lwppend
= src
->pr_lwppend
;
314 dst
->pr_lwphold
= src
->pr_lwphold
;
316 sigaction_32_to_n(&src
->pr_action
, &dst
->pr_action
);
317 stack_32_to_n(&src
->pr_altstack
, &dst
->pr_altstack
);
319 dst
->pr_oldcontext
= src
->pr_oldcontext
;
320 dst
->pr_syscall
= src
->pr_syscall
;
321 dst
->pr_nsysarg
= src
->pr_nsysarg
;
322 dst
->pr_errno
= src
->pr_errno
;
324 for (i
= 0; i
< PRSYSARGS
; i
++)
325 dst
->pr_sysarg
[i
] = (long)(uint32_t)src
->pr_sysarg
[i
];
327 dst
->pr_rval1
= (long)(uint32_t)src
->pr_rval1
;
328 dst
->pr_rval2
= (long)(uint32_t)src
->pr_rval2
;
330 (void) memcpy(&dst
->pr_clname
[0], &src
->pr_clname
[0], PRCLSZ
);
331 timestruc_32_to_n(&src
->pr_tstamp
, &dst
->pr_tstamp
);
333 dst
->pr_ustack
= src
->pr_ustack
;
334 dst
->pr_instr
= src
->pr_instr
;
336 prgregset_32_to_n(src
->pr_reg
, dst
->pr_reg
);
337 prfpregset_32_to_n(&src
->pr_fpreg
, &dst
->pr_fpreg
);
341 pstatus_32_to_n(const pstatus32_t
*src
, pstatus_t
*dst
)
343 dst
->pr_flags
= src
->pr_flags
;
344 dst
->pr_nlwp
= src
->pr_nlwp
;
345 dst
->pr_nzomb
= src
->pr_nzomb
;
346 dst
->pr_pid
= src
->pr_pid
;
347 dst
->pr_ppid
= src
->pr_ppid
;
348 dst
->pr_pgid
= src
->pr_pgid
;
349 dst
->pr_sid
= src
->pr_sid
;
350 dst
->pr_taskid
= src
->pr_taskid
;
351 dst
->pr_projid
= src
->pr_projid
;
352 dst
->pr_zoneid
= src
->pr_zoneid
;
353 dst
->pr_aslwpid
= src
->pr_aslwpid
;
354 dst
->pr_agentid
= src
->pr_agentid
;
355 dst
->pr_sigpend
= src
->pr_sigpend
;
356 dst
->pr_brkbase
= src
->pr_brkbase
;
357 dst
->pr_brksize
= src
->pr_brksize
;
358 dst
->pr_stkbase
= src
->pr_stkbase
;
359 dst
->pr_stksize
= src
->pr_stksize
;
361 timestruc_32_to_n(&src
->pr_utime
, &dst
->pr_utime
);
362 timestruc_32_to_n(&src
->pr_stime
, &dst
->pr_stime
);
363 timestruc_32_to_n(&src
->pr_cutime
, &dst
->pr_cutime
);
364 timestruc_32_to_n(&src
->pr_cstime
, &dst
->pr_cstime
);
366 dst
->pr_sigtrace
= src
->pr_sigtrace
;
367 dst
->pr_flttrace
= src
->pr_flttrace
;
368 dst
->pr_sysentry
= src
->pr_sysentry
;
369 dst
->pr_sysexit
= src
->pr_sysexit
;
370 dst
->pr_dmodel
= src
->pr_dmodel
;
372 lwpstatus_32_to_n(&src
->pr_lwp
, &dst
->pr_lwp
);
376 lwpsinfo_32_to_n(const lwpsinfo32_t
*src
, lwpsinfo_t
*dst
)
378 dst
->pr_flag
= src
->pr_flag
;
379 dst
->pr_lwpid
= src
->pr_lwpid
;
380 dst
->pr_addr
= src
->pr_addr
;
381 dst
->pr_wchan
= src
->pr_wchan
;
382 dst
->pr_stype
= src
->pr_stype
;
383 dst
->pr_state
= src
->pr_state
;
384 dst
->pr_sname
= src
->pr_sname
;
385 dst
->pr_nice
= src
->pr_nice
;
386 dst
->pr_syscall
= src
->pr_syscall
;
387 dst
->pr_oldpri
= src
->pr_oldpri
;
388 dst
->pr_cpu
= src
->pr_cpu
;
389 dst
->pr_pri
= src
->pr_pri
;
390 dst
->pr_pctcpu
= src
->pr_pctcpu
;
392 timestruc_32_to_n(&src
->pr_start
, &dst
->pr_start
);
393 timestruc_32_to_n(&src
->pr_time
, &dst
->pr_time
);
395 (void) memcpy(&dst
->pr_clname
[0], &src
->pr_clname
[0], PRCLSZ
);
396 (void) memcpy(&dst
->pr_name
[0], &src
->pr_name
[0], PRFNSZ
);
398 dst
->pr_onpro
= src
->pr_onpro
;
399 dst
->pr_bindpro
= src
->pr_bindpro
;
400 dst
->pr_bindpset
= src
->pr_bindpset
;
401 dst
->pr_lgrp
= src
->pr_lgrp
;
405 psinfo_32_to_n(const psinfo32_t
*src
, psinfo_t
*dst
)
407 dst
->pr_flag
= src
->pr_flag
;
408 dst
->pr_nlwp
= src
->pr_nlwp
;
409 dst
->pr_nzomb
= src
->pr_nzomb
;
410 dst
->pr_pid
= src
->pr_pid
;
411 dst
->pr_pgid
= src
->pr_pgid
;
412 dst
->pr_sid
= src
->pr_sid
;
413 dst
->pr_taskid
= src
->pr_taskid
;
414 dst
->pr_projid
= src
->pr_projid
;
415 dst
->pr_zoneid
= src
->pr_zoneid
;
416 dst
->pr_uid
= src
->pr_uid
;
417 dst
->pr_euid
= src
->pr_euid
;
418 dst
->pr_gid
= src
->pr_gid
;
419 dst
->pr_egid
= src
->pr_egid
;
420 dst
->pr_addr
= src
->pr_addr
;
421 dst
->pr_size
= src
->pr_size
;
422 dst
->pr_rssize
= src
->pr_rssize
;
424 dst
->pr_ttydev
= prexpldev(src
->pr_ttydev
);
426 dst
->pr_pctcpu
= src
->pr_pctcpu
;
427 dst
->pr_pctmem
= src
->pr_pctmem
;
429 timestruc_32_to_n(&src
->pr_start
, &dst
->pr_start
);
430 timestruc_32_to_n(&src
->pr_time
, &dst
->pr_time
);
431 timestruc_32_to_n(&src
->pr_ctime
, &dst
->pr_ctime
);
433 (void) memcpy(&dst
->pr_fname
[0], &src
->pr_fname
[0], PRFNSZ
);
434 (void) memcpy(&dst
->pr_psargs
[0], &src
->pr_psargs
[0], PRARGSZ
);
436 dst
->pr_wstat
= src
->pr_wstat
;
437 dst
->pr_argc
= src
->pr_argc
;
438 dst
->pr_argv
= src
->pr_argv
;
439 dst
->pr_envp
= src
->pr_envp
;
440 dst
->pr_dmodel
= src
->pr_dmodel
;
442 lwpsinfo_32_to_n(&src
->pr_lwp
, &dst
->pr_lwp
);
446 timestruc_n_to_32(const timestruc_t
*src
, timestruc32_t
*dst
)
448 dst
->tv_sec
= (time32_t
)src
->tv_sec
;
449 dst
->tv_nsec
= (int32_t)src
->tv_nsec
;
453 stack_n_to_32(const stack_t
*src
, stack32_t
*dst
)
455 dst
->ss_sp
= (caddr32_t
)(uintptr_t)src
->ss_sp
;
456 dst
->ss_size
= src
->ss_size
;
457 dst
->ss_flags
= src
->ss_flags
;
461 sigaction_n_to_32(const struct sigaction
*src
, struct sigaction32
*dst
)
463 (void) memset(dst
, 0, sizeof (struct sigaction32
));
464 dst
->sa_flags
= src
->sa_flags
;
465 dst
->sa_handler
= (caddr32_t
)(uintptr_t)src
->sa_handler
;
466 (void) memcpy(&dst
->sa_mask
, &src
->sa_mask
, sizeof (dst
->sa_mask
));
470 siginfo_n_to_32(const siginfo_t
*src
, siginfo32_t
*dst
)
472 (void) memset(dst
, 0, sizeof (siginfo32_t
));
475 * The absolute minimum content is si_signo and si_code.
477 dst
->si_signo
= src
->si_signo
;
478 if ((dst
->si_code
= src
->si_code
) == SI_NOINFO
)
482 * A siginfo generated by user level is structured
483 * differently from one generated by the kernel.
485 if (SI_FROMUSER(src
)) {
486 dst
->si_pid
= src
->si_pid
;
487 dst
->si_ctid
= src
->si_ctid
;
488 dst
->si_zoneid
= src
->si_zoneid
;
489 dst
->si_uid
= src
->si_uid
;
490 if (SI_CANQUEUE(src
->si_code
)) {
491 dst
->si_value
.sival_int
=
492 (int32_t)src
->si_value
.sival_int
;
497 dst
->si_errno
= src
->si_errno
;
499 switch (src
->si_signo
) {
501 dst
->si_pid
= src
->si_pid
;
502 dst
->si_ctid
= src
->si_ctid
;
503 dst
->si_zoneid
= src
->si_zoneid
;
504 dst
->si_uid
= src
->si_uid
;
505 dst
->si_value
.sival_int
=
506 (int32_t)src
->si_value
.sival_int
;
509 dst
->si_pid
= src
->si_pid
;
510 dst
->si_ctid
= src
->si_ctid
;
511 dst
->si_zoneid
= src
->si_zoneid
;
512 dst
->si_status
= src
->si_status
;
513 dst
->si_stime
= src
->si_stime
;
514 dst
->si_utime
= src
->si_utime
;
522 dst
->si_addr
= (caddr32_t
)(uintptr_t)src
->si_addr
;
523 dst
->si_trapno
= src
->si_trapno
;
524 dst
->si_pc
= (caddr32_t
)(uintptr_t)src
->si_pc
;
528 dst
->si_fd
= src
->si_fd
;
529 dst
->si_band
= src
->si_band
;
532 dst
->si_faddr
= (caddr32_t
)(uintptr_t)src
->si_faddr
;
533 dst
->si_tstamp
.tv_sec
= src
->si_tstamp
.tv_sec
;
534 dst
->si_tstamp
.tv_nsec
= src
->si_tstamp
.tv_nsec
;
535 dst
->si_syscall
= src
->si_syscall
;
536 dst
->si_nsysarg
= src
->si_nsysarg
;
537 dst
->si_fault
= src
->si_fault
;
543 auxv_n_to_32(const auxv_t
*src
, auxv32_t
*dst
)
545 dst
->a_type
= src
->a_type
;
546 dst
->a_un
.a_ptr
= (caddr32_t
)(uintptr_t)src
->a_un
.a_ptr
;
550 prgregset_n_to_32(const prgreg_t
*src
, prgreg32_t
*dst
)
553 (void) memset(dst
, 0, NPRGREG32
* sizeof (prgreg32_t
));
554 dst
[GS
] = src
[REG_GS
];
555 dst
[FS
] = src
[REG_FS
];
556 dst
[DS
] = src
[REG_DS
];
557 dst
[ES
] = src
[REG_ES
];
558 dst
[EDI
] = src
[REG_RDI
];
559 dst
[ESI
] = src
[REG_RSI
];
560 dst
[EBP
] = src
[REG_RBP
];
561 dst
[EBX
] = src
[REG_RBX
];
562 dst
[EDX
] = src
[REG_RDX
];
563 dst
[ECX
] = src
[REG_RCX
];
564 dst
[EAX
] = src
[REG_RAX
];
565 dst
[TRAPNO
] = src
[REG_TRAPNO
];
566 dst
[ERR
] = src
[REG_ERR
];
567 dst
[EIP
] = src
[REG_RIP
];
568 dst
[CS
] = src
[REG_CS
];
569 dst
[EFL
] = src
[REG_RFL
];
570 dst
[UESP
] = src
[REG_RSP
];
571 dst
[SS
] = src
[REG_SS
];
575 for (i
= 0; i
< NPRGREG
; i
++)
576 dst
[i
] = (prgreg32_t
)src
[i
];
581 prfpregset_n_to_32(const prfpregset_t
*src
, prfpregset32_t
*dst
)
586 (void) memset(dst
, 0, sizeof (prfpregset32_t
));
588 for (i
= 0; i
< 32; i
++)
589 dst
->pr_fr
.pr_regs
[i
] = src
->pr_fr
.pr_regs
[i
];
591 dst
->pr_filler
= src
->pr_filler
;
592 dst
->pr_fsr
= src
->pr_fsr
;
593 dst
->pr_q_entrysize
= src
->pr_q_entrysize
;
594 dst
->pr_en
= src
->pr_en
;
596 #elif defined(__amd64)
598 struct _fpstate32
*dst32
= (struct _fpstate32
*)dst
;
599 struct _fpchip_state
*src64
= (struct _fpchip_state
*)src
;
603 (void) memcpy(dst32
->_st
, src64
->st
, sizeof (dst32
->_st
));
604 (void) memcpy(dst32
->xmm
, src64
->xmm
, sizeof (dst32
->xmm
));
605 dst32
->cw
= src64
->cw
;
606 dst32
->sw
= src64
->sw
;
607 dst32
->ipoff
= (unsigned int)src64
->rip
;
609 dst32
->dataoff
= (unsigned int)src64
->rdp
;
611 dst32
->status
= src64
->status
;
612 dst32
->mxcsr
= src64
->mxcsr
;
613 dst32
->xstatus
= src64
->xstatus
;
616 * AMD64 stores the tag in a compressed form. It is
617 * necessary to extract the original 2-bit tag value.
618 * See AMD64 Architecture Programmer's Manual Volume 2:
619 * System Programming, Chapter 11.
622 top
= (src64
->sw
& FPS_TOP
) >> 11;
624 for (i
= 0; i
< 8; i
++) {
626 * Recall that we need to use the current TOP-of-stack value to
627 * associate the _st[] index back to a physical register number,
628 * since tag word indices are physical register numbers. Then
629 * to get the tag value, we shift over two bits for each tag
630 * index, and then grab the bottom two bits.
632 uint_t tag_index
= (i
+ top
) & 7;
633 uint_t tag_fctw
= (src64
->fctw
>> tag_index
) & 1;
638 * Union for overlaying _fpreg structure on to quad-precision
639 * floating-point value (long double).
646 fpru
.ld
= src64
->st
[i
].__fpr_pad
._q
;
647 exp
= fpru
.reg
.exponent
& 0x7fff;
650 tag_value
= 3; /* empty */
651 } else if (exp
== 0) {
652 if (fpru
.reg
.significand
[0] == 0 &&
653 fpru
.reg
.significand
[1] == 0 &&
654 fpru
.reg
.significand
[2] == 0 &&
655 fpru
.reg
.significand
[3] == 0)
656 tag_value
= 1; /* zero */
658 tag_value
= 2; /* special: denormal */
659 } else if (exp
== 0x7fff) {
660 tag_value
= 2; /* special: infinity or NaN */
661 } else if (fpru
.reg
.significand
[3] & 0x8000) {
662 tag_value
= 0; /* valid */
664 tag_value
= 2; /* special: unnormal */
666 dst32
->tag
|= tag_value
<< (tag_index
* 2);
669 #error "unrecognized ISA"
674 lwpstatus_n_to_32(const lwpstatus_t
*src
, lwpstatus32_t
*dst
)
678 dst
->pr_flags
= src
->pr_flags
;
679 dst
->pr_lwpid
= src
->pr_lwpid
;
680 dst
->pr_why
= src
->pr_why
;
681 dst
->pr_what
= src
->pr_what
;
682 dst
->pr_cursig
= src
->pr_cursig
;
684 siginfo_n_to_32(&src
->pr_info
, &dst
->pr_info
);
686 dst
->pr_lwppend
= src
->pr_lwppend
;
687 dst
->pr_lwphold
= src
->pr_lwphold
;
689 sigaction_n_to_32(&src
->pr_action
, &dst
->pr_action
);
690 stack_n_to_32(&src
->pr_altstack
, &dst
->pr_altstack
);
692 dst
->pr_oldcontext
= (caddr32_t
)src
->pr_oldcontext
;
693 dst
->pr_syscall
= src
->pr_syscall
;
694 dst
->pr_nsysarg
= src
->pr_nsysarg
;
695 dst
->pr_errno
= src
->pr_errno
;
697 for (i
= 0; i
< PRSYSARGS
; i
++)
698 dst
->pr_sysarg
[i
] = (int32_t)src
->pr_sysarg
[i
];
700 dst
->pr_rval1
= (int32_t)src
->pr_rval1
;
701 dst
->pr_rval2
= (int32_t)src
->pr_rval2
;
703 (void) memcpy(&dst
->pr_clname
[0], &src
->pr_clname
[0], PRCLSZ
);
704 timestruc_n_to_32(&src
->pr_tstamp
, &dst
->pr_tstamp
);
706 dst
->pr_ustack
= (caddr32_t
)src
->pr_ustack
;
707 dst
->pr_instr
= src
->pr_instr
;
709 prgregset_n_to_32(src
->pr_reg
, dst
->pr_reg
);
710 prfpregset_n_to_32(&src
->pr_fpreg
, &dst
->pr_fpreg
);
714 pstatus_n_to_32(const pstatus_t
*src
, pstatus32_t
*dst
)
716 dst
->pr_flags
= src
->pr_flags
;
717 dst
->pr_nlwp
= src
->pr_nlwp
;
718 dst
->pr_nzomb
= src
->pr_nzomb
;
719 dst
->pr_pid
= (pid32_t
)src
->pr_pid
;
720 dst
->pr_ppid
= (pid32_t
)src
->pr_ppid
;
721 dst
->pr_pgid
= (pid32_t
)src
->pr_pgid
;
722 dst
->pr_sid
= (pid32_t
)src
->pr_sid
;
723 dst
->pr_taskid
= (id32_t
)src
->pr_taskid
;
724 dst
->pr_projid
= (id32_t
)src
->pr_projid
;
725 dst
->pr_zoneid
= (id32_t
)src
->pr_zoneid
;
726 dst
->pr_aslwpid
= (id32_t
)src
->pr_aslwpid
;
727 dst
->pr_agentid
= (id32_t
)src
->pr_agentid
;
728 dst
->pr_sigpend
= src
->pr_sigpend
;
729 dst
->pr_brkbase
= (caddr32_t
)src
->pr_brkbase
;
730 dst
->pr_brksize
= (size32_t
)src
->pr_brksize
;
731 dst
->pr_stkbase
= (caddr32_t
)src
->pr_stkbase
;
732 dst
->pr_stksize
= (size32_t
)src
->pr_stksize
;
734 timestruc_n_to_32(&src
->pr_utime
, &dst
->pr_utime
);
735 timestruc_n_to_32(&src
->pr_stime
, &dst
->pr_stime
);
736 timestruc_n_to_32(&src
->pr_cutime
, &dst
->pr_cutime
);
737 timestruc_n_to_32(&src
->pr_cstime
, &dst
->pr_cstime
);
739 dst
->pr_sigtrace
= src
->pr_sigtrace
;
740 dst
->pr_flttrace
= src
->pr_flttrace
;
741 dst
->pr_sysentry
= src
->pr_sysentry
;
742 dst
->pr_sysexit
= src
->pr_sysexit
;
743 dst
->pr_dmodel
= src
->pr_dmodel
;
745 lwpstatus_n_to_32(&src
->pr_lwp
, &dst
->pr_lwp
);
749 lwpsinfo_n_to_32(const lwpsinfo_t
*src
, lwpsinfo32_t
*dst
)
751 dst
->pr_flag
= src
->pr_flag
;
752 dst
->pr_lwpid
= (id32_t
)src
->pr_lwpid
;
753 dst
->pr_addr
= (caddr32_t
)src
->pr_addr
;
754 dst
->pr_wchan
= (caddr32_t
)src
->pr_wchan
;
755 dst
->pr_stype
= src
->pr_stype
;
756 dst
->pr_state
= src
->pr_state
;
757 dst
->pr_sname
= src
->pr_sname
;
758 dst
->pr_nice
= src
->pr_nice
;
759 dst
->pr_syscall
= src
->pr_syscall
;
760 dst
->pr_oldpri
= src
->pr_oldpri
;
761 dst
->pr_cpu
= src
->pr_cpu
;
762 dst
->pr_pri
= src
->pr_pri
;
763 dst
->pr_pctcpu
= src
->pr_pctcpu
;
765 timestruc_n_to_32(&src
->pr_start
, &dst
->pr_start
);
766 timestruc_n_to_32(&src
->pr_time
, &dst
->pr_time
);
768 (void) memcpy(&dst
->pr_clname
[0], &src
->pr_clname
[0], PRCLSZ
);
769 (void) memcpy(&dst
->pr_name
[0], &src
->pr_name
[0], PRFNSZ
);
771 dst
->pr_onpro
= src
->pr_onpro
;
772 dst
->pr_bindpro
= src
->pr_bindpro
;
773 dst
->pr_bindpset
= src
->pr_bindpset
;
774 dst
->pr_lgrp
= src
->pr_lgrp
;
778 psinfo_n_to_32(const psinfo_t
*src
, psinfo32_t
*dst
)
780 dst
->pr_flag
= src
->pr_flag
;
781 dst
->pr_nlwp
= src
->pr_nlwp
;
782 dst
->pr_nzomb
= src
->pr_nzomb
;
783 dst
->pr_pid
= (pid32_t
)src
->pr_pid
;
784 dst
->pr_pgid
= (pid32_t
)src
->pr_pgid
;
785 dst
->pr_sid
= (pid32_t
)src
->pr_sid
;
786 dst
->pr_taskid
= (id32_t
)src
->pr_taskid
;
787 dst
->pr_projid
= (id32_t
)src
->pr_projid
;
788 dst
->pr_zoneid
= (id32_t
)src
->pr_zoneid
;
789 dst
->pr_uid
= (uid32_t
)src
->pr_uid
;
790 dst
->pr_euid
= (uid32_t
)src
->pr_euid
;
791 dst
->pr_gid
= (gid32_t
)src
->pr_gid
;
792 dst
->pr_egid
= (gid32_t
)src
->pr_egid
;
793 dst
->pr_addr
= (caddr32_t
)src
->pr_addr
;
794 dst
->pr_size
= (size32_t
)src
->pr_size
;
795 dst
->pr_rssize
= (size32_t
)src
->pr_rssize
;
797 dst
->pr_ttydev
= prcmpldev(src
->pr_ttydev
);
799 dst
->pr_pctcpu
= src
->pr_pctcpu
;
800 dst
->pr_pctmem
= src
->pr_pctmem
;
802 timestruc_n_to_32(&src
->pr_start
, &dst
->pr_start
);
803 timestruc_n_to_32(&src
->pr_time
, &dst
->pr_time
);
804 timestruc_n_to_32(&src
->pr_ctime
, &dst
->pr_ctime
);
806 (void) memcpy(&dst
->pr_fname
[0], &src
->pr_fname
[0], PRFNSZ
);
807 (void) memcpy(&dst
->pr_psargs
[0], &src
->pr_psargs
[0], PRARGSZ
);
809 dst
->pr_wstat
= src
->pr_wstat
;
810 dst
->pr_argc
= src
->pr_argc
;
811 dst
->pr_argv
= (caddr32_t
)src
->pr_argv
;
812 dst
->pr_envp
= (caddr32_t
)src
->pr_envp
;
813 dst
->pr_dmodel
= src
->pr_dmodel
;
815 lwpsinfo_n_to_32(&src
->pr_lwp
, &dst
->pr_lwp
);