14fe996c2SAndrew Jeffery // SPDX-License-Identifier: Apache-2.0
24fe996c2SAndrew Jeffery // Copyright (C) 2018 IBM Corp.
35f374bceSAndrew Jeffery
45f374bceSAndrew Jeffery #include <assert.h>
55f374bceSAndrew Jeffery
626558dbbSAndrew Jeffery #include "mboxd.h"
7457a6e5fSAndrew Jeffery #include "transport_mbox.h"
85f374bceSAndrew Jeffery
95f374bceSAndrew Jeffery #include "test/mbox.h"
105f374bceSAndrew Jeffery #include "test/system.h"
115f374bceSAndrew Jeffery
125f374bceSAndrew Jeffery static const uint8_t get_info[] = {
135f374bceSAndrew Jeffery 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
145f374bceSAndrew Jeffery 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
155f374bceSAndrew Jeffery };
165f374bceSAndrew Jeffery
175f374bceSAndrew Jeffery static const uint8_t create_read_window[] = {
185f374bceSAndrew Jeffery 0x04, 0x01, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
195f374bceSAndrew Jeffery 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
205f374bceSAndrew Jeffery };
215f374bceSAndrew Jeffery
225f374bceSAndrew Jeffery static const uint8_t response[] = {
235f374bceSAndrew Jeffery 0x04, 0x01, 0xfd, 0xff, 0x03, 0x00, 0x00, 0x00,
245f374bceSAndrew Jeffery 0x00, 0x00, 0x00, 0x00, 0x00, 0x01
255f374bceSAndrew Jeffery };
265f374bceSAndrew Jeffery
275f374bceSAndrew Jeffery uint8_t data[3] = { 0xaa, 0x55, 0xaa };
285f374bceSAndrew Jeffery
295f374bceSAndrew Jeffery #define MEM_SIZE sizeof(data)
305f374bceSAndrew Jeffery #define ERASE_SIZE 1
315f374bceSAndrew Jeffery #define N_WINDOWS 1
325f374bceSAndrew Jeffery #define WINDOW_SIZE sizeof(data)
335f374bceSAndrew Jeffery
main(void)345f374bceSAndrew Jeffery int main(void)
355f374bceSAndrew Jeffery {
365f374bceSAndrew Jeffery struct mbox_context *ctx;
375f374bceSAndrew Jeffery int rc;
385f374bceSAndrew Jeffery
395f374bceSAndrew Jeffery system_set_reserved_size(MEM_SIZE);
405f374bceSAndrew Jeffery system_set_mtd_sizes(MEM_SIZE, ERASE_SIZE);
415f374bceSAndrew Jeffery
425f374bceSAndrew Jeffery ctx = mbox_create_test_context(N_WINDOWS, WINDOW_SIZE);
435f374bceSAndrew Jeffery rc = mbox_set_mtd_data(ctx, data, sizeof(data));
445f374bceSAndrew Jeffery assert(rc == 0);
455f374bceSAndrew Jeffery
465f374bceSAndrew Jeffery rc = mbox_command_dispatch(ctx, get_info, sizeof(get_info));
475f374bceSAndrew Jeffery assert(rc == 1);
485f374bceSAndrew Jeffery
495f374bceSAndrew Jeffery rc = mbox_command_dispatch(ctx, create_read_window,
505f374bceSAndrew Jeffery sizeof(create_read_window));
515f374bceSAndrew Jeffery assert(rc == 1);
525f374bceSAndrew Jeffery
535f374bceSAndrew Jeffery rc = mbox_cmp(ctx, response, sizeof(response));
545f374bceSAndrew Jeffery assert(rc == 0);
555f374bceSAndrew Jeffery
565f374bceSAndrew Jeffery return rc;
57*68a24c9eSPatrick Williams }
58