38 lines
1.7 KiB
C
38 lines
1.7 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
#include <assert.h>
|
|
#include <string.h>
|
|
#include "../project/cellular/ipa-v2/ipa_v2_cmd_format.h"
|
|
|
|
int main(void)
|
|
{
|
|
struct ipa_v2_shared_mem_cmd command;
|
|
struct ipa_v2_bam_desc descriptor;
|
|
const unsigned char command_bytes[] = {
|
|
0x00, 0x00, 0x40, 0x00, 0x40, 0x30, 0x20, 0x10,
|
|
0x80, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
};
|
|
const unsigned char descriptor_bytes[] = {
|
|
0xa0, 0x90, 0x80, 0x70, 0x13, 0x00, 0x00, 0x41,
|
|
};
|
|
|
|
assert(sizeof(command) == 16);
|
|
assert(sizeof(descriptor) == 8);
|
|
assert(!ipa_v2_shared_read_encode(&command, 0x10203040, 64, 0x80, 8192, 0));
|
|
assert(!memcmp(&command, command_bytes, sizeof(command_bytes)));
|
|
assert(!ipa_v2_shared_read_desc(&descriptor, 0x708090a0, sizeof(command)));
|
|
assert(!memcmp(&descriptor, descriptor_bytes, sizeof(descriptor_bytes)));
|
|
assert(ipa_v2_shared_read_desc(&descriptor, 0x708090a0, 19) == -ERANGE);
|
|
assert(ipa_v2_shared_read_desc(&descriptor, 0xfffffff8ULL, 16) == -ERANGE);
|
|
assert(ipa_v2_shared_read_encode(&command, 0x100000000ULL, 16, 0, 8192, 0) == -ERANGE);
|
|
assert(ipa_v2_shared_read_encode(&command, 0xfffffffcULL, 16, 0, 8192, 0) == -ERANGE);
|
|
assert(ipa_v2_shared_read_encode(&command, 0x1000, 0, 0, 8192, 0) == -ERANGE);
|
|
assert(ipa_v2_shared_read_encode(&command, 0x1000, 16, 8180, 8192, 0) == -ERANGE);
|
|
assert(ipa_v2_shared_read_encode(&command, 0x1000, 16, 0, 8192, 128) == -ERANGE);
|
|
assert(ipa_v2_shared_read_encode(&command, 0x1000, 16, 0x10000, 0x20000, 0) == -ERANGE);
|
|
assert(!ipa_v2_shared_read_encode(&command, 0xfffffff0ULL, 16, 8176, 8192, 0));
|
|
assert(ipa_v2_dma_range_valid(0xffffffffULL, 1));
|
|
assert(!ipa_v2_dma_range_valid(0xffffffffULL, 2));
|
|
assert(!ipa_v2_dma_range_valid(0, 0));
|
|
return 0;
|
|
}
|