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