77 static u32 sci_remote_node_table_get_group_index(
79 u32 group_table_index)
87 for (dword_index = 0; dword_index < remote_node_table->
group_array_size; dword_index++) {
88 if (group_table[dword_index] != 0) {
89 for (bit_index = 0; bit_index < 32; bit_index++) {
90 if ((group_table[dword_index] & (1 << bit_index)) != 0) {
91 return (dword_index * 32) + bit_index;
111 static void sci_remote_node_table_clear_group_index(
113 u32 group_table_index,
123 dword_index = group_index / 32;
124 bit_index = group_index % 32;
127 group_table[dword_index] = group_table[dword_index] & ~(1 << bit_index);
141 static void sci_remote_node_table_set_group_index(
143 u32 group_table_index,
153 dword_index = group_index / 32;
154 bit_index = group_index % 32;
157 group_table[dword_index] = group_table[dword_index] | (1 << bit_index);
170 static void sci_remote_node_table_set_node_index(
172 u32 remote_node_index)
190 1 << (slot_normalized + slot_position);
203 static void sci_remote_node_table_clear_node_index(
205 u32 remote_node_index)
223 ~(1 << (slot_normalized + slot_position));
234 static void sci_remote_node_table_clear_group(
261 static void sci_remote_node_table_set_group(
291 static u8 sci_remote_node_table_get_group_value(
304 dword_value = dword_value >> (dword_remainder * 4);
306 return (
u8)dword_value;
318 u32 remote_node_entries)
344 for (index = 0; index < remote_node_entries; index++) {
345 sci_remote_node_table_set_node_index(remote_node_table, index);
356 sci_remote_node_table_set_group_index(remote_node_table, 2, index);
361 sci_remote_node_table_set_group_index(remote_node_table, 1, index);
362 }
else if ((remote_node_entries % SCU_STP_REMOTE_NODE_COUNT) == 1) {
363 sci_remote_node_table_set_group_index(remote_node_table, 0, index);
382 static u16 sci_remote_node_table_allocate_single_remote_node(
384 u32 group_table_index)
391 group_index = sci_remote_node_table_get_group_index(
392 remote_node_table, group_table_index);
396 group_value = sci_remote_node_table_get_group_value(
397 remote_node_table, group_index);
400 if (((1 << index) & group_value) != 0) {
402 remote_node_index = (
u16)(group_index * SCU_STP_REMOTE_NODE_COUNT
405 sci_remote_node_table_clear_group_index(
406 remote_node_table, group_table_index, group_index
409 sci_remote_node_table_clear_node_index(
410 remote_node_table, remote_node_index
413 if (group_table_index > 0) {
414 sci_remote_node_table_set_group_index(
415 remote_node_table, group_table_index - 1, group_index
424 return remote_node_index;
439 static u16 sci_remote_node_table_allocate_triple_remote_node(
441 u32 group_table_index)
446 group_index = sci_remote_node_table_get_group_index(
447 remote_node_table, group_table_index);
450 remote_node_index = (
u16)group_index * SCU_STP_REMOTE_NODE_COUNT;
452 sci_remote_node_table_clear_group_index(
453 remote_node_table, group_table_index, group_index
456 sci_remote_node_table_clear_group(
457 remote_node_table, group_index
461 return remote_node_index;
478 u32 remote_node_count)
484 sci_remote_node_table_allocate_single_remote_node(
485 remote_node_table, 0);
489 sci_remote_node_table_allocate_single_remote_node(
490 remote_node_table, 1);
495 sci_remote_node_table_allocate_single_remote_node(
496 remote_node_table, 2);
498 }
else if (remote_node_count == SCU_STP_REMOTE_NODE_COUNT) {
500 sci_remote_node_table_allocate_triple_remote_node(
501 remote_node_table, 2);
504 return remote_node_index;
514 static void sci_remote_node_table_release_single_remote_node(
516 u16 remote_node_index)
523 group_value = sci_remote_node_table_get_group_value(remote_node_table, group_index);
530 if (group_value == 0x00) {
534 sci_remote_node_table_set_group_index(remote_node_table, 0, group_index);
535 }
else if ((group_value & (group_value - 1)) == 0) {
539 sci_remote_node_table_clear_group_index(remote_node_table, 0, group_index);
540 sci_remote_node_table_set_group_index(remote_node_table, 1, group_index);
545 sci_remote_node_table_clear_group_index(remote_node_table, 1, group_index);
546 sci_remote_node_table_set_group_index(remote_node_table, 2, group_index);
549 sci_remote_node_table_set_node_index(remote_node_table, remote_node_index);
560 static void sci_remote_node_table_release_triple_remote_node(
562 u16 remote_node_index)
568 sci_remote_node_table_set_group_index(
569 remote_node_table, 2, group_index
572 sci_remote_node_table_set_group(remote_node_table, group_index);
587 u32 remote_node_count,
588 u16 remote_node_index)
591 sci_remote_node_table_release_single_remote_node(
592 remote_node_table, remote_node_index);
593 }
else if (remote_node_count == SCU_STP_REMOTE_NODE_COUNT) {
594 sci_remote_node_table_release_triple_remote_node(
595 remote_node_table, remote_node_index);