[8b6aa39] | 1 | /*
|
---|
| 2 | * Copyright (c) 2016 Martin Decky
|
---|
| 3 | * All rights reserved.
|
---|
| 4 | *
|
---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
---|
| 6 | * modification, are permitted provided that the following conditions
|
---|
| 7 | * are met:
|
---|
| 8 | *
|
---|
| 9 | * - Redistributions of source code must retain the above copyright
|
---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
---|
| 11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 13 | * documentation and/or other materials provided with the distribution.
|
---|
| 14 | * - The name of the author may not be used to endorse or promote products
|
---|
| 15 | * derived from this software without specific prior written permission.
|
---|
| 16 | *
|
---|
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 27 | */
|
---|
| 28 |
|
---|
[c5429fe] | 29 | /** @addtogroup kernel_riscv64
|
---|
[8b6aa39] | 30 | * @{
|
---|
| 31 | */
|
---|
| 32 | /** @file
|
---|
| 33 | */
|
---|
| 34 |
|
---|
| 35 | #include <arch.h>
|
---|
[83dab11] | 36 | #include <stddef.h>
|
---|
[6c742f5e] | 37 | #include <arch/arch.h>
|
---|
[8b6aa39] | 38 | #include <arch/interrupt.h>
|
---|
| 39 | #include <arch/asm.h>
|
---|
[6c742f5e] | 40 | #include <arch/drivers/ucb.h>
|
---|
[8b6aa39] | 41 |
|
---|
[b2e121a] | 42 | #include <halt.h>
|
---|
[8b6aa39] | 43 | #include <config.h>
|
---|
| 44 | #include <errno.h>
|
---|
| 45 | #include <context.h>
|
---|
| 46 | #include <fpu_context.h>
|
---|
| 47 | #include <interrupt.h>
|
---|
| 48 | #include <syscall/copy.h>
|
---|
| 49 | #include <ddi/irq.h>
|
---|
| 50 | #include <proc/thread.h>
|
---|
| 51 | #include <console/console.h>
|
---|
[b169619] | 52 | #include <memw.h>
|
---|
[ccc362a1] | 53 | #include <str.h>
|
---|
[8b6aa39] | 54 |
|
---|
| 55 | char memcpy_from_uspace_failover_address;
|
---|
| 56 | char memcpy_to_uspace_failover_address;
|
---|
| 57 |
|
---|
[ccc362a1] | 58 | static void riscv64_post_mm_init(void);
|
---|
| 59 |
|
---|
[8b6aa39] | 60 | arch_ops_t riscv64_ops = {
|
---|
[ccc362a1] | 61 | .post_mm_init = riscv64_post_mm_init
|
---|
[8b6aa39] | 62 | };
|
---|
| 63 |
|
---|
| 64 | arch_ops_t *arch_ops = &riscv64_ops;
|
---|
| 65 |
|
---|
[ccc362a1] | 66 | void riscv64_pre_main(bootinfo_t *bootinfo)
|
---|
| 67 | {
|
---|
| 68 | physmem_start = bootinfo->physmem_start;
|
---|
| 69 | htif_frame = bootinfo->htif_frame;
|
---|
| 70 | pt_frame = bootinfo->pt_frame;
|
---|
[a35b458] | 71 |
|
---|
[ccc362a1] | 72 | htif_init(bootinfo->ucbinfo.tohost, bootinfo->ucbinfo.fromhost);
|
---|
[a35b458] | 73 |
|
---|
[ccc362a1] | 74 | /* Copy tasks map. */
|
---|
| 75 | init.cnt = min3(bootinfo->taskmap.cnt, TASKMAP_MAX_RECORDS,
|
---|
| 76 | CONFIG_INIT_TASKS);
|
---|
[a35b458] | 77 |
|
---|
[ccc362a1] | 78 | for (size_t i = 0; i < init.cnt; i++) {
|
---|
| 79 | init.tasks[i].paddr = KA2PA(bootinfo->taskmap.tasks[i].addr);
|
---|
| 80 | init.tasks[i].size = bootinfo->taskmap.tasks[i].size;
|
---|
| 81 | str_cpy(init.tasks[i].name, CONFIG_TASK_NAME_BUFLEN,
|
---|
| 82 | bootinfo->taskmap.tasks[i].name);
|
---|
| 83 | }
|
---|
[a35b458] | 84 |
|
---|
[ccc362a1] | 85 | /* Copy physical memory map. */
|
---|
| 86 | memmap.total = bootinfo->memmap.total;
|
---|
| 87 | memmap.cnt = min(bootinfo->memmap.cnt, MEMMAP_MAX_RECORDS);
|
---|
| 88 | for (size_t i = 0; i < memmap.cnt; i++) {
|
---|
| 89 | memmap.zones[i].start = bootinfo->memmap.zones[i].start;
|
---|
| 90 | memmap.zones[i].size = bootinfo->memmap.zones[i].size;
|
---|
| 91 | }
|
---|
| 92 | }
|
---|
| 93 |
|
---|
| 94 | void riscv64_post_mm_init(void)
|
---|
| 95 | {
|
---|
| 96 | outdev_t *htifout = htifout_init();
|
---|
| 97 | if (htifout)
|
---|
| 98 | stdout_wire(htifout);
|
---|
| 99 | }
|
---|
| 100 |
|
---|
[8b6aa39] | 101 | void calibrate_delay_loop(void)
|
---|
| 102 | {
|
---|
| 103 | }
|
---|
| 104 |
|
---|
| 105 | /** Construct function pointer
|
---|
| 106 | *
|
---|
| 107 | * @param fptr function pointer structure
|
---|
| 108 | * @param addr function address
|
---|
| 109 | * @param caller calling function address
|
---|
| 110 | *
|
---|
| 111 | * @return address of the function pointer
|
---|
| 112 | *
|
---|
| 113 | */
|
---|
| 114 | void *arch_construct_function(fncptr_t *fptr, void *addr, void *caller)
|
---|
| 115 | {
|
---|
| 116 | return addr;
|
---|
| 117 | }
|
---|
| 118 |
|
---|
| 119 | void arch_reboot(void)
|
---|
| 120 | {
|
---|
| 121 | }
|
---|
| 122 |
|
---|
| 123 | void irq_initialize_arch(irq_t *irq)
|
---|
| 124 | {
|
---|
| 125 | (void) irq;
|
---|
| 126 | }
|
---|
| 127 |
|
---|
| 128 | void istate_decode(istate_t *istate)
|
---|
| 129 | {
|
---|
| 130 | (void) istate;
|
---|
| 131 | }
|
---|
| 132 |
|
---|
| 133 | void fpu_init(void)
|
---|
| 134 | {
|
---|
| 135 | }
|
---|
| 136 |
|
---|
| 137 | void fpu_context_save(fpu_context_t *ctx)
|
---|
| 138 | {
|
---|
| 139 | }
|
---|
| 140 |
|
---|
| 141 | void fpu_context_restore(fpu_context_t *ctx)
|
---|
| 142 | {
|
---|
| 143 | }
|
---|
| 144 |
|
---|
[5a5269d] | 145 | uintptr_t memcpy_from_uspace(void *dst, uspace_addr_t uspace_src, size_t size)
|
---|
[8b6aa39] | 146 | {
|
---|
[fac0ac7] | 147 | return 0;
|
---|
[8b6aa39] | 148 | }
|
---|
| 149 |
|
---|
[5a5269d] | 150 | uintptr_t memcpy_to_uspace(uspace_addr_t uspace_dst, const void *src, size_t size)
|
---|
[8b6aa39] | 151 | {
|
---|
[fac0ac7] | 152 | return 0;
|
---|
[8b6aa39] | 153 | }
|
---|
| 154 |
|
---|
| 155 | /** @}
|
---|
| 156 | */
|
---|