summaryrefslogtreecommitdiff
path: root/lib/trusty/ql-tipc/sysdeps/sysdeps_uboot.c
blob: f0d6c69abde463f36d3899483fdcfc89939b9c3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation
 * files (the "Software"), to deal in the Software without
 * restriction, including without limitation the rights to use, copy,
 * modify, merge, publish, distribute, sublicense, and/or sell copies
 * of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

#include <trusty/sysdeps.h>

#include <common.h>
#include <linux/string.h>
#include <malloc.h>

extern int trusty_encode_page_info(struct ns_mem_page_info *page_info,
                                   void *vaddr);

void trusty_lock(struct trusty_dev *dev)
{
}
void trusty_unlock(struct trusty_dev *dev)
{
}

void trusty_local_irq_disable(unsigned long *state)
{
    disable_interrupts();
}

void trusty_local_irq_restore(unsigned long *state)
{
    enable_interrupts();
}

void trusty_idle(struct trusty_dev *dev)
{
    wfi();
}

void trusty_abort(void)
{
    do_reset(NULL, 0, 0, NULL);
    __builtin_unreachable();
}

void trusty_printf(const char *format, ...)
{
    va_list ap;

    va_start(ap, format);
    vprintf(format, ap);
    va_end(ap);
}

void *trusty_memcpy(void *dest, const void *src, size_t n)
{
    return memcpy(dest, src, n);
}

void *trusty_memset(void *dest, const int c, size_t n)
{
    return memset(dest, c, n);
}

char *trusty_strcpy(char *dest, const char *src)
{
    return strcpy(dest, src);
}

size_t trusty_strlen(const char *str)
{
    return strlen(str);
}

void *trusty_calloc(size_t n, size_t size)
{
    return calloc(n, size);
}

void trusty_free(void *addr)
{
    if (addr)
        free(addr);
}

void *trusty_alloc_pages(struct ns_mem_page_info *page_info, unsigned count)
{
    void *va = NULL;
    int res;

    va = memalign(PAGE_SIZE, count * PAGE_SIZE);
    if (!va)
        return NULL;

    /* get memory attibutes */
    res = trusty_encode_page_info(page_info, va);
    if (res) {
        trusty_free_pages(va, count);
        return NULL;
    }
    return va;
}

void trusty_free_pages(void *va, unsigned count)
{
    if (va)
        free(va);
}