|
| 1 | +/* |
| 2 | + * Copyright (c) 2016, ARM Limited, All Rights Reserved |
| 3 | + * SPDX-License-Identifier: Apache-2.0 |
| 4 | + * |
| 5 | + * Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 6 | + * not use this file except in compliance with the License. |
| 7 | + * You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 13 | + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License. |
| 16 | + */ |
| 17 | +#ifndef __UVISOR_API_H__ |
| 18 | +#define __UVISOR_API_H__ |
| 19 | + |
| 20 | +#include "rt_OsEventObserver.h" |
| 21 | +#include "api/inc/uvisor_exports.h" |
| 22 | +#include "api/inc/unvic_exports.h" |
| 23 | +#include "api/inc/debug_exports.h" |
| 24 | +#include "api/inc/halt_exports.h" |
| 25 | +#include "api/inc/pool_queue_exports.h" |
| 26 | +#include "api/inc/page_allocator_exports.h" |
| 27 | +#include <stdint.h> |
| 28 | + |
| 29 | +#define UVISOR_API_MAGIC 0x5C9411B4 |
| 30 | +#define UVISOR_API_VERSION (10) |
| 31 | + |
| 32 | +UVISOR_EXTERN_C_BEGIN |
| 33 | + |
| 34 | +extern void uvisor_init(void); |
| 35 | + |
| 36 | +typedef struct { |
| 37 | + uint32_t magic; |
| 38 | + uint32_t (*get_version)(uint32_t); |
| 39 | + |
| 40 | + void (*init)(void); |
| 41 | + |
| 42 | + void (*irq_enable)(uint32_t irqn); |
| 43 | + void (*irq_disable)(uint32_t irqn); |
| 44 | + void (*irq_disable_all)(void); |
| 45 | + void (*irq_enable_all)(void); |
| 46 | + void (*irq_set_vector)(uint32_t irqn, uint32_t vector); |
| 47 | + uint32_t (*irq_get_vector)(uint32_t irqn); |
| 48 | + void (*irq_set_priority)(uint32_t irqn, uint32_t priority); |
| 49 | + uint32_t (*irq_get_priority)(uint32_t irqn); |
| 50 | + void (*irq_set_pending)(uint32_t irqn); |
| 51 | + uint32_t (*irq_get_pending)(uint32_t irqn); |
| 52 | + void (*irq_clear_pending)(uint32_t irqn); |
| 53 | + int (*irq_get_level)(void); |
| 54 | + void (*irq_system_reset)(TResetReason reason); |
| 55 | + |
| 56 | + int (*page_malloc)(UvisorPageTable * const table); |
| 57 | + int (*page_free)(const UvisorPageTable * const table); |
| 58 | + |
| 59 | + int (*box_namespace)(int box_id, char *box_namespace, size_t length); |
| 60 | + |
| 61 | + void (*debug_init)(const TUvisorDebugDriver * const driver); |
| 62 | + void (*error)(THaltUserError reason); |
| 63 | + void (*vmpu_mem_invalidate)(void); |
| 64 | + |
| 65 | + int (*pool_init)(uvisor_pool_t *, void *, size_t, size_t, int); |
| 66 | + int (*pool_queue_init)(uvisor_pool_queue_t *, uvisor_pool_t *, void *, size_t, size_t, int); |
| 67 | + uvisor_pool_slot_t (*pool_allocate)(uvisor_pool_t *, uint32_t); |
| 68 | + void (*pool_queue_enqueue)(uvisor_pool_queue_t *, uvisor_pool_slot_t); |
| 69 | + uvisor_pool_slot_t (*pool_free)(uvisor_pool_t *, uvisor_pool_slot_t); |
| 70 | + uvisor_pool_slot_t (*pool_queue_dequeue)(uvisor_pool_queue_t *, uvisor_pool_slot_t); |
| 71 | + uvisor_pool_slot_t (*pool_queue_dequeue_first)(uvisor_pool_queue_t *); |
| 72 | + uvisor_pool_slot_t (*pool_queue_find_first)(uvisor_pool_queue_t *, TQueryFN_Ptr, void *); |
| 73 | + |
| 74 | + OsEventObserver os_event_observer; |
| 75 | +} UVISOR_PACKED UvisorApi; |
| 76 | + |
| 77 | +extern UvisorApi uvisor_api; |
| 78 | + |
| 79 | +static UVISOR_FORCEINLINE uint32_t uvisor_get_version(void) |
| 80 | +{ |
| 81 | + return uvisor_api.get_version(UVISOR_API_VERSION); |
| 82 | +} |
| 83 | + |
| 84 | +UVISOR_EXTERN_C_END |
| 85 | + |
| 86 | +#endif /* __UVISOR_API_H__ */ |
0 commit comments