Subversion Repositories HelenOS

Rev

Rev 4274 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4274 Rev 4490
Line 97... Line 97...
97
 
97
 
98
/**
98
/**
99
 * Hash table operations for cases when we know that
99
 * Hash table operations for cases when we know that
100
 * there will be collisions between different keys.
100
 * there will be collisions between different keys.
101
 */
101
 */
102
static index_t irq_ht_hash(unative_t *key);
102
static size_t irq_ht_hash(unative_t *key);
103
static bool irq_ht_compare(unative_t *key, count_t keys, link_t *item);
103
static bool irq_ht_compare(unative_t *key, size_t keys, link_t *item);
104
static void irq_ht_remove(link_t *item);
104
static void irq_ht_remove(link_t *item);
105
 
105
 
106
static hash_table_operations_t irq_ht_ops = {
106
static hash_table_operations_t irq_ht_ops = {
107
    .hash = irq_ht_hash,
107
    .hash = irq_ht_hash,
108
    .compare = irq_ht_compare,
108
    .compare = irq_ht_compare,
Line 113... Line 113...
113
 * Hash table operations for cases when we know that
113
 * Hash table operations for cases when we know that
114
 * there will be no collisions between different keys.
114
 * there will be no collisions between different keys.
115
 * However, there might be still collisions among
115
 * However, there might be still collisions among
116
 * elements with single key (sharing of one IRQ).
116
 * elements with single key (sharing of one IRQ).
117
 */
117
 */
118
static index_t irq_lin_hash(unative_t *key);
118
static size_t irq_lin_hash(unative_t *key);
119
static bool irq_lin_compare(unative_t *key, count_t keys, link_t *item);
119
static bool irq_lin_compare(unative_t *key, size_t keys, link_t *item);
120
static void irq_lin_remove(link_t *item);
120
static void irq_lin_remove(link_t *item);
121
 
121
 
122
static hash_table_operations_t irq_lin_ops = {
122
static hash_table_operations_t irq_lin_ops = {
123
    .hash = irq_lin_hash,
123
    .hash = irq_lin_hash,
124
    .compare = irq_lin_compare,
124
    .compare = irq_lin_compare,
125
    .remove_callback = irq_lin_remove,
125
    .remove_callback = irq_lin_remove,
126
};
126
};
127
 
127
 
128
/** Number of buckets in either of the hash tables. */
128
/** Number of buckets in either of the hash tables. */
129
static count_t buckets;
129
static size_t buckets;
130
 
130
 
131
/** Initialize IRQ subsystem.
131
/** Initialize IRQ subsystem.
132
 *
132
 *
133
 * @param inrs Numbers of unique IRQ numbers or INRs.
133
 * @param inrs Numbers of unique IRQ numbers or INRs.
134
 * @param chains Number of chains in the hash table.
134
 * @param chains Number of chains in the hash table.
135
 */
135
 */
136
void irq_init(count_t inrs, count_t chains)
136
void irq_init(size_t inrs, size_t chains)
137
{
137
{
138
    buckets = chains;
138
    buckets = chains;
139
    /*
139
    /*
140
     * Be smart about the choice of the hash table operations.
140
     * Be smart about the choice of the hash table operations.
141
     * In cases in which inrs equals the requested number of
141
     * In cases in which inrs equals the requested number of
Line 296... Line 296...
296
 *
296
 *
297
 * @param key The first of the keys is inr and the second is devno or -1.
297
 * @param key The first of the keys is inr and the second is devno or -1.
298
 *
298
 *
299
 * @return Index into the hash table.
299
 * @return Index into the hash table.
300
 */
300
 */
301
index_t irq_ht_hash(unative_t key[])
301
size_t irq_ht_hash(unative_t key[])
302
{
302
{
303
    inr_t inr = (inr_t) key[KEY_INR];
303
    inr_t inr = (inr_t) key[KEY_INR];
304
    return inr % buckets;
304
    return inr % buckets;
305
}
305
}
306
 
306
 
Line 322... Line 322...
322
 * @param keys This is 2.
322
 * @param keys This is 2.
323
 * @param item The item to compare the key with.
323
 * @param item The item to compare the key with.
324
 *
324
 *
325
 * @return True on match or false otherwise.
325
 * @return True on match or false otherwise.
326
 */
326
 */
327
bool irq_ht_compare(unative_t key[], count_t keys, link_t *item)
327
bool irq_ht_compare(unative_t key[], size_t keys, link_t *item)
328
{
328
{
329
    irq_t *irq = hash_table_get_instance(item, irq_t, link);
329
    irq_t *irq = hash_table_get_instance(item, irq_t, link);
330
    inr_t inr = (inr_t) key[KEY_INR];
330
    inr_t inr = (inr_t) key[KEY_INR];
331
    devno_t devno = (devno_t) key[KEY_DEVNO];
331
    devno_t devno = (devno_t) key[KEY_DEVNO];
332
 
332
 
Line 369... Line 369...
369
 *
369
 *
370
 * @param key The first of the keys is inr and the second is devno or -1.
370
 * @param key The first of the keys is inr and the second is devno or -1.
371
 *
371
 *
372
 * @return Index into the hash table.
372
 * @return Index into the hash table.
373
 */
373
 */
374
index_t irq_lin_hash(unative_t key[])
374
size_t irq_lin_hash(unative_t key[])
375
{
375
{
376
    inr_t inr = (inr_t) key[KEY_INR];
376
    inr_t inr = (inr_t) key[KEY_INR];
377
    return inr;
377
    return inr;
378
}
378
}
379
 
379
 
Line 395... Line 395...
395
 * @param keys This is 2.
395
 * @param keys This is 2.
396
 * @param item The item to compare the key with.
396
 * @param item The item to compare the key with.
397
 *
397
 *
398
 * @return True on match or false otherwise.
398
 * @return True on match or false otherwise.
399
 */
399
 */
400
bool irq_lin_compare(unative_t key[], count_t keys, link_t *item)
400
bool irq_lin_compare(unative_t key[], size_t keys, link_t *item)
401
{
401
{
402
    irq_t *irq = list_get_instance(item, irq_t, link);
402
    irq_t *irq = list_get_instance(item, irq_t, link);
403
    devno_t devno = (devno_t) key[KEY_DEVNO];
403
    devno_t devno = (devno_t) key[KEY_DEVNO];
404
    bool rv;
404
    bool rv;
405
   
405