1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 28*7c478bd9Sstevel@tonic-gate 29*7c478bd9Sstevel@tonic-gate /* 30*7c478bd9Sstevel@tonic-gate * Adr memory based translations 31*7c478bd9Sstevel@tonic-gate */ 32*7c478bd9Sstevel@tonic-gate 33*7c478bd9Sstevel@tonic-gate #include <stdio.h> 34*7c478bd9Sstevel@tonic-gate #include <sys/types.h> 35*7c478bd9Sstevel@tonic-gate #include <bsm/audit.h> 36*7c478bd9Sstevel@tonic-gate #include <bsm/audit_record.h> 37*7c478bd9Sstevel@tonic-gate 38*7c478bd9Sstevel@tonic-gate void 39*7c478bd9Sstevel@tonic-gate adrm_start(adr_t *adr, char *p) 40*7c478bd9Sstevel@tonic-gate { 41*7c478bd9Sstevel@tonic-gate adr->adr_stream = p; 42*7c478bd9Sstevel@tonic-gate adr->adr_now = p; 43*7c478bd9Sstevel@tonic-gate } 44*7c478bd9Sstevel@tonic-gate 45*7c478bd9Sstevel@tonic-gate /* 46*7c478bd9Sstevel@tonic-gate * adrm_char - pull out characters 47*7c478bd9Sstevel@tonic-gate */ 48*7c478bd9Sstevel@tonic-gate void 49*7c478bd9Sstevel@tonic-gate adrm_char(adr_t *adr, char *cp, int count) 50*7c478bd9Sstevel@tonic-gate { 51*7c478bd9Sstevel@tonic-gate while (count--) 52*7c478bd9Sstevel@tonic-gate *cp++ = *adr->adr_now++; 53*7c478bd9Sstevel@tonic-gate } 54*7c478bd9Sstevel@tonic-gate 55*7c478bd9Sstevel@tonic-gate /* 56*7c478bd9Sstevel@tonic-gate * adrm_short - pull out shorts 57*7c478bd9Sstevel@tonic-gate */ 58*7c478bd9Sstevel@tonic-gate void 59*7c478bd9Sstevel@tonic-gate adrm_short(adr_t *adr, short *sp, int count) 60*7c478bd9Sstevel@tonic-gate { 61*7c478bd9Sstevel@tonic-gate 62*7c478bd9Sstevel@tonic-gate while (count--) { 63*7c478bd9Sstevel@tonic-gate *sp = *adr->adr_now++ << 8; 64*7c478bd9Sstevel@tonic-gate *sp++ += ((short)*adr->adr_now++) & 0x00ff; 65*7c478bd9Sstevel@tonic-gate } 66*7c478bd9Sstevel@tonic-gate } 67*7c478bd9Sstevel@tonic-gate 68*7c478bd9Sstevel@tonic-gate /* 69*7c478bd9Sstevel@tonic-gate * adrm_int32 - pull out int 70*7c478bd9Sstevel@tonic-gate */ 71*7c478bd9Sstevel@tonic-gate void adrm_int(adr_t *adr, int32_t *lp, int count); 72*7c478bd9Sstevel@tonic-gate void adrm_long(adr_t *adr, int32_t *lp, int count); 73*7c478bd9Sstevel@tonic-gate #pragma weak adrm_int = adrm_int32 74*7c478bd9Sstevel@tonic-gate #pragma weak adrm_long = adrm_int32 75*7c478bd9Sstevel@tonic-gate 76*7c478bd9Sstevel@tonic-gate void 77*7c478bd9Sstevel@tonic-gate adrm_int32(adr_t *adr, int32_t *lp, int count) 78*7c478bd9Sstevel@tonic-gate { 79*7c478bd9Sstevel@tonic-gate int i; 80*7c478bd9Sstevel@tonic-gate 81*7c478bd9Sstevel@tonic-gate for (; count--; lp++) { 82*7c478bd9Sstevel@tonic-gate *lp = 0; 83*7c478bd9Sstevel@tonic-gate for (i = 0; i < 4; i++) { 84*7c478bd9Sstevel@tonic-gate *lp <<= 8; 85*7c478bd9Sstevel@tonic-gate *lp += ((int32_t)*adr->adr_now++) & 0x000000ff; 86*7c478bd9Sstevel@tonic-gate } 87*7c478bd9Sstevel@tonic-gate } 88*7c478bd9Sstevel@tonic-gate } 89*7c478bd9Sstevel@tonic-gate 90*7c478bd9Sstevel@tonic-gate void 91*7c478bd9Sstevel@tonic-gate adrm_int64(adr_t *adr, int64_t *lp, int count) 92*7c478bd9Sstevel@tonic-gate { 93*7c478bd9Sstevel@tonic-gate int i; 94*7c478bd9Sstevel@tonic-gate 95*7c478bd9Sstevel@tonic-gate for (; count--; lp++) { 96*7c478bd9Sstevel@tonic-gate *lp = 0; 97*7c478bd9Sstevel@tonic-gate for (i = 0; i < 8; i++) { 98*7c478bd9Sstevel@tonic-gate *lp <<= 8; 99*7c478bd9Sstevel@tonic-gate *lp += ((int64_t)*adr->adr_now++) & 0x00000000000000ff; 100*7c478bd9Sstevel@tonic-gate } 101*7c478bd9Sstevel@tonic-gate } 102*7c478bd9Sstevel@tonic-gate } 103*7c478bd9Sstevel@tonic-gate 104*7c478bd9Sstevel@tonic-gate void adrm_u_int(adr_t *adr, uint32_t *cp, int count); 105*7c478bd9Sstevel@tonic-gate void adrm_u_long(adr_t *adr, uint32_t *cp, int count); 106*7c478bd9Sstevel@tonic-gate #pragma weak adrm_u_int = adrm_u_int32 107*7c478bd9Sstevel@tonic-gate #pragma weak adrm_u_long = adrm_u_int32 108*7c478bd9Sstevel@tonic-gate 109*7c478bd9Sstevel@tonic-gate void 110*7c478bd9Sstevel@tonic-gate adrm_u_int32(adr_t *adr, uint32_t *cp, int count) 111*7c478bd9Sstevel@tonic-gate { 112*7c478bd9Sstevel@tonic-gate adrm_int32(adr, (int32_t *)cp, count); 113*7c478bd9Sstevel@tonic-gate } 114*7c478bd9Sstevel@tonic-gate 115*7c478bd9Sstevel@tonic-gate void 116*7c478bd9Sstevel@tonic-gate adrm_u_char(adr_t *adr, uchar_t *cp, int count) 117*7c478bd9Sstevel@tonic-gate { 118*7c478bd9Sstevel@tonic-gate adrm_char(adr, (char *)cp, count); 119*7c478bd9Sstevel@tonic-gate } 120*7c478bd9Sstevel@tonic-gate 121*7c478bd9Sstevel@tonic-gate void 122*7c478bd9Sstevel@tonic-gate adrm_u_int64(adr_t *adr, uint64_t *lp, int count) 123*7c478bd9Sstevel@tonic-gate { 124*7c478bd9Sstevel@tonic-gate adrm_int64(adr, (int64_t *)lp, count); 125*7c478bd9Sstevel@tonic-gate } 126*7c478bd9Sstevel@tonic-gate 127*7c478bd9Sstevel@tonic-gate void 128*7c478bd9Sstevel@tonic-gate adrm_u_short(adr_t *adr, ushort_t *sp, int count) 129*7c478bd9Sstevel@tonic-gate { 130*7c478bd9Sstevel@tonic-gate adrm_short(adr, (short *)sp, count); 131*7c478bd9Sstevel@tonic-gate } 132*7c478bd9Sstevel@tonic-gate 133*7c478bd9Sstevel@tonic-gate /* 134*7c478bd9Sstevel@tonic-gate * adrm_putint32 - pack in int32 135*7c478bd9Sstevel@tonic-gate */ 136*7c478bd9Sstevel@tonic-gate #pragma weak adrm_putint = adrm_putint32 137*7c478bd9Sstevel@tonic-gate #pragma weak adrm_putlong = adrm_putint32 138*7c478bd9Sstevel@tonic-gate void 139*7c478bd9Sstevel@tonic-gate adrm_putint32(adr_t *adr, int32_t *lp, int count) 140*7c478bd9Sstevel@tonic-gate { 141*7c478bd9Sstevel@tonic-gate int i; /* index for counting */ 142*7c478bd9Sstevel@tonic-gate int32_t l; /* value for shifting */ 143*7c478bd9Sstevel@tonic-gate 144*7c478bd9Sstevel@tonic-gate for (; count-- > 0; lp++) { 145*7c478bd9Sstevel@tonic-gate for (i = 0, l = *lp; i < 4; i++) { 146*7c478bd9Sstevel@tonic-gate *adr->adr_now++ = (char)((l & (int32_t)0xff000000) >> 147*7c478bd9Sstevel@tonic-gate (int)24); 148*7c478bd9Sstevel@tonic-gate l <<= (int)8; 149*7c478bd9Sstevel@tonic-gate } 150*7c478bd9Sstevel@tonic-gate } 151*7c478bd9Sstevel@tonic-gate } 152