Lines Matching defs:table
35 * Number of bytes we allocate at a given time for an SMBIOS table.
65 smbios_test_table_t *table;
71 table = umem_zalloc(sizeof (smbios_test_table_t), UMEM_DEFAULT);
72 if (table == NULL) {
76 table->stt_data = umem_zalloc(SMBIOS_TEST_ALLOC_SIZE, UMEM_DEFAULT);
77 if (table->stt_data == NULL) {
78 umem_free(table, sizeof (smbios_test_table_t));
81 table->stt_buflen = SMBIOS_TEST_ALLOC_SIZE;
82 table->stt_type = type;
83 table->stt_version = version;
84 table->stt_nextid = 1;
86 return (table);
90 smbios_test_table_append_common(smbios_test_table_t *table, const void *buf,
95 if (SIZE_MAX - table->stt_offset < len)
98 if (len + table->stt_offset >= table->stt_buflen) {
100 size_t newlen = table->stt_buflen + SMBIOS_TEST_ALLOC_SIZE;
102 while (len + table->stt_offset >= newlen) {
112 (void) memcpy(newbuf, table->stt_data, table->stt_buflen);
113 umem_free(table->stt_data, table->stt_buflen);
114 table->stt_data = newbuf;
115 table->stt_buflen = newlen;
118 start = (void *)((uintptr_t)table->stt_data + table->stt_offset);
120 table->stt_offset += len;
126 smbios_test_table_append_raw(smbios_test_table_t *table, const void *buf,
129 (void) smbios_test_table_append_common(table, buf, len);
133 smbios_test_table_append_string(smbios_test_table_t *table, const char *str)
136 (void) smbios_test_table_append_common(table, str, len);
140 smbios_test_table_append(smbios_test_table_t *table, const void *buf,
146 hdr = smbios_test_table_append_common(table, buf, len);
147 table->stt_nents++;
149 id = table->stt_nextid;
150 hdr->smbh_hdl = htole16(table->stt_nextid);
151 table->stt_nextid++;
173 smbios_test_table_snapshot(smbios_test_table_t *table, smbios_entry_t **entryp,
178 switch (table->stt_type) {
180 ent30 = &table->stt_entry.ep30;
186 ent30->smbe_major = (table->stt_version >> 8) & 0xff;
187 ent30->smbe_minor = table->stt_version & 0xff;
191 ent30->smbe_stlen = htole32(table->stt_offset);
201 *entryp = &table->stt_entry;
202 *bufp = table->stt_data;
203 *lenp = table->stt_offset;
207 smbios_test_table_fini(smbios_test_table_t *table)
209 if (table == NULL) {
213 if (table->stt_data != NULL) {
214 umem_free(table->stt_data, table->stt_buflen);
217 umem_free(table, sizeof (smbios_test_table_t));
221 smbios_test_mktable(smbios_test_table_t *table)
253 (void) smbios_test_table_append(table, &slot, sizeof (slot));
254 (void) smbios_test_table_append_raw(table, peers, sizeof (peers));
255 (void) smbios_test_table_append_string(table, smbios_test_name);
256 (void) smbios_test_table_append_raw(table, &endstring,
262 (void) smbios_test_table_append(table, &eot, sizeof (eot));
263 (void) smbios_test_table_append_raw(table, &endstring,
265 (void) smbios_test_table_append_raw(table, &endstring,
391 smbios_test_table_t *table;
396 table = smbios_test_table_init(SMBIOS_ENTRY_POINT_30, SMB_VERSION_32);
397 smbios_test_mktable(table);
398 smbios_test_table_snapshot(table, &entry, &buf, &len);
403 errx(EXIT_FAILURE, "failed to create fake smbios table: %s",
408 smbios_test_table_fini(table);