xref: /titanic_51/usr/src/lib/libfru/libfru/PayloadReader.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright (c) 2000-2001 by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #ifndef	_PAYLOADREADER_H
28 #define	_PAYLOADREADER_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 #ifdef	__cplusplus
37 }
38 #endif
39 
40 #include "Parser.h"
41 
42 #define	NORMAL_READ 0
43 #define	ITER_THERE_ONLY 1
44 
45 struct PayloadReader
46 {
47 	// will send the data back in (data,dataLen)
48 	static fru_errno_t readData(PathDef *path, Ancestor *curDef,
49 				int instWICur,
50 				uint8_t *payload, size_t payloadLen,
51 				void **data, size_t *dataLen);
52 
53 	// will update the data in payload which can then be written back.
54 	static fru_errno_t updateData(PathDef *path, Ancestor *curDef,
55 				int instWICur,
56 				uint8_t *payload, size_t payloadLen,
57 				void *data, size_t dataLen);
58 
59 	// will return the nuber of iterations actually there.
60 	static fru_errno_t findIterThere(PathDef *path, Ancestor *curDef,
61 				int instWICur,
62 				uint8_t *payload, size_t payloadLen,
63 				int *numThere);
64 
65 private:
66 	static int getIterationOffset(uint8_t *iter, int iterLen,
67 				PathDef *path, int *rcIterThere,
68 				fru_errno_t *err,
69 				int onlyFindingIterThereFlag);
70 	static int calcOffset(int iterType,
71 				uint8_t head, uint8_t tail,
72 				uint8_t iterThere, uint8_t iterPoss,
73 				size_t length, int index,
74 				fru_errno_t *err);
75 
76 	static fru_errno_t readRecurse(PathDef *path,
77 				uint8_t *cur, size_t curLen,
78 				void **data, size_t *dataLen,
79 				int onlyFindingIterThereFlag);
80 
81 	static fru_errno_t updateRecurse(PathDef *path,
82 				uint8_t *cur, size_t curLen,
83 				void *data, size_t dataLen);
84 
85 	static int getOffsetIntoRecord(fru_regdef_t *recDef,
86 				fru_regdef_t *elemDef);
87 
88 	PayloadReader();
89 	~PayloadReader();
90 	PayloadReader(const PayloadReader&);
91 	void operator=(const PayloadReader&);
92 };
93 
94 #ifdef __cplusplus
95 extern "C" {
96 #endif
97 
98 #ifdef	__cplusplus
99 }
100 #endif
101 
102 #endif /* _PAYLOADREADER_H */
103