17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*c6402783Sakolb * Common Development and Distribution License (the "License"). 6*c6402783Sakolb * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 2175521904Sraf 227c478bd9Sstevel@tonic-gate /* 23*c6402783Sakolb * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #include <sys/types.h> 307c478bd9Sstevel@tonic-gate #include <sys/mkdev.h> 317c478bd9Sstevel@tonic-gate #include <sys/regset.h> 327c478bd9Sstevel@tonic-gate #include <string.h> 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate #if defined(__amd64) 357c478bd9Sstevel@tonic-gate #include <sys/fp.h> 367c478bd9Sstevel@tonic-gate #include <ieeefp.h> 377c478bd9Sstevel@tonic-gate #endif 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate #include "P32ton.h" 407c478bd9Sstevel@tonic-gate 417c478bd9Sstevel@tonic-gate dev_t 427c478bd9Sstevel@tonic-gate prexpldev(dev32_t d) 437c478bd9Sstevel@tonic-gate { 447c478bd9Sstevel@tonic-gate if (d != (dev32_t)-1L) 457c478bd9Sstevel@tonic-gate return (makedev((d >> NBITSMINOR32) & MAXMAJ32, d & MAXMIN32)); 467c478bd9Sstevel@tonic-gate 477c478bd9Sstevel@tonic-gate return ((dev_t)PRNODEV); 487c478bd9Sstevel@tonic-gate } 497c478bd9Sstevel@tonic-gate 507c478bd9Sstevel@tonic-gate 517c478bd9Sstevel@tonic-gate dev32_t 527c478bd9Sstevel@tonic-gate prcmpldev(dev_t d) 537c478bd9Sstevel@tonic-gate { 547c478bd9Sstevel@tonic-gate #ifdef _LP64 557c478bd9Sstevel@tonic-gate if (d == PRNODEV) { 567c478bd9Sstevel@tonic-gate return (PRNODEV32); 577c478bd9Sstevel@tonic-gate } else { 587c478bd9Sstevel@tonic-gate major_t maj = major(d); 597c478bd9Sstevel@tonic-gate minor_t min = minor(d); 607c478bd9Sstevel@tonic-gate 617c478bd9Sstevel@tonic-gate if (maj == (major_t)PRNODEV || min == (minor_t)PRNODEV) 627c478bd9Sstevel@tonic-gate return (PRNODEV32); 637c478bd9Sstevel@tonic-gate 647c478bd9Sstevel@tonic-gate return ((dev32_t)((maj << NBITSMINOR32) | min)); 657c478bd9Sstevel@tonic-gate } 667c478bd9Sstevel@tonic-gate #else 677c478bd9Sstevel@tonic-gate return ((dev32_t)d); 687c478bd9Sstevel@tonic-gate #endif 697c478bd9Sstevel@tonic-gate } 707c478bd9Sstevel@tonic-gate 717c478bd9Sstevel@tonic-gate #ifdef _LP64 727c478bd9Sstevel@tonic-gate 737c478bd9Sstevel@tonic-gate void 747c478bd9Sstevel@tonic-gate timestruc_32_to_n(const timestruc32_t *src, timestruc_t *dst) 757c478bd9Sstevel@tonic-gate { 767c478bd9Sstevel@tonic-gate dst->tv_sec = (time_t)(uint32_t)src->tv_sec; 777c478bd9Sstevel@tonic-gate dst->tv_nsec = (long)(uint32_t)src->tv_nsec; 787c478bd9Sstevel@tonic-gate } 797c478bd9Sstevel@tonic-gate 807c478bd9Sstevel@tonic-gate void 817c478bd9Sstevel@tonic-gate stack_32_to_n(const stack32_t *src, stack_t *dst) 827c478bd9Sstevel@tonic-gate { 837c478bd9Sstevel@tonic-gate dst->ss_sp = (caddr_t)(uintptr_t)src->ss_sp; 847c478bd9Sstevel@tonic-gate dst->ss_size = src->ss_size; 857c478bd9Sstevel@tonic-gate dst->ss_flags = src->ss_flags; 867c478bd9Sstevel@tonic-gate } 877c478bd9Sstevel@tonic-gate 887c478bd9Sstevel@tonic-gate void 897c478bd9Sstevel@tonic-gate sigaction_32_to_n(const struct sigaction32 *src, struct sigaction *dst) 907c478bd9Sstevel@tonic-gate { 917c478bd9Sstevel@tonic-gate (void) memset(dst, 0, sizeof (struct sigaction)); 927c478bd9Sstevel@tonic-gate dst->sa_flags = src->sa_flags; 937c478bd9Sstevel@tonic-gate dst->sa_handler = (void (*)())(uintptr_t)src->sa_handler; 947c478bd9Sstevel@tonic-gate (void) memcpy(&dst->sa_mask, &src->sa_mask, sizeof (dst->sa_mask)); 957c478bd9Sstevel@tonic-gate } 967c478bd9Sstevel@tonic-gate 977c478bd9Sstevel@tonic-gate void 987c478bd9Sstevel@tonic-gate siginfo_32_to_n(const siginfo32_t *src, siginfo_t *dst) 997c478bd9Sstevel@tonic-gate { 1007c478bd9Sstevel@tonic-gate (void) memset(dst, 0, sizeof (siginfo_t)); 1017c478bd9Sstevel@tonic-gate 1027c478bd9Sstevel@tonic-gate /* 1037c478bd9Sstevel@tonic-gate * The absolute minimum content is si_signo and si_code. 1047c478bd9Sstevel@tonic-gate */ 1057c478bd9Sstevel@tonic-gate dst->si_signo = src->si_signo; 1067c478bd9Sstevel@tonic-gate if ((dst->si_code = src->si_code) == SI_NOINFO) 1077c478bd9Sstevel@tonic-gate return; 1087c478bd9Sstevel@tonic-gate 1097c478bd9Sstevel@tonic-gate /* 1107c478bd9Sstevel@tonic-gate * A siginfo generated by user level is structured 1117c478bd9Sstevel@tonic-gate * differently from one generated by the kernel. 1127c478bd9Sstevel@tonic-gate */ 1137c478bd9Sstevel@tonic-gate if (SI_FROMUSER(src)) { 1147c478bd9Sstevel@tonic-gate dst->si_pid = src->si_pid; 1157c478bd9Sstevel@tonic-gate dst->si_ctid = src->si_ctid; 1167c478bd9Sstevel@tonic-gate dst->si_zoneid = src->si_zoneid; 1177c478bd9Sstevel@tonic-gate dst->si_uid = src->si_uid; 1187c478bd9Sstevel@tonic-gate if (SI_CANQUEUE(src->si_code)) { 1197c478bd9Sstevel@tonic-gate dst->si_value.sival_int = 1207c478bd9Sstevel@tonic-gate (long)(uint32_t)src->si_value.sival_int; 1217c478bd9Sstevel@tonic-gate } 1227c478bd9Sstevel@tonic-gate return; 1237c478bd9Sstevel@tonic-gate } 1247c478bd9Sstevel@tonic-gate 1257c478bd9Sstevel@tonic-gate dst->si_errno = src->si_errno; 1267c478bd9Sstevel@tonic-gate 1277c478bd9Sstevel@tonic-gate switch (src->si_signo) { 1287c478bd9Sstevel@tonic-gate default: 1297c478bd9Sstevel@tonic-gate dst->si_pid = src->si_pid; 1307c478bd9Sstevel@tonic-gate dst->si_ctid = src->si_ctid; 1317c478bd9Sstevel@tonic-gate dst->si_zoneid = src->si_zoneid; 1327c478bd9Sstevel@tonic-gate dst->si_uid = src->si_uid; 1337c478bd9Sstevel@tonic-gate dst->si_value.sival_int = 1347c478bd9Sstevel@tonic-gate (long)(uint32_t)src->si_value.sival_int; 1357c478bd9Sstevel@tonic-gate break; 1367c478bd9Sstevel@tonic-gate case SIGCLD: 1377c478bd9Sstevel@tonic-gate dst->si_pid = src->si_pid; 1387c478bd9Sstevel@tonic-gate dst->si_ctid = src->si_ctid; 1397c478bd9Sstevel@tonic-gate dst->si_zoneid = src->si_zoneid; 1407c478bd9Sstevel@tonic-gate dst->si_status = src->si_status; 1417c478bd9Sstevel@tonic-gate dst->si_stime = src->si_stime; 1427c478bd9Sstevel@tonic-gate dst->si_utime = src->si_utime; 1437c478bd9Sstevel@tonic-gate break; 1447c478bd9Sstevel@tonic-gate case SIGSEGV: 1457c478bd9Sstevel@tonic-gate case SIGBUS: 1467c478bd9Sstevel@tonic-gate case SIGILL: 1477c478bd9Sstevel@tonic-gate case SIGTRAP: 1487c478bd9Sstevel@tonic-gate case SIGFPE: 1497c478bd9Sstevel@tonic-gate case SIGEMT: 1507c478bd9Sstevel@tonic-gate dst->si_addr = (void *)(uintptr_t)src->si_addr; 1517c478bd9Sstevel@tonic-gate dst->si_trapno = src->si_trapno; 1527c478bd9Sstevel@tonic-gate dst->si_pc = (void *)(uintptr_t)src->si_pc; 1537c478bd9Sstevel@tonic-gate break; 1547c478bd9Sstevel@tonic-gate case SIGPOLL: 1557c478bd9Sstevel@tonic-gate case SIGXFSZ: 1567c478bd9Sstevel@tonic-gate dst->si_fd = src->si_fd; 1577c478bd9Sstevel@tonic-gate dst->si_band = src->si_band; 1587c478bd9Sstevel@tonic-gate break; 1597c478bd9Sstevel@tonic-gate case SIGPROF: 1607c478bd9Sstevel@tonic-gate dst->si_faddr = (void *)(uintptr_t)src->si_faddr; 1617c478bd9Sstevel@tonic-gate dst->si_tstamp.tv_sec = src->si_tstamp.tv_sec; 1627c478bd9Sstevel@tonic-gate dst->si_tstamp.tv_nsec = src->si_tstamp.tv_nsec; 1637c478bd9Sstevel@tonic-gate dst->si_syscall = src->si_syscall; 1647c478bd9Sstevel@tonic-gate dst->si_nsysarg = src->si_nsysarg; 1657c478bd9Sstevel@tonic-gate dst->si_fault = src->si_fault; 1667c478bd9Sstevel@tonic-gate break; 1677c478bd9Sstevel@tonic-gate } 1687c478bd9Sstevel@tonic-gate } 1697c478bd9Sstevel@tonic-gate 1707c478bd9Sstevel@tonic-gate void 1717c478bd9Sstevel@tonic-gate auxv_32_to_n(const auxv32_t *src, auxv_t *dst) 1727c478bd9Sstevel@tonic-gate { 1737c478bd9Sstevel@tonic-gate /* 1747c478bd9Sstevel@tonic-gate * This is a little sketchy: we have three types of values stored 1757c478bd9Sstevel@tonic-gate * in an auxv (long, void *, and void (*)()) so the only sign-extension 1767c478bd9Sstevel@tonic-gate * issue is with the long. We could case on all possible AT_* types, 1777c478bd9Sstevel@tonic-gate * but this seems silly since currently none of the types which use 1787c478bd9Sstevel@tonic-gate * a_un.a_val actually use negative numbers as a value. For this 1797c478bd9Sstevel@tonic-gate * reason, it seems simpler to just do an unsigned expansion for now. 1807c478bd9Sstevel@tonic-gate */ 1817c478bd9Sstevel@tonic-gate dst->a_type = src->a_type; 1827c478bd9Sstevel@tonic-gate dst->a_un.a_ptr = (void *)(uintptr_t)src->a_un.a_ptr; 1837c478bd9Sstevel@tonic-gate } 1847c478bd9Sstevel@tonic-gate 1857c478bd9Sstevel@tonic-gate #if defined(__sparc) 1867c478bd9Sstevel@tonic-gate void 1877c478bd9Sstevel@tonic-gate rwindow_32_to_n(const struct rwindow32 *src, struct rwindow *dst) 1887c478bd9Sstevel@tonic-gate { 1897c478bd9Sstevel@tonic-gate int i; 1907c478bd9Sstevel@tonic-gate 1917c478bd9Sstevel@tonic-gate for (i = 0; i < 8; i++) { 1927c478bd9Sstevel@tonic-gate dst->rw_local[i] = (uint64_t)(uint32_t)src->rw_local[i]; 1937c478bd9Sstevel@tonic-gate dst->rw_in[i] = (uint64_t)(uint32_t)src->rw_in[i]; 1947c478bd9Sstevel@tonic-gate } 1957c478bd9Sstevel@tonic-gate } 1967c478bd9Sstevel@tonic-gate 1977c478bd9Sstevel@tonic-gate void 1987c478bd9Sstevel@tonic-gate gwindows_32_to_n(const gwindows32_t *src, gwindows_t *dst) 1997c478bd9Sstevel@tonic-gate { 2007c478bd9Sstevel@tonic-gate int i; 2017c478bd9Sstevel@tonic-gate 2027c478bd9Sstevel@tonic-gate (void) memset(dst, 0, sizeof (gwindows_t)); 2037c478bd9Sstevel@tonic-gate dst->wbcnt = src->wbcnt; 2047c478bd9Sstevel@tonic-gate 2057c478bd9Sstevel@tonic-gate for (i = 0; i < src->wbcnt; i++) { 2067c478bd9Sstevel@tonic-gate if (src->spbuf[i] != 0) { 2077c478bd9Sstevel@tonic-gate rwindow_32_to_n(&src->wbuf[i], &dst->wbuf[i]); 20875521904Sraf dst->spbuf[i] = (greg_t *)(uintptr_t)src->spbuf[i]; 2097c478bd9Sstevel@tonic-gate } 2107c478bd9Sstevel@tonic-gate } 2117c478bd9Sstevel@tonic-gate } 2127c478bd9Sstevel@tonic-gate #endif /* __sparc */ 2137c478bd9Sstevel@tonic-gate 2147c478bd9Sstevel@tonic-gate void 2157c478bd9Sstevel@tonic-gate prgregset_32_to_n(const prgreg32_t *src, prgreg_t *dst) 2167c478bd9Sstevel@tonic-gate { 2177c478bd9Sstevel@tonic-gate #ifdef __amd64 2187c478bd9Sstevel@tonic-gate (void) memset(dst, 0, NPRGREG * sizeof (prgreg_t)); 2197c478bd9Sstevel@tonic-gate dst[REG_GS] = (uint32_t)src[GS]; 2207c478bd9Sstevel@tonic-gate dst[REG_FS] = (uint32_t)src[FS]; 2217c478bd9Sstevel@tonic-gate dst[REG_DS] = (uint32_t)src[DS]; 2227c478bd9Sstevel@tonic-gate dst[REG_ES] = (uint32_t)src[ES]; 2237c478bd9Sstevel@tonic-gate dst[REG_RDI] = (uint32_t)src[EDI]; 2247c478bd9Sstevel@tonic-gate dst[REG_RSI] = (uint32_t)src[ESI]; 2257c478bd9Sstevel@tonic-gate dst[REG_RBP] = (uint32_t)src[EBP]; 2267c478bd9Sstevel@tonic-gate dst[REG_RBX] = (uint32_t)src[EBX]; 2277c478bd9Sstevel@tonic-gate dst[REG_RDX] = (uint32_t)src[EDX]; 2287c478bd9Sstevel@tonic-gate dst[REG_RCX] = (uint32_t)src[ECX]; 2297c478bd9Sstevel@tonic-gate dst[REG_RAX] = (uint32_t)src[EAX]; 2307c478bd9Sstevel@tonic-gate dst[REG_TRAPNO] = (uint32_t)src[TRAPNO]; 2317c478bd9Sstevel@tonic-gate dst[REG_ERR] = (uint32_t)src[ERR]; 2327c478bd9Sstevel@tonic-gate dst[REG_RIP] = (uint32_t)src[EIP]; 2337c478bd9Sstevel@tonic-gate dst[REG_CS] = (uint32_t)src[CS]; 2347c478bd9Sstevel@tonic-gate dst[REG_RFL] = (uint32_t)src[EFL]; 2357c478bd9Sstevel@tonic-gate dst[REG_RSP] = (uint32_t)src[UESP]; 2367c478bd9Sstevel@tonic-gate dst[REG_SS] = (uint32_t)src[SS]; 2377c478bd9Sstevel@tonic-gate #else 2387c478bd9Sstevel@tonic-gate int i; 2397c478bd9Sstevel@tonic-gate 2407c478bd9Sstevel@tonic-gate for (i = 0; i < NPRGREG; i++) 2417c478bd9Sstevel@tonic-gate dst[i] = (prgreg_t)(uint32_t)src[i]; 2427c478bd9Sstevel@tonic-gate #endif 2437c478bd9Sstevel@tonic-gate } 2447c478bd9Sstevel@tonic-gate 2457c478bd9Sstevel@tonic-gate void 2467c478bd9Sstevel@tonic-gate prfpregset_32_to_n(const prfpregset32_t *src, prfpregset_t *dst) 2477c478bd9Sstevel@tonic-gate { 2487c478bd9Sstevel@tonic-gate #if defined(__sparc) 2497c478bd9Sstevel@tonic-gate int i; 2507c478bd9Sstevel@tonic-gate 2517c478bd9Sstevel@tonic-gate (void) memset(dst, 0, sizeof (prfpregset_t)); 2527c478bd9Sstevel@tonic-gate 2537c478bd9Sstevel@tonic-gate for (i = 0; i < 32; i++) 2547c478bd9Sstevel@tonic-gate dst->pr_fr.pr_regs[i] = src->pr_fr.pr_regs[i]; 2557c478bd9Sstevel@tonic-gate 2567c478bd9Sstevel@tonic-gate /* 2577c478bd9Sstevel@tonic-gate * We deliberately do not convert pr_qcnt or pr_q because it is a long- 2587c478bd9Sstevel@tonic-gate * standing /proc bug that this information is not exported, and another 2597c478bd9Sstevel@tonic-gate * bug further caused these values to be returned as uninitialized data 2607c478bd9Sstevel@tonic-gate * when the 64-bit kernel exported them for a 32-bit process with en=0. 2617c478bd9Sstevel@tonic-gate */ 2627c478bd9Sstevel@tonic-gate dst->pr_filler = src->pr_filler; 2637c478bd9Sstevel@tonic-gate dst->pr_fsr = src->pr_fsr; 2647c478bd9Sstevel@tonic-gate dst->pr_q_entrysize = src->pr_q_entrysize; 2657c478bd9Sstevel@tonic-gate dst->pr_en = src->pr_en; 2667c478bd9Sstevel@tonic-gate 2677c478bd9Sstevel@tonic-gate #elif defined(__amd64) 2687c478bd9Sstevel@tonic-gate 2697c478bd9Sstevel@tonic-gate struct _fpstate32 *src32 = (struct _fpstate32 *)src; 2707c478bd9Sstevel@tonic-gate struct fpchip_state *dst64 = (struct fpchip_state *)dst; 2717c478bd9Sstevel@tonic-gate int i; 2727c478bd9Sstevel@tonic-gate 2737c478bd9Sstevel@tonic-gate (void) memcpy(dst64->st, src32->_st, sizeof (src32->_st)); 2747c478bd9Sstevel@tonic-gate (void) memcpy(dst64->xmm, src32->xmm, sizeof (src32->xmm)); 2757c478bd9Sstevel@tonic-gate (void) memset((caddr_t)dst64->xmm + sizeof (src32->xmm), 0, 2767c478bd9Sstevel@tonic-gate sizeof (dst64->xmm) - sizeof (src32->xmm)); 2777c478bd9Sstevel@tonic-gate dst64->cw = (uint16_t)src32->cw; 2787c478bd9Sstevel@tonic-gate dst64->sw = (uint16_t)src32->sw; 2797c478bd9Sstevel@tonic-gate dst64->fop = 0; 2807c478bd9Sstevel@tonic-gate dst64->rip = src32->ipoff; 2817c478bd9Sstevel@tonic-gate dst64->rdp = src32->dataoff; 2827c478bd9Sstevel@tonic-gate dst64->mxcsr = src32->mxcsr; 2837c478bd9Sstevel@tonic-gate dst64->mxcsr_mask = 0; 2847c478bd9Sstevel@tonic-gate dst64->status = src32->status; 2857c478bd9Sstevel@tonic-gate dst64->xstatus = src32->xstatus; 2867c478bd9Sstevel@tonic-gate 2877c478bd9Sstevel@tonic-gate /* 2887c478bd9Sstevel@tonic-gate * Converting from the tag field to the compressed fctw is easy. 2897c478bd9Sstevel@tonic-gate * If the two tag bits are 3, then the register is empty and we 2907c478bd9Sstevel@tonic-gate * clear the bit in fctw. Otherwise we set the bit. 2917c478bd9Sstevel@tonic-gate */ 2927c478bd9Sstevel@tonic-gate 2937c478bd9Sstevel@tonic-gate dst64->fctw = 0; 2947c478bd9Sstevel@tonic-gate for (i = 0; i < 8; i++) 2957c478bd9Sstevel@tonic-gate if (((src32->tag >> (i * 2)) & 3) != 3) 2967c478bd9Sstevel@tonic-gate dst64->fctw |= 1 << i; 2977c478bd9Sstevel@tonic-gate #else 2987c478bd9Sstevel@tonic-gate #error "unrecognized ISA" 2997c478bd9Sstevel@tonic-gate #endif 3007c478bd9Sstevel@tonic-gate } 3017c478bd9Sstevel@tonic-gate 3027c478bd9Sstevel@tonic-gate void 3037c478bd9Sstevel@tonic-gate lwpstatus_32_to_n(const lwpstatus32_t *src, lwpstatus_t *dst) 3047c478bd9Sstevel@tonic-gate { 3057c478bd9Sstevel@tonic-gate int i; 3067c478bd9Sstevel@tonic-gate 3077c478bd9Sstevel@tonic-gate dst->pr_flags = src->pr_flags; 3087c478bd9Sstevel@tonic-gate dst->pr_lwpid = src->pr_lwpid; 3097c478bd9Sstevel@tonic-gate dst->pr_why = src->pr_why; 3107c478bd9Sstevel@tonic-gate dst->pr_what = src->pr_what; 3117c478bd9Sstevel@tonic-gate dst->pr_cursig = src->pr_cursig; 3127c478bd9Sstevel@tonic-gate 3137c478bd9Sstevel@tonic-gate siginfo_32_to_n(&src->pr_info, &dst->pr_info); 3147c478bd9Sstevel@tonic-gate 3157c478bd9Sstevel@tonic-gate dst->pr_lwppend = src->pr_lwppend; 3167c478bd9Sstevel@tonic-gate dst->pr_lwphold = src->pr_lwphold; 3177c478bd9Sstevel@tonic-gate 3187c478bd9Sstevel@tonic-gate sigaction_32_to_n(&src->pr_action, &dst->pr_action); 3197c478bd9Sstevel@tonic-gate stack_32_to_n(&src->pr_altstack, &dst->pr_altstack); 3207c478bd9Sstevel@tonic-gate 3217c478bd9Sstevel@tonic-gate dst->pr_oldcontext = src->pr_oldcontext; 3227c478bd9Sstevel@tonic-gate dst->pr_syscall = src->pr_syscall; 3237c478bd9Sstevel@tonic-gate dst->pr_nsysarg = src->pr_nsysarg; 3247c478bd9Sstevel@tonic-gate dst->pr_errno = src->pr_errno; 3257c478bd9Sstevel@tonic-gate 3267c478bd9Sstevel@tonic-gate for (i = 0; i < PRSYSARGS; i++) 3277c478bd9Sstevel@tonic-gate dst->pr_sysarg[i] = (long)(uint32_t)src->pr_sysarg[i]; 3287c478bd9Sstevel@tonic-gate 3297c478bd9Sstevel@tonic-gate dst->pr_rval1 = (long)(uint32_t)src->pr_rval1; 3307c478bd9Sstevel@tonic-gate dst->pr_rval2 = (long)(uint32_t)src->pr_rval2; 3317c478bd9Sstevel@tonic-gate 3327c478bd9Sstevel@tonic-gate (void) memcpy(&dst->pr_clname[0], &src->pr_clname[0], PRCLSZ); 3337c478bd9Sstevel@tonic-gate timestruc_32_to_n(&src->pr_tstamp, &dst->pr_tstamp); 3347c478bd9Sstevel@tonic-gate 3357c478bd9Sstevel@tonic-gate dst->pr_ustack = src->pr_ustack; 3367c478bd9Sstevel@tonic-gate dst->pr_instr = src->pr_instr; 3377c478bd9Sstevel@tonic-gate 3387c478bd9Sstevel@tonic-gate prgregset_32_to_n(src->pr_reg, dst->pr_reg); 3397c478bd9Sstevel@tonic-gate prfpregset_32_to_n(&src->pr_fpreg, &dst->pr_fpreg); 3407c478bd9Sstevel@tonic-gate } 3417c478bd9Sstevel@tonic-gate 3427c478bd9Sstevel@tonic-gate void 3437c478bd9Sstevel@tonic-gate pstatus_32_to_n(const pstatus32_t *src, pstatus_t *dst) 3447c478bd9Sstevel@tonic-gate { 3457c478bd9Sstevel@tonic-gate dst->pr_flags = src->pr_flags; 3467c478bd9Sstevel@tonic-gate dst->pr_nlwp = src->pr_nlwp; 3477c478bd9Sstevel@tonic-gate dst->pr_nzomb = src->pr_nzomb; 3487c478bd9Sstevel@tonic-gate dst->pr_pid = src->pr_pid; 3497c478bd9Sstevel@tonic-gate dst->pr_ppid = src->pr_ppid; 3507c478bd9Sstevel@tonic-gate dst->pr_pgid = src->pr_pgid; 3517c478bd9Sstevel@tonic-gate dst->pr_sid = src->pr_sid; 3527c478bd9Sstevel@tonic-gate dst->pr_taskid = src->pr_taskid; 3537c478bd9Sstevel@tonic-gate dst->pr_projid = src->pr_projid; 3547c478bd9Sstevel@tonic-gate dst->pr_zoneid = src->pr_zoneid; 3557c478bd9Sstevel@tonic-gate dst->pr_aslwpid = src->pr_aslwpid; 3567c478bd9Sstevel@tonic-gate dst->pr_agentid = src->pr_agentid; 3577c478bd9Sstevel@tonic-gate dst->pr_sigpend = src->pr_sigpend; 3587c478bd9Sstevel@tonic-gate dst->pr_brkbase = src->pr_brkbase; 3597c478bd9Sstevel@tonic-gate dst->pr_brksize = src->pr_brksize; 3607c478bd9Sstevel@tonic-gate dst->pr_stkbase = src->pr_stkbase; 3617c478bd9Sstevel@tonic-gate dst->pr_stksize = src->pr_stksize; 3627c478bd9Sstevel@tonic-gate 3637c478bd9Sstevel@tonic-gate timestruc_32_to_n(&src->pr_utime, &dst->pr_utime); 3647c478bd9Sstevel@tonic-gate timestruc_32_to_n(&src->pr_stime, &dst->pr_stime); 3657c478bd9Sstevel@tonic-gate timestruc_32_to_n(&src->pr_cutime, &dst->pr_cutime); 3667c478bd9Sstevel@tonic-gate timestruc_32_to_n(&src->pr_cstime, &dst->pr_cstime); 3677c478bd9Sstevel@tonic-gate 3687c478bd9Sstevel@tonic-gate dst->pr_sigtrace = src->pr_sigtrace; 3697c478bd9Sstevel@tonic-gate dst->pr_flttrace = src->pr_flttrace; 3707c478bd9Sstevel@tonic-gate dst->pr_sysentry = src->pr_sysentry; 3717c478bd9Sstevel@tonic-gate dst->pr_sysexit = src->pr_sysexit; 3727c478bd9Sstevel@tonic-gate dst->pr_dmodel = src->pr_dmodel; 3737c478bd9Sstevel@tonic-gate 3747c478bd9Sstevel@tonic-gate lwpstatus_32_to_n(&src->pr_lwp, &dst->pr_lwp); 3757c478bd9Sstevel@tonic-gate } 3767c478bd9Sstevel@tonic-gate 3777c478bd9Sstevel@tonic-gate void 3787c478bd9Sstevel@tonic-gate lwpsinfo_32_to_n(const lwpsinfo32_t *src, lwpsinfo_t *dst) 3797c478bd9Sstevel@tonic-gate { 3807c478bd9Sstevel@tonic-gate dst->pr_flag = src->pr_flag; 3817c478bd9Sstevel@tonic-gate dst->pr_lwpid = src->pr_lwpid; 3827c478bd9Sstevel@tonic-gate dst->pr_addr = src->pr_addr; 3837c478bd9Sstevel@tonic-gate dst->pr_wchan = src->pr_wchan; 3847c478bd9Sstevel@tonic-gate dst->pr_stype = src->pr_stype; 3857c478bd9Sstevel@tonic-gate dst->pr_state = src->pr_state; 3867c478bd9Sstevel@tonic-gate dst->pr_sname = src->pr_sname; 3877c478bd9Sstevel@tonic-gate dst->pr_nice = src->pr_nice; 3887c478bd9Sstevel@tonic-gate dst->pr_syscall = src->pr_syscall; 3897c478bd9Sstevel@tonic-gate dst->pr_oldpri = src->pr_oldpri; 3907c478bd9Sstevel@tonic-gate dst->pr_cpu = src->pr_cpu; 3917c478bd9Sstevel@tonic-gate dst->pr_pri = src->pr_pri; 3927c478bd9Sstevel@tonic-gate dst->pr_pctcpu = src->pr_pctcpu; 3937c478bd9Sstevel@tonic-gate 3947c478bd9Sstevel@tonic-gate timestruc_32_to_n(&src->pr_start, &dst->pr_start); 3957c478bd9Sstevel@tonic-gate timestruc_32_to_n(&src->pr_time, &dst->pr_time); 3967c478bd9Sstevel@tonic-gate 3977c478bd9Sstevel@tonic-gate (void) memcpy(&dst->pr_clname[0], &src->pr_clname[0], PRCLSZ); 3987c478bd9Sstevel@tonic-gate (void) memcpy(&dst->pr_name[0], &src->pr_name[0], PRFNSZ); 3997c478bd9Sstevel@tonic-gate 4007c478bd9Sstevel@tonic-gate dst->pr_onpro = src->pr_onpro; 4017c478bd9Sstevel@tonic-gate dst->pr_bindpro = src->pr_bindpro; 4027c478bd9Sstevel@tonic-gate dst->pr_bindpset = src->pr_bindpset; 403*c6402783Sakolb dst->pr_lgrp = src->pr_lgrp; 4047c478bd9Sstevel@tonic-gate } 4057c478bd9Sstevel@tonic-gate 4067c478bd9Sstevel@tonic-gate void 4077c478bd9Sstevel@tonic-gate psinfo_32_to_n(const psinfo32_t *src, psinfo_t *dst) 4087c478bd9Sstevel@tonic-gate { 4097c478bd9Sstevel@tonic-gate dst->pr_flag = src->pr_flag; 4107c478bd9Sstevel@tonic-gate dst->pr_nlwp = src->pr_nlwp; 4117c478bd9Sstevel@tonic-gate dst->pr_nzomb = src->pr_nzomb; 4127c478bd9Sstevel@tonic-gate dst->pr_pid = src->pr_pid; 4137c478bd9Sstevel@tonic-gate dst->pr_pgid = src->pr_pgid; 4147c478bd9Sstevel@tonic-gate dst->pr_sid = src->pr_sid; 4157c478bd9Sstevel@tonic-gate dst->pr_taskid = src->pr_taskid; 4167c478bd9Sstevel@tonic-gate dst->pr_projid = src->pr_projid; 4177c478bd9Sstevel@tonic-gate dst->pr_zoneid = src->pr_zoneid; 4187c478bd9Sstevel@tonic-gate dst->pr_uid = src->pr_uid; 4197c478bd9Sstevel@tonic-gate dst->pr_euid = src->pr_euid; 4207c478bd9Sstevel@tonic-gate dst->pr_gid = src->pr_gid; 4217c478bd9Sstevel@tonic-gate dst->pr_egid = src->pr_egid; 4227c478bd9Sstevel@tonic-gate dst->pr_addr = src->pr_addr; 4237c478bd9Sstevel@tonic-gate dst->pr_size = src->pr_size; 4247c478bd9Sstevel@tonic-gate dst->pr_rssize = src->pr_rssize; 4257c478bd9Sstevel@tonic-gate 4267c478bd9Sstevel@tonic-gate dst->pr_ttydev = prexpldev(src->pr_ttydev); 4277c478bd9Sstevel@tonic-gate 4287c478bd9Sstevel@tonic-gate dst->pr_pctcpu = src->pr_pctcpu; 4297c478bd9Sstevel@tonic-gate dst->pr_pctmem = src->pr_pctmem; 4307c478bd9Sstevel@tonic-gate 4317c478bd9Sstevel@tonic-gate timestruc_32_to_n(&src->pr_start, &dst->pr_start); 4327c478bd9Sstevel@tonic-gate timestruc_32_to_n(&src->pr_time, &dst->pr_time); 4337c478bd9Sstevel@tonic-gate timestruc_32_to_n(&src->pr_ctime, &dst->pr_ctime); 4347c478bd9Sstevel@tonic-gate 4357c478bd9Sstevel@tonic-gate (void) memcpy(&dst->pr_fname[0], &src->pr_fname[0], PRFNSZ); 4367c478bd9Sstevel@tonic-gate (void) memcpy(&dst->pr_psargs[0], &src->pr_psargs[0], PRARGSZ); 4377c478bd9Sstevel@tonic-gate 4387c478bd9Sstevel@tonic-gate dst->pr_wstat = src->pr_wstat; 4397c478bd9Sstevel@tonic-gate dst->pr_argc = src->pr_argc; 4407c478bd9Sstevel@tonic-gate dst->pr_argv = src->pr_argv; 4417c478bd9Sstevel@tonic-gate dst->pr_envp = src->pr_envp; 4427c478bd9Sstevel@tonic-gate dst->pr_dmodel = src->pr_dmodel; 4437c478bd9Sstevel@tonic-gate 4447c478bd9Sstevel@tonic-gate lwpsinfo_32_to_n(&src->pr_lwp, &dst->pr_lwp); 4457c478bd9Sstevel@tonic-gate } 4467c478bd9Sstevel@tonic-gate 4477c478bd9Sstevel@tonic-gate void 4487c478bd9Sstevel@tonic-gate timestruc_n_to_32(const timestruc_t *src, timestruc32_t *dst) 4497c478bd9Sstevel@tonic-gate { 4507c478bd9Sstevel@tonic-gate dst->tv_sec = (time32_t)src->tv_sec; 4517c478bd9Sstevel@tonic-gate dst->tv_nsec = (int32_t)src->tv_nsec; 4527c478bd9Sstevel@tonic-gate } 4537c478bd9Sstevel@tonic-gate 4547c478bd9Sstevel@tonic-gate void 4557c478bd9Sstevel@tonic-gate stack_n_to_32(const stack_t *src, stack32_t *dst) 4567c478bd9Sstevel@tonic-gate { 4577c478bd9Sstevel@tonic-gate dst->ss_sp = (caddr32_t)(uintptr_t)src->ss_sp; 4587c478bd9Sstevel@tonic-gate dst->ss_size = src->ss_size; 4597c478bd9Sstevel@tonic-gate dst->ss_flags = src->ss_flags; 4607c478bd9Sstevel@tonic-gate } 4617c478bd9Sstevel@tonic-gate 4627c478bd9Sstevel@tonic-gate void 4637c478bd9Sstevel@tonic-gate sigaction_n_to_32(const struct sigaction *src, struct sigaction32 *dst) 4647c478bd9Sstevel@tonic-gate { 4657c478bd9Sstevel@tonic-gate (void) memset(dst, 0, sizeof (struct sigaction32)); 4667c478bd9Sstevel@tonic-gate dst->sa_flags = src->sa_flags; 4677c478bd9Sstevel@tonic-gate dst->sa_handler = (caddr32_t)(uintptr_t)src->sa_handler; 4687c478bd9Sstevel@tonic-gate (void) memcpy(&dst->sa_mask, &src->sa_mask, sizeof (dst->sa_mask)); 4697c478bd9Sstevel@tonic-gate } 4707c478bd9Sstevel@tonic-gate 4717c478bd9Sstevel@tonic-gate void 4727c478bd9Sstevel@tonic-gate siginfo_n_to_32(const siginfo_t *src, siginfo32_t *dst) 4737c478bd9Sstevel@tonic-gate { 4747c478bd9Sstevel@tonic-gate (void) memset(dst, 0, sizeof (siginfo32_t)); 4757c478bd9Sstevel@tonic-gate 4767c478bd9Sstevel@tonic-gate /* 4777c478bd9Sstevel@tonic-gate * The absolute minimum content is si_signo and si_code. 4787c478bd9Sstevel@tonic-gate */ 4797c478bd9Sstevel@tonic-gate dst->si_signo = src->si_signo; 4807c478bd9Sstevel@tonic-gate if ((dst->si_code = src->si_code) == SI_NOINFO) 4817c478bd9Sstevel@tonic-gate return; 4827c478bd9Sstevel@tonic-gate 4837c478bd9Sstevel@tonic-gate /* 4847c478bd9Sstevel@tonic-gate * A siginfo generated by user level is structured 4857c478bd9Sstevel@tonic-gate * differently from one generated by the kernel. 4867c478bd9Sstevel@tonic-gate */ 4877c478bd9Sstevel@tonic-gate if (SI_FROMUSER(src)) { 4887c478bd9Sstevel@tonic-gate dst->si_pid = src->si_pid; 4897c478bd9Sstevel@tonic-gate dst->si_ctid = src->si_ctid; 4907c478bd9Sstevel@tonic-gate dst->si_zoneid = src->si_zoneid; 4917c478bd9Sstevel@tonic-gate dst->si_uid = src->si_uid; 4927c478bd9Sstevel@tonic-gate if (SI_CANQUEUE(src->si_code)) { 4937c478bd9Sstevel@tonic-gate dst->si_value.sival_int = 4947c478bd9Sstevel@tonic-gate (int32_t)src->si_value.sival_int; 4957c478bd9Sstevel@tonic-gate } 4967c478bd9Sstevel@tonic-gate return; 4977c478bd9Sstevel@tonic-gate } 4987c478bd9Sstevel@tonic-gate 4997c478bd9Sstevel@tonic-gate dst->si_errno = src->si_errno; 5007c478bd9Sstevel@tonic-gate 5017c478bd9Sstevel@tonic-gate switch (src->si_signo) { 5027c478bd9Sstevel@tonic-gate default: 5037c478bd9Sstevel@tonic-gate dst->si_pid = src->si_pid; 5047c478bd9Sstevel@tonic-gate dst->si_ctid = src->si_ctid; 5057c478bd9Sstevel@tonic-gate dst->si_zoneid = src->si_zoneid; 5067c478bd9Sstevel@tonic-gate dst->si_uid = src->si_uid; 5077c478bd9Sstevel@tonic-gate dst->si_value.sival_int = 5087c478bd9Sstevel@tonic-gate (int32_t)src->si_value.sival_int; 5097c478bd9Sstevel@tonic-gate break; 5107c478bd9Sstevel@tonic-gate case SIGCLD: 5117c478bd9Sstevel@tonic-gate dst->si_pid = src->si_pid; 5127c478bd9Sstevel@tonic-gate dst->si_ctid = src->si_ctid; 5137c478bd9Sstevel@tonic-gate dst->si_zoneid = src->si_zoneid; 5147c478bd9Sstevel@tonic-gate dst->si_status = src->si_status; 5157c478bd9Sstevel@tonic-gate dst->si_stime = src->si_stime; 5167c478bd9Sstevel@tonic-gate dst->si_utime = src->si_utime; 5177c478bd9Sstevel@tonic-gate break; 5187c478bd9Sstevel@tonic-gate case SIGSEGV: 5197c478bd9Sstevel@tonic-gate case SIGBUS: 5207c478bd9Sstevel@tonic-gate case SIGILL: 5217c478bd9Sstevel@tonic-gate case SIGTRAP: 5227c478bd9Sstevel@tonic-gate case SIGFPE: 5237c478bd9Sstevel@tonic-gate case SIGEMT: 5247c478bd9Sstevel@tonic-gate dst->si_addr = (caddr32_t)(uintptr_t)src->si_addr; 5257c478bd9Sstevel@tonic-gate dst->si_trapno = src->si_trapno; 5267c478bd9Sstevel@tonic-gate dst->si_pc = (caddr32_t)(uintptr_t)src->si_pc; 5277c478bd9Sstevel@tonic-gate break; 5287c478bd9Sstevel@tonic-gate case SIGPOLL: 5297c478bd9Sstevel@tonic-gate case SIGXFSZ: 5307c478bd9Sstevel@tonic-gate dst->si_fd = src->si_fd; 5317c478bd9Sstevel@tonic-gate dst->si_band = src->si_band; 5327c478bd9Sstevel@tonic-gate break; 5337c478bd9Sstevel@tonic-gate case SIGPROF: 5347c478bd9Sstevel@tonic-gate dst->si_faddr = (caddr32_t)(uintptr_t)src->si_faddr; 5357c478bd9Sstevel@tonic-gate dst->si_tstamp.tv_sec = src->si_tstamp.tv_sec; 5367c478bd9Sstevel@tonic-gate dst->si_tstamp.tv_nsec = src->si_tstamp.tv_nsec; 5377c478bd9Sstevel@tonic-gate dst->si_syscall = src->si_syscall; 5387c478bd9Sstevel@tonic-gate dst->si_nsysarg = src->si_nsysarg; 5397c478bd9Sstevel@tonic-gate dst->si_fault = src->si_fault; 5407c478bd9Sstevel@tonic-gate break; 5417c478bd9Sstevel@tonic-gate } 5427c478bd9Sstevel@tonic-gate } 5437c478bd9Sstevel@tonic-gate 5447c478bd9Sstevel@tonic-gate void 5457c478bd9Sstevel@tonic-gate auxv_n_to_32(const auxv_t *src, auxv32_t *dst) 5467c478bd9Sstevel@tonic-gate { 5477c478bd9Sstevel@tonic-gate dst->a_type = src->a_type; 5487c478bd9Sstevel@tonic-gate dst->a_un.a_ptr = (caddr32_t)(uintptr_t)src->a_un.a_ptr; 5497c478bd9Sstevel@tonic-gate } 5507c478bd9Sstevel@tonic-gate 5517c478bd9Sstevel@tonic-gate void 5527c478bd9Sstevel@tonic-gate prgregset_n_to_32(const prgreg_t *src, prgreg32_t *dst) 5537c478bd9Sstevel@tonic-gate { 5547c478bd9Sstevel@tonic-gate #ifdef __amd64 5557c478bd9Sstevel@tonic-gate (void) memset(dst, 0, NPRGREG32 * sizeof (prgreg32_t)); 5567c478bd9Sstevel@tonic-gate dst[GS] = src[REG_GS]; 5577c478bd9Sstevel@tonic-gate dst[FS] = src[REG_FS]; 5587c478bd9Sstevel@tonic-gate dst[DS] = src[REG_DS]; 5597c478bd9Sstevel@tonic-gate dst[ES] = src[REG_ES]; 5607c478bd9Sstevel@tonic-gate dst[EDI] = src[REG_RDI]; 5617c478bd9Sstevel@tonic-gate dst[ESI] = src[REG_RSI]; 5627c478bd9Sstevel@tonic-gate dst[EBP] = src[REG_RBP]; 5637c478bd9Sstevel@tonic-gate dst[EBX] = src[REG_RBX]; 5647c478bd9Sstevel@tonic-gate dst[EDX] = src[REG_RDX]; 5657c478bd9Sstevel@tonic-gate dst[ECX] = src[REG_RCX]; 5667c478bd9Sstevel@tonic-gate dst[EAX] = src[REG_RAX]; 5677c478bd9Sstevel@tonic-gate dst[TRAPNO] = src[REG_TRAPNO]; 5687c478bd9Sstevel@tonic-gate dst[ERR] = src[REG_ERR]; 5697c478bd9Sstevel@tonic-gate dst[EIP] = src[REG_RIP]; 5707c478bd9Sstevel@tonic-gate dst[CS] = src[REG_CS]; 5717c478bd9Sstevel@tonic-gate dst[EFL] = src[REG_RFL]; 5727c478bd9Sstevel@tonic-gate dst[UESP] = src[REG_RSP]; 5737c478bd9Sstevel@tonic-gate dst[SS] = src[REG_SS]; 5747c478bd9Sstevel@tonic-gate #else 5757c478bd9Sstevel@tonic-gate int i; 5767c478bd9Sstevel@tonic-gate 5777c478bd9Sstevel@tonic-gate for (i = 0; i < NPRGREG; i++) 5787c478bd9Sstevel@tonic-gate dst[i] = (prgreg32_t)src[i]; 5797c478bd9Sstevel@tonic-gate #endif 5807c478bd9Sstevel@tonic-gate } 5817c478bd9Sstevel@tonic-gate 5827c478bd9Sstevel@tonic-gate void 5837c478bd9Sstevel@tonic-gate prfpregset_n_to_32(const prfpregset_t *src, prfpregset32_t *dst) 5847c478bd9Sstevel@tonic-gate { 5857c478bd9Sstevel@tonic-gate #if defined(__sparc) 5867c478bd9Sstevel@tonic-gate int i; 5877c478bd9Sstevel@tonic-gate 5887c478bd9Sstevel@tonic-gate (void) memset(dst, 0, sizeof (prfpregset32_t)); 5897c478bd9Sstevel@tonic-gate 5907c478bd9Sstevel@tonic-gate for (i = 0; i < 32; i++) 5917c478bd9Sstevel@tonic-gate dst->pr_fr.pr_regs[i] = src->pr_fr.pr_regs[i]; 5927c478bd9Sstevel@tonic-gate 5937c478bd9Sstevel@tonic-gate dst->pr_filler = src->pr_filler; 5947c478bd9Sstevel@tonic-gate dst->pr_fsr = src->pr_fsr; 5957c478bd9Sstevel@tonic-gate dst->pr_q_entrysize = src->pr_q_entrysize; 5967c478bd9Sstevel@tonic-gate dst->pr_en = src->pr_en; 5977c478bd9Sstevel@tonic-gate 5987c478bd9Sstevel@tonic-gate #elif defined(__amd64) 5997c478bd9Sstevel@tonic-gate 6007c478bd9Sstevel@tonic-gate struct _fpstate32 *dst32 = (struct _fpstate32 *)dst; 6017c478bd9Sstevel@tonic-gate struct fpchip_state *src64 = (struct fpchip_state *)src; 6027c478bd9Sstevel@tonic-gate uint32_t top; 6037c478bd9Sstevel@tonic-gate int i; 6047c478bd9Sstevel@tonic-gate 6057c478bd9Sstevel@tonic-gate (void) memcpy(dst32->_st, src64->st, sizeof (dst32->_st)); 6067c478bd9Sstevel@tonic-gate (void) memcpy(dst32->xmm, src64->xmm, sizeof (dst32->xmm)); 6077c478bd9Sstevel@tonic-gate dst32->cw = src64->cw; 6087c478bd9Sstevel@tonic-gate dst32->sw = src64->sw; 6097c478bd9Sstevel@tonic-gate dst32->ipoff = (unsigned int)src64->rip; 6107c478bd9Sstevel@tonic-gate dst32->cssel = 0; 6117c478bd9Sstevel@tonic-gate dst32->dataoff = (unsigned int)src64->rdp; 6127c478bd9Sstevel@tonic-gate dst32->datasel = 0; 6137c478bd9Sstevel@tonic-gate dst32->status = src64->status; 6147c478bd9Sstevel@tonic-gate dst32->mxcsr = src64->mxcsr; 6157c478bd9Sstevel@tonic-gate dst32->xstatus = src64->xstatus; 6167c478bd9Sstevel@tonic-gate 6177c478bd9Sstevel@tonic-gate /* 6187c478bd9Sstevel@tonic-gate * AMD64 stores the tag in a compressed form. It is 6197c478bd9Sstevel@tonic-gate * necessary to extract the original 2-bit tag value. 6207c478bd9Sstevel@tonic-gate * See AMD64 Architecture Programmer's Manual Volume 2: 6217c478bd9Sstevel@tonic-gate * System Programming, Chapter 11. 6227c478bd9Sstevel@tonic-gate */ 6237c478bd9Sstevel@tonic-gate 6247c478bd9Sstevel@tonic-gate top = (src64->sw & FPS_TOP) >> 11; 6257c478bd9Sstevel@tonic-gate dst32->tag = 0; 6267c478bd9Sstevel@tonic-gate for (i = 0; i < 8; i++) { 6277c478bd9Sstevel@tonic-gate /* 6287c478bd9Sstevel@tonic-gate * Recall that we need to use the current TOP-of-stack value to 6297c478bd9Sstevel@tonic-gate * associate the _st[] index back to a physical register number, 6307c478bd9Sstevel@tonic-gate * since tag word indices are physical register numbers. Then 6317c478bd9Sstevel@tonic-gate * to get the tag value, we shift over two bits for each tag 6327c478bd9Sstevel@tonic-gate * index, and then grab the bottom two bits. 6337c478bd9Sstevel@tonic-gate */ 6347c478bd9Sstevel@tonic-gate uint_t tag_index = (i + top) & 7; 6357c478bd9Sstevel@tonic-gate uint_t tag_fctw = (src64->fctw >> tag_index) & 1; 6367c478bd9Sstevel@tonic-gate uint_t tag_value; 6377c478bd9Sstevel@tonic-gate uint_t exp; 6387c478bd9Sstevel@tonic-gate 6397c478bd9Sstevel@tonic-gate /* 6407c478bd9Sstevel@tonic-gate * Union for overlaying _fpreg structure on to quad-precision 6417c478bd9Sstevel@tonic-gate * floating-point value (long double). 6427c478bd9Sstevel@tonic-gate */ 6437c478bd9Sstevel@tonic-gate union { 6447c478bd9Sstevel@tonic-gate struct _fpreg reg; 6457c478bd9Sstevel@tonic-gate long double ld; 6467c478bd9Sstevel@tonic-gate } fpru; 6477c478bd9Sstevel@tonic-gate 6487c478bd9Sstevel@tonic-gate fpru.ld = src64->st[i].__fpr_pad._q; 6497c478bd9Sstevel@tonic-gate exp = fpru.reg.exponent & 0x7fff; 6507c478bd9Sstevel@tonic-gate 6517c478bd9Sstevel@tonic-gate if (tag_fctw == 0) { 6527c478bd9Sstevel@tonic-gate tag_value = 3; /* empty */ 6537c478bd9Sstevel@tonic-gate } else if (exp == 0) { 6547c478bd9Sstevel@tonic-gate if (fpru.reg.significand[0] == 0 && 6557c478bd9Sstevel@tonic-gate fpru.reg.significand[1] == 0 && 6567c478bd9Sstevel@tonic-gate fpru.reg.significand[2] == 0 && 6577c478bd9Sstevel@tonic-gate fpru.reg.significand[3] == 0) 6587c478bd9Sstevel@tonic-gate tag_value = 1; /* zero */ 6597c478bd9Sstevel@tonic-gate else 6607c478bd9Sstevel@tonic-gate tag_value = 2; /* special: denormal */ 6617c478bd9Sstevel@tonic-gate } else if (exp == 0x7fff) { 6627c478bd9Sstevel@tonic-gate tag_value = 2; /* special: infinity or NaN */ 6637c478bd9Sstevel@tonic-gate } else if (fpru.reg.significand[3] & 0x8000) { 6647c478bd9Sstevel@tonic-gate tag_value = 0; /* valid */ 6657c478bd9Sstevel@tonic-gate } else { 6667c478bd9Sstevel@tonic-gate tag_value = 2; /* special: unnormal */ 6677c478bd9Sstevel@tonic-gate } 6687c478bd9Sstevel@tonic-gate dst32->tag |= tag_value << (tag_index * 2); 6697c478bd9Sstevel@tonic-gate } 6707c478bd9Sstevel@tonic-gate #else 6717c478bd9Sstevel@tonic-gate #error "unrecognized ISA" 6727c478bd9Sstevel@tonic-gate #endif 6737c478bd9Sstevel@tonic-gate } 6747c478bd9Sstevel@tonic-gate 6757c478bd9Sstevel@tonic-gate void 6767c478bd9Sstevel@tonic-gate lwpstatus_n_to_32(const lwpstatus_t *src, lwpstatus32_t *dst) 6777c478bd9Sstevel@tonic-gate { 6787c478bd9Sstevel@tonic-gate int i; 6797c478bd9Sstevel@tonic-gate 6807c478bd9Sstevel@tonic-gate dst->pr_flags = src->pr_flags; 6817c478bd9Sstevel@tonic-gate dst->pr_lwpid = src->pr_lwpid; 6827c478bd9Sstevel@tonic-gate dst->pr_why = src->pr_why; 6837c478bd9Sstevel@tonic-gate dst->pr_what = src->pr_what; 6847c478bd9Sstevel@tonic-gate dst->pr_cursig = src->pr_cursig; 6857c478bd9Sstevel@tonic-gate 6867c478bd9Sstevel@tonic-gate siginfo_n_to_32(&src->pr_info, &dst->pr_info); 6877c478bd9Sstevel@tonic-gate 6887c478bd9Sstevel@tonic-gate dst->pr_lwppend = src->pr_lwppend; 6897c478bd9Sstevel@tonic-gate dst->pr_lwphold = src->pr_lwphold; 6907c478bd9Sstevel@tonic-gate 6917c478bd9Sstevel@tonic-gate sigaction_n_to_32(&src->pr_action, &dst->pr_action); 6927c478bd9Sstevel@tonic-gate stack_n_to_32(&src->pr_altstack, &dst->pr_altstack); 6937c478bd9Sstevel@tonic-gate 6947c478bd9Sstevel@tonic-gate dst->pr_oldcontext = (caddr32_t)src->pr_oldcontext; 6957c478bd9Sstevel@tonic-gate dst->pr_syscall = src->pr_syscall; 6967c478bd9Sstevel@tonic-gate dst->pr_nsysarg = src->pr_nsysarg; 6977c478bd9Sstevel@tonic-gate dst->pr_errno = src->pr_errno; 6987c478bd9Sstevel@tonic-gate 6997c478bd9Sstevel@tonic-gate for (i = 0; i < PRSYSARGS; i++) 7007c478bd9Sstevel@tonic-gate dst->pr_sysarg[i] = (int32_t)src->pr_sysarg[i]; 7017c478bd9Sstevel@tonic-gate 7027c478bd9Sstevel@tonic-gate dst->pr_rval1 = (int32_t)src->pr_rval1; 7037c478bd9Sstevel@tonic-gate dst->pr_rval2 = (int32_t)src->pr_rval2; 7047c478bd9Sstevel@tonic-gate 7057c478bd9Sstevel@tonic-gate (void) memcpy(&dst->pr_clname[0], &src->pr_clname[0], PRCLSZ); 7067c478bd9Sstevel@tonic-gate timestruc_n_to_32(&src->pr_tstamp, &dst->pr_tstamp); 7077c478bd9Sstevel@tonic-gate 7087c478bd9Sstevel@tonic-gate dst->pr_ustack = (caddr32_t)src->pr_ustack; 7097c478bd9Sstevel@tonic-gate dst->pr_instr = src->pr_instr; 7107c478bd9Sstevel@tonic-gate 7117c478bd9Sstevel@tonic-gate prgregset_n_to_32(src->pr_reg, dst->pr_reg); 7127c478bd9Sstevel@tonic-gate prfpregset_n_to_32(&src->pr_fpreg, &dst->pr_fpreg); 7137c478bd9Sstevel@tonic-gate } 7147c478bd9Sstevel@tonic-gate 7157c478bd9Sstevel@tonic-gate void 7167c478bd9Sstevel@tonic-gate pstatus_n_to_32(const pstatus_t *src, pstatus32_t *dst) 7177c478bd9Sstevel@tonic-gate { 7187c478bd9Sstevel@tonic-gate dst->pr_flags = src->pr_flags; 7197c478bd9Sstevel@tonic-gate dst->pr_nlwp = src->pr_nlwp; 7207c478bd9Sstevel@tonic-gate dst->pr_nzomb = src->pr_nzomb; 7217c478bd9Sstevel@tonic-gate dst->pr_pid = (pid32_t)src->pr_pid; 7227c478bd9Sstevel@tonic-gate dst->pr_ppid = (pid32_t)src->pr_ppid; 7237c478bd9Sstevel@tonic-gate dst->pr_pgid = (pid32_t)src->pr_pgid; 7247c478bd9Sstevel@tonic-gate dst->pr_sid = (pid32_t)src->pr_sid; 7257c478bd9Sstevel@tonic-gate dst->pr_taskid = (id32_t)src->pr_taskid; 7267c478bd9Sstevel@tonic-gate dst->pr_projid = (id32_t)src->pr_projid; 7277c478bd9Sstevel@tonic-gate dst->pr_zoneid = (id32_t)src->pr_zoneid; 7287c478bd9Sstevel@tonic-gate dst->pr_aslwpid = (id32_t)src->pr_aslwpid; 7297c478bd9Sstevel@tonic-gate dst->pr_agentid = (id32_t)src->pr_agentid; 7307c478bd9Sstevel@tonic-gate dst->pr_sigpend = src->pr_sigpend; 7317c478bd9Sstevel@tonic-gate dst->pr_brkbase = (caddr32_t)src->pr_brkbase; 7327c478bd9Sstevel@tonic-gate dst->pr_brksize = (size32_t)src->pr_brksize; 7337c478bd9Sstevel@tonic-gate dst->pr_stkbase = (caddr32_t)src->pr_stkbase; 7347c478bd9Sstevel@tonic-gate dst->pr_stksize = (size32_t)src->pr_stksize; 7357c478bd9Sstevel@tonic-gate 7367c478bd9Sstevel@tonic-gate timestruc_n_to_32(&src->pr_utime, &dst->pr_utime); 7377c478bd9Sstevel@tonic-gate timestruc_n_to_32(&src->pr_stime, &dst->pr_stime); 7387c478bd9Sstevel@tonic-gate timestruc_n_to_32(&src->pr_cutime, &dst->pr_cutime); 7397c478bd9Sstevel@tonic-gate timestruc_n_to_32(&src->pr_cstime, &dst->pr_cstime); 7407c478bd9Sstevel@tonic-gate 7417c478bd9Sstevel@tonic-gate dst->pr_sigtrace = src->pr_sigtrace; 7427c478bd9Sstevel@tonic-gate dst->pr_flttrace = src->pr_flttrace; 7437c478bd9Sstevel@tonic-gate dst->pr_sysentry = src->pr_sysentry; 7447c478bd9Sstevel@tonic-gate dst->pr_sysexit = src->pr_sysexit; 7457c478bd9Sstevel@tonic-gate dst->pr_dmodel = src->pr_dmodel; 7467c478bd9Sstevel@tonic-gate 7477c478bd9Sstevel@tonic-gate lwpstatus_n_to_32(&src->pr_lwp, &dst->pr_lwp); 7487c478bd9Sstevel@tonic-gate } 7497c478bd9Sstevel@tonic-gate 7507c478bd9Sstevel@tonic-gate void 7517c478bd9Sstevel@tonic-gate lwpsinfo_n_to_32(const lwpsinfo_t *src, lwpsinfo32_t *dst) 7527c478bd9Sstevel@tonic-gate { 7537c478bd9Sstevel@tonic-gate dst->pr_flag = src->pr_flag; 7547c478bd9Sstevel@tonic-gate dst->pr_lwpid = (id32_t)src->pr_lwpid; 7557c478bd9Sstevel@tonic-gate dst->pr_addr = (caddr32_t)src->pr_addr; 7567c478bd9Sstevel@tonic-gate dst->pr_wchan = (caddr32_t)src->pr_wchan; 7577c478bd9Sstevel@tonic-gate dst->pr_stype = src->pr_stype; 7587c478bd9Sstevel@tonic-gate dst->pr_state = src->pr_state; 7597c478bd9Sstevel@tonic-gate dst->pr_sname = src->pr_sname; 7607c478bd9Sstevel@tonic-gate dst->pr_nice = src->pr_nice; 7617c478bd9Sstevel@tonic-gate dst->pr_syscall = src->pr_syscall; 7627c478bd9Sstevel@tonic-gate dst->pr_oldpri = src->pr_oldpri; 7637c478bd9Sstevel@tonic-gate dst->pr_cpu = src->pr_cpu; 7647c478bd9Sstevel@tonic-gate dst->pr_pri = src->pr_pri; 7657c478bd9Sstevel@tonic-gate dst->pr_pctcpu = src->pr_pctcpu; 7667c478bd9Sstevel@tonic-gate 7677c478bd9Sstevel@tonic-gate timestruc_n_to_32(&src->pr_start, &dst->pr_start); 7687c478bd9Sstevel@tonic-gate timestruc_n_to_32(&src->pr_time, &dst->pr_time); 7697c478bd9Sstevel@tonic-gate 7707c478bd9Sstevel@tonic-gate (void) memcpy(&dst->pr_clname[0], &src->pr_clname[0], PRCLSZ); 7717c478bd9Sstevel@tonic-gate (void) memcpy(&dst->pr_name[0], &src->pr_name[0], PRFNSZ); 7727c478bd9Sstevel@tonic-gate 7737c478bd9Sstevel@tonic-gate dst->pr_onpro = src->pr_onpro; 7747c478bd9Sstevel@tonic-gate dst->pr_bindpro = src->pr_bindpro; 7757c478bd9Sstevel@tonic-gate dst->pr_bindpset = src->pr_bindpset; 776*c6402783Sakolb dst->pr_lgrp = src->pr_lgrp; 7777c478bd9Sstevel@tonic-gate } 7787c478bd9Sstevel@tonic-gate 7797c478bd9Sstevel@tonic-gate void 7807c478bd9Sstevel@tonic-gate psinfo_n_to_32(const psinfo_t *src, psinfo32_t *dst) 7817c478bd9Sstevel@tonic-gate { 7827c478bd9Sstevel@tonic-gate dst->pr_flag = src->pr_flag; 7837c478bd9Sstevel@tonic-gate dst->pr_nlwp = src->pr_nlwp; 7847c478bd9Sstevel@tonic-gate dst->pr_nzomb = src->pr_nzomb; 7857c478bd9Sstevel@tonic-gate dst->pr_pid = (pid32_t)src->pr_pid; 7867c478bd9Sstevel@tonic-gate dst->pr_pgid = (pid32_t)src->pr_pgid; 7877c478bd9Sstevel@tonic-gate dst->pr_sid = (pid32_t)src->pr_sid; 7887c478bd9Sstevel@tonic-gate dst->pr_taskid = (id32_t)src->pr_taskid; 7897c478bd9Sstevel@tonic-gate dst->pr_projid = (id32_t)src->pr_projid; 7907c478bd9Sstevel@tonic-gate dst->pr_zoneid = (id32_t)src->pr_zoneid; 7917c478bd9Sstevel@tonic-gate dst->pr_uid = (uid32_t)src->pr_uid; 7927c478bd9Sstevel@tonic-gate dst->pr_euid = (uid32_t)src->pr_euid; 7937c478bd9Sstevel@tonic-gate dst->pr_gid = (gid32_t)src->pr_gid; 7947c478bd9Sstevel@tonic-gate dst->pr_egid = (gid32_t)src->pr_egid; 7957c478bd9Sstevel@tonic-gate dst->pr_addr = (caddr32_t)src->pr_addr; 7967c478bd9Sstevel@tonic-gate dst->pr_size = (size32_t)src->pr_size; 7977c478bd9Sstevel@tonic-gate dst->pr_rssize = (size32_t)src->pr_rssize; 7987c478bd9Sstevel@tonic-gate 7997c478bd9Sstevel@tonic-gate dst->pr_ttydev = prcmpldev(src->pr_ttydev); 8007c478bd9Sstevel@tonic-gate 8017c478bd9Sstevel@tonic-gate dst->pr_pctcpu = src->pr_pctcpu; 8027c478bd9Sstevel@tonic-gate dst->pr_pctmem = src->pr_pctmem; 8037c478bd9Sstevel@tonic-gate 8047c478bd9Sstevel@tonic-gate timestruc_n_to_32(&src->pr_start, &dst->pr_start); 8057c478bd9Sstevel@tonic-gate timestruc_n_to_32(&src->pr_time, &dst->pr_time); 8067c478bd9Sstevel@tonic-gate timestruc_n_to_32(&src->pr_ctime, &dst->pr_ctime); 8077c478bd9Sstevel@tonic-gate 8087c478bd9Sstevel@tonic-gate (void) memcpy(&dst->pr_fname[0], &src->pr_fname[0], PRFNSZ); 8097c478bd9Sstevel@tonic-gate (void) memcpy(&dst->pr_psargs[0], &src->pr_psargs[0], PRARGSZ); 8107c478bd9Sstevel@tonic-gate 8117c478bd9Sstevel@tonic-gate dst->pr_wstat = src->pr_wstat; 8127c478bd9Sstevel@tonic-gate dst->pr_argc = src->pr_argc; 8137c478bd9Sstevel@tonic-gate dst->pr_argv = (caddr32_t)src->pr_argv; 8147c478bd9Sstevel@tonic-gate dst->pr_envp = (caddr32_t)src->pr_envp; 8157c478bd9Sstevel@tonic-gate dst->pr_dmodel = src->pr_dmodel; 8167c478bd9Sstevel@tonic-gate 8177c478bd9Sstevel@tonic-gate lwpsinfo_n_to_32(&src->pr_lwp, &dst->pr_lwp); 8187c478bd9Sstevel@tonic-gate } 8197c478bd9Sstevel@tonic-gate 8207c478bd9Sstevel@tonic-gate 8217c478bd9Sstevel@tonic-gate #endif /* _LP64 */ 822