Commit 982610bd authored by Stefan Richter's avatar Stefan Richter

ieee1394: csr1212: rename some types

Use u8, u32 etc. instead of u_int8_t, csr1212_quad_t etc.
Signed-off-by: default avatarStefan Richter <stefanr@s5r6.in-berlin.de>
parent 7fb9addb
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
#define __C (1 << CSR1212_KV_TYPE_CSR_OFFSET) #define __C (1 << CSR1212_KV_TYPE_CSR_OFFSET)
#define __D (1 << CSR1212_KV_TYPE_DIRECTORY) #define __D (1 << CSR1212_KV_TYPE_DIRECTORY)
#define __L (1 << CSR1212_KV_TYPE_LEAF) #define __L (1 << CSR1212_KV_TYPE_LEAF)
static const u_int8_t csr1212_key_id_type_map[0x30] = { static const u8 csr1212_key_id_type_map[0x30] = {
__C, /* used by Apple iSight */ __C, /* used by Apple iSight */
__D | __L, /* Descriptor */ __D | __L, /* Descriptor */
__I | __D | __L, /* Bus_Dependent_Info */ __I | __D | __L, /* Bus_Dependent_Info */
...@@ -81,8 +81,8 @@ static const u_int8_t csr1212_key_id_type_map[0x30] = { ...@@ -81,8 +81,8 @@ static const u_int8_t csr1212_key_id_type_map[0x30] = {
#undef __L #undef __L
#define quads_to_bytes(_q) ((_q) * sizeof(u_int32_t)) #define quads_to_bytes(_q) ((_q) * sizeof(u32))
#define bytes_to_quads(_b) (((_b) + sizeof(u_int32_t) - 1) / sizeof(u_int32_t)) #define bytes_to_quads(_b) (((_b) + sizeof(u32) - 1) / sizeof(u32))
static void free_keyval(struct csr1212_keyval *kv) static void free_keyval(struct csr1212_keyval *kv)
{ {
...@@ -93,11 +93,11 @@ static void free_keyval(struct csr1212_keyval *kv) ...@@ -93,11 +93,11 @@ static void free_keyval(struct csr1212_keyval *kv)
CSR1212_FREE(kv); CSR1212_FREE(kv);
} }
static u_int16_t csr1212_crc16(const u_int32_t *buffer, size_t length) static u16 csr1212_crc16(const u32 *buffer, size_t length)
{ {
int shift; int shift;
u_int32_t data; u32 data;
u_int16_t sum, crc = 0; u16 sum, crc = 0;
for (; length; length--) { for (; length; length--) {
data = be32_to_cpu(*buffer); data = be32_to_cpu(*buffer);
...@@ -116,11 +116,11 @@ static u_int16_t csr1212_crc16(const u_int32_t *buffer, size_t length) ...@@ -116,11 +116,11 @@ static u_int16_t csr1212_crc16(const u_int32_t *buffer, size_t length)
/* Microsoft computes the CRC with the bytes in reverse order. Therefore we /* Microsoft computes the CRC with the bytes in reverse order. Therefore we
* have a special version of the CRC algorithm to account for their buggy * have a special version of the CRC algorithm to account for their buggy
* software. */ * software. */
static u_int16_t csr1212_msft_crc16(const u_int32_t *buffer, size_t length) static u16 csr1212_msft_crc16(const u32 *buffer, size_t length)
{ {
int shift; int shift;
u_int32_t data; u32 data;
u_int16_t sum, crc = 0; u16 sum, crc = 0;
for (; length; length--) { for (; length; length--) {
data = le32_to_cpu(*buffer); data = le32_to_cpu(*buffer);
...@@ -150,7 +150,7 @@ csr1212_find_keyval(struct csr1212_keyval *dir, struct csr1212_keyval *kv) ...@@ -150,7 +150,7 @@ csr1212_find_keyval(struct csr1212_keyval *dir, struct csr1212_keyval *kv)
} }
static struct csr1212_keyval * static struct csr1212_keyval *
csr1212_find_keyval_offset(struct csr1212_keyval *kv_list, u_int32_t offset) csr1212_find_keyval_offset(struct csr1212_keyval *kv_list, u32 offset)
{ {
struct csr1212_keyval *kv; struct csr1212_keyval *kv;
...@@ -202,7 +202,7 @@ struct csr1212_csr *csr1212_create_csr(struct csr1212_bus_ops *ops, ...@@ -202,7 +202,7 @@ struct csr1212_csr *csr1212_create_csr(struct csr1212_bus_ops *ops,
} }
void csr1212_init_local_csr(struct csr1212_csr *csr, void csr1212_init_local_csr(struct csr1212_csr *csr,
const u_int32_t *bus_info_data, int max_rom) const u32 *bus_info_data, int max_rom)
{ {
static const int mr_map[] = { 4, 64, 1024, 0 }; static const int mr_map[] = { 4, 64, 1024, 0 };
...@@ -211,7 +211,7 @@ void csr1212_init_local_csr(struct csr1212_csr *csr, ...@@ -211,7 +211,7 @@ void csr1212_init_local_csr(struct csr1212_csr *csr,
memcpy(csr->bus_info_data, bus_info_data, csr->bus_info_len); memcpy(csr->bus_info_data, bus_info_data, csr->bus_info_len);
} }
static struct csr1212_keyval *csr1212_new_keyval(u_int8_t type, u_int8_t key) static struct csr1212_keyval *csr1212_new_keyval(u8 type, u8 key)
{ {
struct csr1212_keyval *kv; struct csr1212_keyval *kv;
...@@ -235,7 +235,7 @@ static struct csr1212_keyval *csr1212_new_keyval(u_int8_t type, u_int8_t key) ...@@ -235,7 +235,7 @@ static struct csr1212_keyval *csr1212_new_keyval(u_int8_t type, u_int8_t key)
return kv; return kv;
} }
struct csr1212_keyval *csr1212_new_immediate(u_int8_t key, u_int32_t value) struct csr1212_keyval *csr1212_new_immediate(u8 key, u32 value)
{ {
struct csr1212_keyval *kv = csr1212_new_keyval(CSR1212_KV_TYPE_IMMEDIATE, key); struct csr1212_keyval *kv = csr1212_new_keyval(CSR1212_KV_TYPE_IMMEDIATE, key);
...@@ -248,7 +248,7 @@ struct csr1212_keyval *csr1212_new_immediate(u_int8_t key, u_int32_t value) ...@@ -248,7 +248,7 @@ struct csr1212_keyval *csr1212_new_immediate(u_int8_t key, u_int32_t value)
} }
static struct csr1212_keyval * static struct csr1212_keyval *
csr1212_new_leaf(u_int8_t key, const void *data, size_t data_len) csr1212_new_leaf(u8 key, const void *data, size_t data_len)
{ {
struct csr1212_keyval *kv = csr1212_new_keyval(CSR1212_KV_TYPE_LEAF, key); struct csr1212_keyval *kv = csr1212_new_keyval(CSR1212_KV_TYPE_LEAF, key);
...@@ -276,7 +276,7 @@ csr1212_new_leaf(u_int8_t key, const void *data, size_t data_len) ...@@ -276,7 +276,7 @@ csr1212_new_leaf(u_int8_t key, const void *data, size_t data_len)
} }
static struct csr1212_keyval * static struct csr1212_keyval *
csr1212_new_csr_offset(u_int8_t key, u_int32_t csr_offset) csr1212_new_csr_offset(u8 key, u32 csr_offset)
{ {
struct csr1212_keyval *kv = csr1212_new_keyval(CSR1212_KV_TYPE_CSR_OFFSET, key); struct csr1212_keyval *kv = csr1212_new_keyval(CSR1212_KV_TYPE_CSR_OFFSET, key);
...@@ -290,7 +290,7 @@ csr1212_new_csr_offset(u_int8_t key, u_int32_t csr_offset) ...@@ -290,7 +290,7 @@ csr1212_new_csr_offset(u_int8_t key, u_int32_t csr_offset)
return kv; return kv;
} }
struct csr1212_keyval *csr1212_new_directory(u_int8_t key) struct csr1212_keyval *csr1212_new_directory(u8 key)
{ {
struct csr1212_keyval *kv = csr1212_new_keyval(CSR1212_KV_TYPE_DIRECTORY, key); struct csr1212_keyval *kv = csr1212_new_keyval(CSR1212_KV_TYPE_DIRECTORY, key);
...@@ -387,7 +387,7 @@ int csr1212_attach_keyval_to_directory(struct csr1212_keyval *dir, ...@@ -387,7 +387,7 @@ int csr1212_attach_keyval_to_directory(struct csr1212_keyval *dir,
((spec_id) & CSR1212_DESCRIPTOR_LEAF_SPECIFIER_ID_MASK))) ((spec_id) & CSR1212_DESCRIPTOR_LEAF_SPECIFIER_ID_MASK)))
static struct csr1212_keyval * static struct csr1212_keyval *
csr1212_new_descriptor_leaf(u_int8_t dtype, u_int32_t specifier_id, csr1212_new_descriptor_leaf(u8 dtype, u32 specifier_id,
const void *data, size_t data_len) const void *data, size_t data_len)
{ {
struct csr1212_keyval *kv; struct csr1212_keyval *kv;
...@@ -432,9 +432,8 @@ csr1212_new_descriptor_leaf(u_int8_t dtype, u_int32_t specifier_id, ...@@ -432,9 +432,8 @@ csr1212_new_descriptor_leaf(u_int8_t dtype, u_int32_t specifier_id,
CSR1212_TEXTUAL_DESCRIPTOR_LEAF_LANGUAGE_MASK))) CSR1212_TEXTUAL_DESCRIPTOR_LEAF_LANGUAGE_MASK)))
static struct csr1212_keyval * static struct csr1212_keyval *
csr1212_new_textual_descriptor_leaf(u_int8_t cwidth, u_int16_t cset, csr1212_new_textual_descriptor_leaf(u8 cwidth, u16 cset, u16 language,
u_int16_t language, const void *data, const void *data, size_t data_len)
size_t data_len)
{ {
struct csr1212_keyval *kv; struct csr1212_keyval *kv;
char *lstr; char *lstr;
...@@ -451,7 +450,7 @@ csr1212_new_textual_descriptor_leaf(u_int8_t cwidth, u_int16_t cset, ...@@ -451,7 +450,7 @@ csr1212_new_textual_descriptor_leaf(u_int8_t cwidth, u_int16_t cset,
lstr = (char*)CSR1212_TEXTUAL_DESCRIPTOR_LEAF_DATA(kv); lstr = (char*)CSR1212_TEXTUAL_DESCRIPTOR_LEAF_DATA(kv);
/* make sure last quadlet is zeroed out */ /* make sure last quadlet is zeroed out */
*((u_int32_t*)&(lstr[(data_len - 1) & ~0x3])) = 0; *((u32*)&(lstr[(data_len - 1) & ~0x3])) = 0;
/* don't copy the NUL terminator */ /* don't copy the NUL terminator */
memcpy(lstr, data, data_len); memcpy(lstr, data, data_len);
...@@ -610,7 +609,7 @@ void csr1212_destroy_csr(struct csr1212_csr *csr) ...@@ -610,7 +609,7 @@ void csr1212_destroy_csr(struct csr1212_csr *csr)
static int csr1212_append_new_cache(struct csr1212_csr *csr, size_t romsize) static int csr1212_append_new_cache(struct csr1212_csr *csr, size_t romsize)
{ {
struct csr1212_csr_rom_cache *cache; struct csr1212_csr_rom_cache *cache;
u_int64_t csr_addr; u64 csr_addr;
if (!csr || !csr->ops || !csr->ops->allocate_addr_range || if (!csr || !csr->ops || !csr->ops->allocate_addr_range ||
!csr->ops->release_addr || csr->max_rom < 1) !csr->ops->release_addr || csr->max_rom < 1)
...@@ -824,7 +823,7 @@ csr1212_generate_positions(struct csr1212_csr_rom_cache *cache, ...@@ -824,7 +823,7 @@ csr1212_generate_positions(struct csr1212_csr_rom_cache *cache,
#define CSR1212_KV_KEY_TYPE_MASK 0x3 /* after shift */ #define CSR1212_KV_KEY_TYPE_MASK 0x3 /* after shift */
static void static void
csr1212_generate_tree_subdir(struct csr1212_keyval *dir, u_int32_t *data_buffer) csr1212_generate_tree_subdir(struct csr1212_keyval *dir, u32 *data_buffer)
{ {
struct csr1212_dentry *dentry; struct csr1212_dentry *dentry;
struct csr1212_keyval *last_extkey_spec = NULL; struct csr1212_keyval *last_extkey_spec = NULL;
...@@ -835,7 +834,7 @@ csr1212_generate_tree_subdir(struct csr1212_keyval *dir, u_int32_t *data_buffer) ...@@ -835,7 +834,7 @@ csr1212_generate_tree_subdir(struct csr1212_keyval *dir, u_int32_t *data_buffer)
struct csr1212_keyval *a; struct csr1212_keyval *a;
for (a = dentry->kv; a; a = a->associate) { for (a = dentry->kv; a; a = a->associate) {
u_int32_t value = 0; u32 value = 0;
/* Special Case: Extended Key Specifier_ID */ /* Special Case: Extended Key Specifier_ID */
if (a->key.id == CSR1212_KV_ID_EXTENDED_KEY_SPECIFIER_ID) { if (a->key.id == CSR1212_KV_ID_EXTENDED_KEY_SPECIFIER_ID) {
...@@ -889,11 +888,11 @@ csr1212_generate_tree_subdir(struct csr1212_keyval *dir, u_int32_t *data_buffer) ...@@ -889,11 +888,11 @@ csr1212_generate_tree_subdir(struct csr1212_keyval *dir, u_int32_t *data_buffer)
} }
struct csr1212_keyval_img { struct csr1212_keyval_img {
u_int16_t length; u16 length;
u_int16_t crc; u16 crc;
/* Must be last */ /* Must be last */
csr1212_quad_t data[0]; /* older gcc can't handle [] which is standard */ u32 data[0]; /* older gcc can't handle [] which is standard */
}; };
static void csr1212_fill_cache(struct csr1212_csr_rom_cache *cache) static void csr1212_fill_cache(struct csr1212_csr_rom_cache *cache)
...@@ -940,7 +939,7 @@ static void csr1212_fill_cache(struct csr1212_csr_rom_cache *cache) ...@@ -940,7 +939,7 @@ static void csr1212_fill_cache(struct csr1212_csr_rom_cache *cache)
} }
} }
#define CSR1212_EXTENDED_ROM_SIZE (0x10000 * sizeof(u_int32_t)) #define CSR1212_EXTENDED_ROM_SIZE (0x10000 * sizeof(u32))
int csr1212_generate_csr_image(struct csr1212_csr *csr) int csr1212_generate_csr_image(struct csr1212_csr *csr)
{ {
...@@ -975,7 +974,7 @@ int csr1212_generate_csr_image(struct csr1212_csr *csr) ...@@ -975,7 +974,7 @@ int csr1212_generate_csr_image(struct csr1212_csr *csr)
* regions needed (it assumes that the cache holding * regions needed (it assumes that the cache holding
* the first 1K Config ROM space always exists). */ * the first 1K Config ROM space always exists). */
int est_c = agg_size / (CSR1212_EXTENDED_ROM_SIZE - int est_c = agg_size / (CSR1212_EXTENDED_ROM_SIZE -
(2 * sizeof(u_int32_t))) + 1; (2 * sizeof(u32))) + 1;
/* Add additional cache regions, extras will be /* Add additional cache regions, extras will be
* removed later */ * removed later */
...@@ -992,7 +991,7 @@ int csr1212_generate_csr_image(struct csr1212_csr *csr) ...@@ -992,7 +991,7 @@ int csr1212_generate_csr_image(struct csr1212_csr *csr)
} }
kv = csr1212_generate_positions(cache, kv, init_offset); kv = csr1212_generate_positions(cache, kv, init_offset);
agg_size -= cache->len; agg_size -= cache->len;
init_offset = sizeof(u_int32_t); init_offset = sizeof(u32);
} }
/* Remove unused, excess cache regions */ /* Remove unused, excess cache regions */
...@@ -1022,7 +1021,7 @@ int csr1212_generate_csr_image(struct csr1212_csr *csr) ...@@ -1022,7 +1021,7 @@ int csr1212_generate_csr_image(struct csr1212_csr *csr)
leaf_size - cache->len); leaf_size - cache->len);
/* Subtract leaf header */ /* Subtract leaf header */
leaf_size -= sizeof(u_int32_t); leaf_size -= sizeof(u32);
/* Update the Extended ROM leaf length */ /* Update the Extended ROM leaf length */
cache->ext_rom->value.leaf.len = cache->ext_rom->value.leaf.len =
...@@ -1040,7 +1039,7 @@ int csr1212_generate_csr_image(struct csr1212_csr *csr) ...@@ -1040,7 +1039,7 @@ int csr1212_generate_csr_image(struct csr1212_csr *csr)
/* Set the length and CRC of the extended ROM. */ /* Set the length and CRC of the extended ROM. */
struct csr1212_keyval_img *kvi = struct csr1212_keyval_img *kvi =
(struct csr1212_keyval_img*)cache->data; (struct csr1212_keyval_img*)cache->data;
u_int16_t len = bytes_to_quads(cache->len) - 1; u16 len = bytes_to_quads(cache->len) - 1;
kvi->length = cpu_to_be16(len); kvi->length = cpu_to_be16(len);
kvi->crc = csr1212_crc16(kvi->data, len); kvi->crc = csr1212_crc16(kvi->data, len);
...@@ -1050,7 +1049,7 @@ int csr1212_generate_csr_image(struct csr1212_csr *csr) ...@@ -1050,7 +1049,7 @@ int csr1212_generate_csr_image(struct csr1212_csr *csr)
return CSR1212_SUCCESS; return CSR1212_SUCCESS;
} }
int csr1212_read(struct csr1212_csr *csr, u_int32_t offset, void *buffer, u_int32_t len) int csr1212_read(struct csr1212_csr *csr, u32 offset, void *buffer, u32 len)
{ {
struct csr1212_csr_rom_cache *cache; struct csr1212_csr_rom_cache *cache;
...@@ -1081,9 +1080,9 @@ static int csr1212_parse_bus_info_block(struct csr1212_csr *csr) ...@@ -1081,9 +1080,9 @@ static int csr1212_parse_bus_info_block(struct csr1212_csr *csr)
* Unfortunately, many IEEE 1394 devices do not abide by that, so the * Unfortunately, many IEEE 1394 devices do not abide by that, so the
* bus info block will be read 1 quadlet at a time. The rest of the * bus info block will be read 1 quadlet at a time. The rest of the
* ConfigROM will be read according to the max_rom field. */ * ConfigROM will be read according to the max_rom field. */
for (i = 0; i < csr->bus_info_len; i += sizeof(csr1212_quad_t)) { for (i = 0; i < csr->bus_info_len; i += sizeof(u32)) {
ret = csr->ops->bus_read(csr, CSR1212_CONFIG_ROM_SPACE_BASE + i, ret = csr->ops->bus_read(csr, CSR1212_CONFIG_ROM_SPACE_BASE + i,
sizeof(csr1212_quad_t), sizeof(u32),
&csr->cache_head->data[bytes_to_quads(i)], &csr->cache_head->data[bytes_to_quads(i)],
csr->private); csr->private);
if (ret != CSR1212_SUCCESS) if (ret != CSR1212_SUCCESS)
...@@ -1101,9 +1100,9 @@ static int csr1212_parse_bus_info_block(struct csr1212_csr *csr) ...@@ -1101,9 +1100,9 @@ static int csr1212_parse_bus_info_block(struct csr1212_csr *csr)
/* IEEE 1212 recommends that crc_len be equal to bus_info_len, but that is not /* IEEE 1212 recommends that crc_len be equal to bus_info_len, but that is not
* always the case, so read the rest of the crc area 1 quadlet at a time. */ * always the case, so read the rest of the crc area 1 quadlet at a time. */
for (i = csr->bus_info_len; i <= csr->crc_len; i += sizeof(csr1212_quad_t)) { for (i = csr->bus_info_len; i <= csr->crc_len; i += sizeof(u32)) {
ret = csr->ops->bus_read(csr, CSR1212_CONFIG_ROM_SPACE_BASE + i, ret = csr->ops->bus_read(csr, CSR1212_CONFIG_ROM_SPACE_BASE + i,
sizeof(csr1212_quad_t), sizeof(u32),
&csr->cache_head->data[bytes_to_quads(i)], &csr->cache_head->data[bytes_to_quads(i)],
csr->private); csr->private);
if (ret != CSR1212_SUCCESS) if (ret != CSR1212_SUCCESS)
...@@ -1140,12 +1139,11 @@ static int csr1212_parse_bus_info_block(struct csr1212_csr *csr) ...@@ -1140,12 +1139,11 @@ static int csr1212_parse_bus_info_block(struct csr1212_csr *csr)
#define CSR1212_KV_VAL(q) (be32_to_cpu(q) & CSR1212_KV_VAL_MASK) #define CSR1212_KV_VAL(q) (be32_to_cpu(q) & CSR1212_KV_VAL_MASK)
static int csr1212_parse_dir_entry(struct csr1212_keyval *dir, static int csr1212_parse_dir_entry(struct csr1212_keyval *dir,
csr1212_quad_t ki, u32 ki, u32 kv_pos)
u_int32_t kv_pos)
{ {
int ret = CSR1212_SUCCESS; int ret = CSR1212_SUCCESS;
struct csr1212_keyval *k = NULL; struct csr1212_keyval *k = NULL;
u_int32_t offset; u32 offset;
switch(CSR1212_KV_KEY_TYPE(ki)) { switch(CSR1212_KV_KEY_TYPE(ki)) {
case CSR1212_KV_TYPE_IMMEDIATE: case CSR1212_KV_TYPE_IMMEDIATE:
...@@ -1236,7 +1234,7 @@ int csr1212_parse_keyval(struct csr1212_keyval *kv, ...@@ -1236,7 +1234,7 @@ int csr1212_parse_keyval(struct csr1212_keyval *kv,
switch(kv->key.type) { switch(kv->key.type) {
case CSR1212_KV_TYPE_DIRECTORY: case CSR1212_KV_TYPE_DIRECTORY:
for (i = 0; i < kvi_len; i++) { for (i = 0; i < kvi_len; i++) {
csr1212_quad_t ki = kvi->data[i]; u32 ki = kvi->data[i];
/* Some devices put null entries in their unit /* Some devices put null entries in their unit
* directories. If we come across such an entry, * directories. If we come across such an entry,
...@@ -1276,9 +1274,9 @@ int _csr1212_read_keyval(struct csr1212_csr *csr, struct csr1212_keyval *kv) ...@@ -1276,9 +1274,9 @@ int _csr1212_read_keyval(struct csr1212_csr *csr, struct csr1212_keyval *kv)
struct csr1212_keyval_img *kvi = NULL; struct csr1212_keyval_img *kvi = NULL;
struct csr1212_csr_rom_cache *cache; struct csr1212_csr_rom_cache *cache;
int cache_index; int cache_index;
u_int64_t addr; u64 addr;
u_int32_t *cache_ptr; u32 *cache_ptr;
u_int16_t kv_len = 0; u16 kv_len = 0;
if (!csr || !kv || csr->max_rom < 1) if (!csr || !kv || csr->max_rom < 1)
return -EINVAL; return -EINVAL;
...@@ -1292,8 +1290,7 @@ int _csr1212_read_keyval(struct csr1212_csr *csr, struct csr1212_keyval *kv) ...@@ -1292,8 +1290,7 @@ int _csr1212_read_keyval(struct csr1212_csr *csr, struct csr1212_keyval *kv)
} }
if (!cache) { if (!cache) {
csr1212_quad_t q; u32 q, cache_size;
u_int32_t cache_size;
/* Only create a new cache for Extended ROM leaves. */ /* Only create a new cache for Extended ROM leaves. */
if (kv->key.id != CSR1212_KV_ID_EXTENDED_ROM) if (kv->key.id != CSR1212_KV_ID_EXTENDED_ROM)
...@@ -1301,7 +1298,7 @@ int _csr1212_read_keyval(struct csr1212_csr *csr, struct csr1212_keyval *kv) ...@@ -1301,7 +1298,7 @@ int _csr1212_read_keyval(struct csr1212_csr *csr, struct csr1212_keyval *kv)
if (csr->ops->bus_read(csr, if (csr->ops->bus_read(csr,
CSR1212_REGISTER_SPACE_BASE + kv->offset, CSR1212_REGISTER_SPACE_BASE + kv->offset,
sizeof(csr1212_quad_t), &q, csr->private)) { sizeof(u32), &q, csr->private)) {
return -EIO; return -EIO;
} }
...@@ -1326,7 +1323,7 @@ int _csr1212_read_keyval(struct csr1212_csr *csr, struct csr1212_keyval *kv) ...@@ -1326,7 +1323,7 @@ int _csr1212_read_keyval(struct csr1212_csr *csr, struct csr1212_keyval *kv)
} }
cache->filled_head->offset_start = 0; cache->filled_head->offset_start = 0;
cache->filled_head->offset_end = sizeof(csr1212_quad_t); cache->filled_head->offset_end = sizeof(u32);
cache->filled_tail = cache->filled_head; cache->filled_tail = cache->filled_head;
cache->filled_head->next = NULL; cache->filled_head->next = NULL;
cache->filled_head->prev = NULL; cache->filled_head->prev = NULL;
......
...@@ -114,19 +114,17 @@ ...@@ -114,19 +114,17 @@
/* Config ROM image structures */ /* Config ROM image structures */
struct csr1212_bus_info_block_img { struct csr1212_bus_info_block_img {
u_int8_t length; u8 length;
u_int8_t crc_length; u8 crc_length;
u_int16_t crc; u16 crc;
/* Must be last */ /* Must be last */
u_int32_t data[0]; /* older gcc can't handle [] which is standard */ u32 data[0]; /* older gcc can't handle [] which is standard */
}; };
typedef u_int32_t csr1212_quad_t;
struct csr1212_leaf { struct csr1212_leaf {
int len; int len;
u_int32_t *data; u32 *data;
}; };
struct csr1212_dentry { struct csr1212_dentry {
...@@ -141,12 +139,12 @@ struct csr1212_directory { ...@@ -141,12 +139,12 @@ struct csr1212_directory {
struct csr1212_keyval { struct csr1212_keyval {
struct { struct {
u_int8_t type; u8 type;
u_int8_t id; u8 id;
} key; } key;
union { union {
u_int32_t immediate; u32 immediate;
u_int32_t csr_offset; u32 csr_offset;
struct csr1212_leaf leaf; struct csr1212_leaf leaf;
struct csr1212_directory directory; struct csr1212_directory directory;
} value; } value;
...@@ -155,15 +153,15 @@ struct csr1212_keyval { ...@@ -155,15 +153,15 @@ struct csr1212_keyval {
/* used in generating and/or parsing CSR image */ /* used in generating and/or parsing CSR image */
struct csr1212_keyval *next, *prev; /* flat list of CSR elements */ struct csr1212_keyval *next, *prev; /* flat list of CSR elements */
u_int32_t offset; /* position in CSR from 0xffff f000 0000 */ u32 offset; /* position in CSR from 0xffff f000 0000 */
u_int8_t valid; /* flag indicating keyval has valid data*/ u8 valid; /* flag indicating keyval has valid data*/
}; };
struct csr1212_cache_region { struct csr1212_cache_region {
struct csr1212_cache_region *next, *prev; struct csr1212_cache_region *next, *prev;
u_int32_t offset_start; /* inclusive */ u32 offset_start; /* inclusive */
u_int32_t offset_end; /* exclusive */ u32 offset_end; /* exclusive */
}; };
struct csr1212_csr_rom_cache { struct csr1212_csr_rom_cache {
...@@ -171,18 +169,18 @@ struct csr1212_csr_rom_cache { ...@@ -171,18 +169,18 @@ struct csr1212_csr_rom_cache {
struct csr1212_cache_region *filled_head, *filled_tail; struct csr1212_cache_region *filled_head, *filled_tail;
struct csr1212_keyval *layout_head, *layout_tail; struct csr1212_keyval *layout_head, *layout_tail;
size_t size; size_t size;
u_int32_t offset; u32 offset;
struct csr1212_keyval *ext_rom; struct csr1212_keyval *ext_rom;
size_t len; size_t len;
/* Must be last */ /* Must be last */
u_int32_t data[0]; /* older gcc can't handle [] which is standard */ u32 data[0]; /* older gcc can't handle [] which is standard */
}; };
struct csr1212_csr { struct csr1212_csr {
size_t bus_info_len; /* bus info block length in bytes */ size_t bus_info_len; /* bus info block length in bytes */
size_t crc_len; /* crc length in bytes */ size_t crc_len; /* crc length in bytes */
u_int32_t *bus_info_data; /* bus info data incl bus name and EUI */ u32 *bus_info_data; /* bus info data incl bus name and EUI */
void *private; /* private, bus specific data */ void *private; /* private, bus specific data */
struct csr1212_bus_ops *ops; struct csr1212_bus_ops *ops;
...@@ -200,32 +198,30 @@ struct csr1212_bus_ops { ...@@ -200,32 +198,30 @@ struct csr1212_bus_ops {
* from remote nodes when parsing a Config ROM (i.e., read Config ROM * from remote nodes when parsing a Config ROM (i.e., read Config ROM
* entries located in the Units Space. Must return 0 on success * entries located in the Units Space. Must return 0 on success
* anything else indicates an error. */ * anything else indicates an error. */
int (*bus_read) (struct csr1212_csr *csr, u_int64_t addr, int (*bus_read) (struct csr1212_csr *csr, u64 addr,
u_int16_t length, void *buffer, void *private); u16 length, void *buffer, void *private);
/* This function is used by csr1212 to allocate a region in units space /* This function is used by csr1212 to allocate a region in units space
* in the event that Config ROM entries don't all fit in the predefined * in the event that Config ROM entries don't all fit in the predefined
* 1K region. The void *private parameter is private member of struct * 1K region. The void *private parameter is private member of struct
* csr1212_csr. */ * csr1212_csr. */
u_int64_t (*allocate_addr_range) (u_int64_t size, u_int32_t alignment, u64 (*allocate_addr_range) (u64 size, u32 alignment, void *private);
void *private);
/* This function is used by csr1212 to release a region in units space /* This function is used by csr1212 to release a region in units space
* that is no longer needed. */ * that is no longer needed. */
void (*release_addr) (u_int64_t addr, void *private); void (*release_addr) (u64 addr, void *private);
/* This function is used by csr1212 to determine the max read request /* This function is used by csr1212 to determine the max read request
* supported by a remote node when reading the ConfigROM space. Must * supported by a remote node when reading the ConfigROM space. Must
* return 0, 1, or 2 per IEEE 1212. */ * return 0, 1, or 2 per IEEE 1212. */
int (*get_max_rom) (u_int32_t *bus_info, void *private); int (*get_max_rom) (u32 *bus_info, void *private);
}; };
/* Descriptor Leaf manipulation macros */ /* Descriptor Leaf manipulation macros */
#define CSR1212_DESCRIPTOR_LEAF_TYPE_SHIFT 24 #define CSR1212_DESCRIPTOR_LEAF_TYPE_SHIFT 24
#define CSR1212_DESCRIPTOR_LEAF_SPECIFIER_ID_MASK 0xffffff #define CSR1212_DESCRIPTOR_LEAF_SPECIFIER_ID_MASK 0xffffff
#define CSR1212_DESCRIPTOR_LEAF_OVERHEAD (1 * sizeof(u_int32_t)) #define CSR1212_DESCRIPTOR_LEAF_OVERHEAD (1 * sizeof(u32))
#define CSR1212_DESCRIPTOR_LEAF_TYPE(kv) \ #define CSR1212_DESCRIPTOR_LEAF_TYPE(kv) \
(be32_to_cpu((kv)->value.leaf.data[0]) >> CSR1212_DESCRIPTOR_LEAF_TYPE_SHIFT) (be32_to_cpu((kv)->value.leaf.data[0]) >> CSR1212_DESCRIPTOR_LEAF_TYPE_SHIFT)
...@@ -240,7 +236,7 @@ struct csr1212_bus_ops { ...@@ -240,7 +236,7 @@ struct csr1212_bus_ops {
#define CSR1212_TEXTUAL_DESCRIPTOR_LEAF_CHAR_SET_SHIFT 16 #define CSR1212_TEXTUAL_DESCRIPTOR_LEAF_CHAR_SET_SHIFT 16
#define CSR1212_TEXTUAL_DESCRIPTOR_LEAF_CHAR_SET_MASK 0xfff /* after shift */ #define CSR1212_TEXTUAL_DESCRIPTOR_LEAF_CHAR_SET_MASK 0xfff /* after shift */
#define CSR1212_TEXTUAL_DESCRIPTOR_LEAF_LANGUAGE_MASK 0xffff #define CSR1212_TEXTUAL_DESCRIPTOR_LEAF_LANGUAGE_MASK 0xffff
#define CSR1212_TEXTUAL_DESCRIPTOR_LEAF_OVERHEAD (1 * sizeof(u_int32_t)) #define CSR1212_TEXTUAL_DESCRIPTOR_LEAF_OVERHEAD (1 * sizeof(u32))
#define CSR1212_TEXTUAL_DESCRIPTOR_LEAF_WIDTH(kv) \ #define CSR1212_TEXTUAL_DESCRIPTOR_LEAF_WIDTH(kv) \
(be32_to_cpu((kv)->value.leaf.data[1]) >> \ (be32_to_cpu((kv)->value.leaf.data[1]) >> \
...@@ -264,7 +260,7 @@ extern struct csr1212_csr *csr1212_create_csr(struct csr1212_bus_ops *ops, ...@@ -264,7 +260,7 @@ extern struct csr1212_csr *csr1212_create_csr(struct csr1212_bus_ops *ops,
size_t bus_info_size, size_t bus_info_size,
void *private); void *private);
extern void csr1212_init_local_csr(struct csr1212_csr *csr, extern void csr1212_init_local_csr(struct csr1212_csr *csr,
const u_int32_t *bus_info_data, int max_rom); const u32 *bus_info_data, int max_rom);
/* Destroy a Configuration ROM tree and release all memory taken by the tree. */ /* Destroy a Configuration ROM tree and release all memory taken by the tree. */
...@@ -275,8 +271,8 @@ extern void csr1212_destroy_csr(struct csr1212_csr *csr); ...@@ -275,8 +271,8 @@ extern void csr1212_destroy_csr(struct csr1212_csr *csr);
* a Configuration ROM tree. Code that creates new keyvals with these functions * a Configuration ROM tree. Code that creates new keyvals with these functions
* must release those keyvals with csr1212_release_keyval() when they are no * must release those keyvals with csr1212_release_keyval() when they are no
* longer needed. */ * longer needed. */
extern struct csr1212_keyval *csr1212_new_immediate(u_int8_t key, u_int32_t value); extern struct csr1212_keyval *csr1212_new_immediate(u8 key, u32 value);
extern struct csr1212_keyval *csr1212_new_directory(u_int8_t key); extern struct csr1212_keyval *csr1212_new_directory(u8 key);
extern struct csr1212_keyval *csr1212_new_string_descriptor_leaf(const char *s); extern struct csr1212_keyval *csr1212_new_string_descriptor_leaf(const char *s);
...@@ -306,8 +302,8 @@ extern int csr1212_generate_csr_image(struct csr1212_csr *csr); ...@@ -306,8 +302,8 @@ extern int csr1212_generate_csr_image(struct csr1212_csr *csr);
/* This is a convience function for reading a block of data out of one of the /* This is a convience function for reading a block of data out of one of the
* caches in the csr->cache_head list. */ * caches in the csr->cache_head list. */
extern int csr1212_read(struct csr1212_csr *csr, u_int32_t offset, void *buffer, extern int csr1212_read(struct csr1212_csr *csr, u32 offset, void *buffer,
u_int32_t len); u32 len);
/* The following functions are in place for parsing Configuration ROM images. /* The following functions are in place for parsing Configuration ROM images.
...@@ -324,7 +320,7 @@ extern void _csr1212_destroy_keyval(struct csr1212_keyval *kv); ...@@ -324,7 +320,7 @@ extern void _csr1212_destroy_keyval(struct csr1212_keyval *kv);
/* This function allocates a new cache which may be used for either parsing or /* This function allocates a new cache which may be used for either parsing or
* generating sub-sets of Configuration ROM images. */ * generating sub-sets of Configuration ROM images. */
static inline struct csr1212_csr_rom_cache *csr1212_rom_cache_malloc(u_int32_t offset, static inline struct csr1212_csr_rom_cache *csr1212_rom_cache_malloc(u32 offset,
size_t size) size_t size)
{ {
struct csr1212_csr_rom_cache *cache; struct csr1212_csr_rom_cache *cache;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment