[d630139] | 1 | /*
|
---|
[6b781c0] | 2 | * Copyright (c) 2007 Michal Kebrt
|
---|
[d630139] | 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_arm32
|
---|
[d630139] | 30 | * @{
|
---|
| 31 | */
|
---|
| 32 | /** @file
|
---|
[6b781c0] | 33 | * @brief ARM32 architecture specific functions.
|
---|
[d630139] | 34 | */
|
---|
| 35 |
|
---|
| 36 | #include <arch.h>
|
---|
[36df4109] | 37 | #include <arch/arch.h>
|
---|
[6b781c0] | 38 | #include <config.h>
|
---|
| 39 | #include <genarch/fb/fb.h>
|
---|
[c0699467] | 40 | #include <abi/fb/visuals.h>
|
---|
[c2417bc] | 41 | #include <console/console.h>
|
---|
[6b781c0] | 42 | #include <ddi/irq.h>
|
---|
| 43 | #include <config.h>
|
---|
| 44 | #include <interrupt.h>
|
---|
| 45 | #include <arch/regutils.h>
|
---|
[8ef40329] | 46 | #include <arch/machine_func.h>
|
---|
[6b781c0] | 47 | #include <userspace.h>
|
---|
[96e0748d] | 48 | #include <macros.h>
|
---|
[19f857a] | 49 | #include <str.h>
|
---|
[82a04c6] | 50 | #include <arch/ras.h>
|
---|
[a19dc957] | 51 | #include <sysinfo/sysinfo.h>
|
---|
[d630139] | 52 |
|
---|
[36df4109] | 53 | static void arm32_pre_mm_init(void);
|
---|
| 54 | static void arm32_post_mm_init(void);
|
---|
| 55 | static void arm32_post_smp_init(void);
|
---|
| 56 |
|
---|
| 57 | arch_ops_t arm32_ops = {
|
---|
| 58 | .pre_mm_init = arm32_pre_mm_init,
|
---|
| 59 | .post_mm_init = arm32_post_mm_init,
|
---|
| 60 | .post_smp_init = arm32_post_smp_init,
|
---|
| 61 | };
|
---|
| 62 |
|
---|
| 63 | arch_ops_t *arch_ops = &arm32_ops;
|
---|
| 64 |
|
---|
[06f96234] | 65 | /** Performs arm32-specific initialization before main_bsp() is called. */
|
---|
[36df4109] | 66 | void arm32_pre_main(void *entry __attribute__((unused)), bootinfo_t *bootinfo)
|
---|
[d630139] | 67 | {
|
---|
[63a045c] | 68 | init.cnt = min3(bootinfo->taskmap.cnt, TASKMAP_MAX_RECORDS, CONFIG_INIT_TASKS);
|
---|
[a35b458] | 69 |
|
---|
[4872160] | 70 | size_t i;
|
---|
| 71 | for (i = 0; i < init.cnt; i++) {
|
---|
[63a045c] | 72 | init.tasks[i].paddr = KA2PA(bootinfo->taskmap.tasks[i].addr);
|
---|
| 73 | init.tasks[i].size = bootinfo->taskmap.tasks[i].size;
|
---|
[f4b1535] | 74 | str_cpy(init.tasks[i].name, CONFIG_TASK_NAME_BUFLEN,
|
---|
[63a045c] | 75 | bootinfo->taskmap.tasks[i].name);
|
---|
[96e0748d] | 76 | }
|
---|
[66fcba2] | 77 |
|
---|
| 78 | /* Initialize machine_ops pointer. */
|
---|
| 79 | machine_ops_init();
|
---|
[d630139] | 80 | }
|
---|
| 81 |
|
---|
[6b781c0] | 82 | /** Performs arm32 specific initialization before mm is initialized. */
|
---|
[36df4109] | 83 | void arm32_pre_mm_init(void)
|
---|
[d630139] | 84 | {
|
---|
[6b781c0] | 85 | /* It is not assumed by default */
|
---|
| 86 | interrupts_disable();
|
---|
[d630139] | 87 | }
|
---|
| 88 |
|
---|
[6b781c0] | 89 | /** Performs arm32 specific initialization afterr mm is initialized. */
|
---|
[36df4109] | 90 | void arm32_post_mm_init(void)
|
---|
[d630139] | 91 | {
|
---|
[6ac14a70] | 92 | machine_init();
|
---|
[a35b458] | 93 |
|
---|
[6b781c0] | 94 | /* Initialize exception dispatch table */
|
---|
| 95 | exception_init();
|
---|
| 96 | interrupt_init();
|
---|
[82a04c6] | 97 |
|
---|
| 98 | /* Initialize Restartable Atomic Sequences support. */
|
---|
| 99 | ras_init();
|
---|
[a35b458] | 100 |
|
---|
[6ac14a70] | 101 | machine_output_init();
|
---|
[d630139] | 102 | }
|
---|
| 103 |
|
---|
[6b781c0] | 104 | /** Performs arm32 specific tasks needed after the multiprocessing is
|
---|
| 105 | * initialized.
|
---|
| 106 | *
|
---|
| 107 | * Currently the function is empty because SMP is not supported.
|
---|
| 108 | */
|
---|
[36df4109] | 109 | void arm32_post_smp_init(void)
|
---|
[d630139] | 110 | {
|
---|
[6ac14a70] | 111 | machine_input_init();
|
---|
[a19dc957] | 112 | const char *platform = machine_get_platform_name();
|
---|
| 113 |
|
---|
| 114 | sysinfo_set_item_data("platform", NULL, (void *) platform,
|
---|
| 115 | str_size(platform));
|
---|
[d630139] | 116 | }
|
---|
| 117 |
|
---|
[6b781c0] | 118 | /** Performs arm32 specific tasks needed before the new task is run. */
|
---|
[d630139] | 119 | void before_task_runs_arch(void)
|
---|
| 120 | {
|
---|
| 121 | }
|
---|
| 122 |
|
---|
[6b781c0] | 123 | /** Performs arm32 specific tasks needed before the new thread is scheduled.
|
---|
| 124 | *
|
---|
| 125 | * It sets supervisor_sp.
|
---|
| 126 | */
|
---|
[d630139] | 127 | void before_thread_runs_arch(void)
|
---|
| 128 | {
|
---|
[6b781c0] | 129 | uint8_t *stck;
|
---|
[a35b458] | 130 |
|
---|
[2277e03] | 131 | stck = &THREAD->kstack[STACK_SIZE];
|
---|
[6b781c0] | 132 | supervisor_sp = (uintptr_t) stck;
|
---|
[d630139] | 133 | }
|
---|
| 134 |
|
---|
[6b781c0] | 135 | /** Performs arm32 specific tasks before a thread stops running.
|
---|
| 136 | *
|
---|
| 137 | * Currently the function is empty.
|
---|
| 138 | */
|
---|
[d630139] | 139 | void after_thread_ran_arch(void)
|
---|
| 140 | {
|
---|
| 141 | }
|
---|
| 142 |
|
---|
[6b781c0] | 143 | /** Halts CPU. */
|
---|
| 144 | void cpu_halt(void)
|
---|
| 145 | {
|
---|
[82474ef] | 146 | while (true)
|
---|
| 147 | machine_cpu_halt();
|
---|
[6b781c0] | 148 | }
|
---|
| 149 |
|
---|
| 150 | /** Reboot. */
|
---|
[193d280c] | 151 | void arch_reboot(void)
|
---|
[f74bbaf] | 152 | {
|
---|
[6b781c0] | 153 | /* not implemented */
|
---|
[1433ecda] | 154 | while (true)
|
---|
| 155 | ;
|
---|
[6da1013f] | 156 | }
|
---|
| 157 |
|
---|
| 158 | /** Construct function pointer
|
---|
| 159 | *
|
---|
| 160 | * @param fptr function pointer structure
|
---|
| 161 | * @param addr function address
|
---|
| 162 | * @param caller calling function address
|
---|
| 163 | *
|
---|
| 164 | * @return address of the function pointer
|
---|
| 165 | *
|
---|
| 166 | */
|
---|
| 167 | void *arch_construct_function(fncptr_t *fptr, void *addr, void *caller)
|
---|
| 168 | {
|
---|
| 169 | return addr;
|
---|
[f74bbaf] | 170 | }
|
---|
| 171 |
|
---|
[3a2f8aa] | 172 | void irq_initialize_arch(irq_t *irq)
|
---|
| 173 | {
|
---|
| 174 | (void) irq;
|
---|
| 175 | }
|
---|
| 176 |
|
---|
[d630139] | 177 | /** @}
|
---|
| 178 | */
|
---|