4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved.
26 * Adr memory based encoding
29 #include <sys/feature_tests.h>
31 #pragma weak adr_ushort = adr_short
32 #pragma weak adr_uint32 = adr_int32
33 #pragma weak adr_uint64 = adr_int64
34 #pragma weak adr_getushort = adr_getshort
35 #pragma weak adr_getuint32 = adr_getint32
36 #pragma weak adr_getuint64 = adr_getint64
38 #include <sys/types.h>
39 #include <sys/t_lock.h>
40 #include <sys/systm.h>
41 #include <sys/mutex.h>
42 #include <sys/thread.h>
44 #include <c2/audit_kernel.h>
45 #include <c2/audit_record.h>
48 adr_start(adr_t
*adr
, char *p
)
57 return ((int)((uintptr_t)adr
->adr_now
- (uintptr_t)adr
->adr_stream
));
62 * adr_char - pull out characters
65 adr_char(adr_t
*adr
, char *cp
, int count
)
68 *adr
->adr_now
++ = *cp
++;
72 * adr_short - pull out shorts
75 adr_short(adr_t
*adr
, short *sp
, int count
)
78 for (; count
-- > 0; sp
++) {
79 *adr
->adr_now
++ = (char)((*sp
>> (int)8) & 0x00ff);
80 *adr
->adr_now
++ = (char)(*sp
& 0x00ff);
85 * adr_int32 - pull out int32
88 adr_int32(adr_t
*adr
, int32_t *lp
, int count
)
90 int i
; /* index for counting */
91 int32_t l
; /* value for shifting */
93 for (; count
-- > 0; lp
++) {
94 for (i
= 0, l
= *lp
; i
< 4; i
++) {
95 *adr
->adr_now
++ = (char)((l
& (int32_t)0xff000000) >>
103 * adr_int64 - pull out int64
106 adr_int64(adr_t
*adr
, int64_t *lp
, int count
)
108 int i
; /* index for counting */
109 int64_t l
; /* value for shifting */
111 for (; count
-- > 0; lp
++) {
112 for (i
= 0, l
= *lp
; i
< 8; i
++) {
114 (char)((l
& (int64_t)0xff00000000000000) >>
123 adr_getchar(adr_t
*adr
, char *cp
)
128 *cp
= *adr
->adr_now
++;
133 adr_getshort(adr_t
*adr
, short *sp
)
138 *sp
= *adr
->adr_now
++;
140 *sp
= *adr
->adr_now
++;
146 adr_getint32(adr_t
*adr
, int32_t *lp
)
152 for (i
= 0; i
< 4; i
++) {
154 *lp
+= ((int32_t)*adr
->adr_now
++) & 0x000000ff;
161 adr_getint64(adr_t
*adr
, int64_t *lp
)
167 for (i
= 0; i
< 8; i
++) {
169 *lp
+= ((int64_t)*adr
->adr_now
++) & 0x00000000000000ff;