* This function is used by repack to count the number of BPDT and S-BPDT * entries that are present. It frees the current buffers used by the entries * and allocates fresh buffers that can be used for repacking. Returns BPDT * entries which are empty and need to be filled in. */
| 923 | * entries which are empty and need to be filled in. |
| 924 | */ |
| 925 | static void __bpdt_reset(struct buffer *b, size_t count, size_t size) |
| 926 | { |
| 927 | size_t bpdt_size = BPDT_HEADER_SIZE + count * BPDT_ENTRY_SIZE; |
| 928 | assert(size >= bpdt_size); |
| 929 | |
| 930 | /* |
| 931 | * If buffer does not have the required size, allocate a fresh buffer. |
| 932 | */ |
| 933 | if (buffer_size(b) != size) { |
| 934 | struct buffer temp; |
| 935 | alloc_buffer(&temp, size, b->name); |
| 936 | memcpy(buffer_get(&temp), buffer_get(b), buffer_size(b)); |
| 937 | buffer_delete(b); |
| 938 | *b = temp; |
| 939 | } |
| 940 | |
| 941 | struct bpdt *bpdt = buffer_get(b); |
| 942 | uint8_t *ptr = (uint8_t *)&bpdt->e[0]; |
| 943 | size_t entries_size = BPDT_ENTRY_SIZE * count; |
| 944 | |
| 945 | /* Zero out BPDT entries. */ |
| 946 | memset(ptr, 0, entries_size); |
| 947 | /* Fill any pad-space with FF. */ |
| 948 | memset(ptr + entries_size, 0xFF, size - bpdt_size); |
| 949 | |
| 950 | bpdt->h.descriptor_count = count; |
| 951 | } |
| 952 | |
| 953 | static void bpdt_reset(void) |
| 954 | { |
no test coverage detected