diff options
| author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
|---|---|---|
| committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
| commit | fcc9d2e5a6c89d22b8b773a64fb4ad21ac318446 (patch) | |
| tree | a57612d1888735a2ec7972891b68c1ac5ec8faea /arch/tile/kernel | |
| parent | 8dea78da5cee153b8af9c07a2745f6c55057fe12 (diff) | |
Diffstat (limited to 'arch/tile/kernel')
| -rw-r--r-- | arch/tile/kernel/init_task.c | 59 | ||||
| -rw-r--r-- | arch/tile/kernel/relocate_kernel.S | 280 |
2 files changed, 339 insertions, 0 deletions
diff --git a/arch/tile/kernel/init_task.c b/arch/tile/kernel/init_task.c new file mode 100644 index 00000000000..928b3187066 --- /dev/null +++ b/arch/tile/kernel/init_task.c | |||
| @@ -0,0 +1,59 @@ | |||
| 1 | /* | ||
| 2 | * Copyright 2010 Tilera Corporation. All Rights Reserved. | ||
| 3 | * | ||
| 4 | * This program is free software; you can redistribute it and/or | ||
| 5 | * modify it under the terms of the GNU General Public License | ||
| 6 | * as published by the Free Software Foundation, version 2. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, but | ||
| 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
| 11 | * NON INFRINGEMENT. See the GNU General Public License for | ||
| 12 | * more details. | ||
| 13 | */ | ||
| 14 | |||
| 15 | #include <linux/mm.h> | ||
| 16 | #include <linux/fs.h> | ||
| 17 | #include <linux/init_task.h> | ||
| 18 | #include <linux/mqueue.h> | ||
| 19 | #include <linux/module.h> | ||
| 20 | #include <linux/start_kernel.h> | ||
| 21 | #include <linux/uaccess.h> | ||
| 22 | |||
| 23 | static struct signal_struct init_signals = INIT_SIGNALS(init_signals); | ||
| 24 | static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); | ||
| 25 | |||
| 26 | /* | ||
| 27 | * Initial thread structure. | ||
| 28 | * | ||
| 29 | * We need to make sure that this is THREAD_SIZE aligned due to the | ||
| 30 | * way process stacks are handled. This is done by having a special | ||
| 31 | * "init_task" linker map entry.. | ||
| 32 | */ | ||
| 33 | union thread_union init_thread_union __init_task_data = { | ||
| 34 | INIT_THREAD_INFO(init_task) | ||
| 35 | }; | ||
| 36 | |||
| 37 | /* | ||
| 38 | * Initial task structure. | ||
| 39 | * | ||
| 40 | * All other task structs will be allocated on slabs in fork.c | ||
| 41 | */ | ||
| 42 | struct task_struct init_task = INIT_TASK(init_task); | ||
| 43 | EXPORT_SYMBOL(init_task); | ||
| 44 | |||
| 45 | /* | ||
| 46 | * per-CPU stack and boot info. | ||
| 47 | */ | ||
| 48 | DEFINE_PER_CPU(unsigned long, boot_sp) = | ||
| 49 | (unsigned long)init_stack + THREAD_SIZE; | ||
| 50 | |||
| 51 | #ifdef CONFIG_SMP | ||
| 52 | DEFINE_PER_CPU(unsigned long, boot_pc) = (unsigned long)start_kernel; | ||
| 53 | #else | ||
| 54 | /* | ||
| 55 | * The variable must be __initdata since it references __init code. | ||
| 56 | * With CONFIG_SMP it is per-cpu data, which is exempt from validation. | ||
| 57 | */ | ||
| 58 | unsigned long __initdata boot_pc = (unsigned long)start_kernel; | ||
| 59 | #endif | ||
diff --git a/arch/tile/kernel/relocate_kernel.S b/arch/tile/kernel/relocate_kernel.S new file mode 100644 index 00000000000..010b418515f --- /dev/null +++ b/arch/tile/kernel/relocate_kernel.S | |||
| @@ -0,0 +1,280 @@ | |||
| 1 | /* | ||
| 2 | * Copyright 2010 Tilera Corporation. All Rights Reserved. | ||
| 3 | * | ||
| 4 | * This program is free software; you can redistribute it and/or | ||
| 5 | * modify it under the terms of the GNU General Public License | ||
| 6 | * as published by the Free Software Foundation, version 2. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, but | ||
| 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
| 11 | * NON INFRINGEMENT. See the GNU General Public License for | ||
| 12 | * more details. | ||
| 13 | * | ||
| 14 | * copy new kernel into place and then call hv_reexec | ||
| 15 | * | ||
| 16 | */ | ||
| 17 | |||
| 18 | #include <linux/linkage.h> | ||
| 19 | #include <arch/chip.h> | ||
| 20 | #include <asm/page.h> | ||
| 21 | #include <hv/hypervisor.h> | ||
| 22 | |||
| 23 | #define ___hvb MEM_SV_INTRPT + HV_GLUE_START_CPA | ||
| 24 | |||
| 25 | #define ___hv_dispatch(f) (___hvb + (HV_DISPATCH_ENTRY_SIZE * f)) | ||
| 26 | |||
| 27 | #define ___hv_console_putc ___hv_dispatch(HV_DISPATCH_CONSOLE_PUTC) | ||
| 28 | #define ___hv_halt ___hv_dispatch(HV_DISPATCH_HALT) | ||
| 29 | #define ___hv_reexec ___hv_dispatch(HV_DISPATCH_REEXEC) | ||
| 30 | #define ___hv_flush_remote ___hv_dispatch(HV_DISPATCH_FLUSH_REMOTE) | ||
| 31 | |||
| 32 | #undef RELOCATE_NEW_KERNEL_VERBOSE | ||
| 33 | |||
| 34 | STD_ENTRY(relocate_new_kernel) | ||
| 35 | |||
| 36 | move r30, r0 /* page list */ | ||
| 37 | move r31, r1 /* address of page we are on */ | ||
| 38 | move r32, r2 /* start address of new kernel */ | ||
| 39 | |||
| 40 | shri r1, r1, PAGE_SHIFT | ||
| 41 | addi r1, r1, 1 | ||
| 42 | shli sp, r1, PAGE_SHIFT | ||
| 43 | addi sp, sp, -8 | ||
| 44 | /* we now have a stack (whether we need one or not) */ | ||
| 45 | |||
| 46 | moveli r40, lo16(___hv_console_putc) | ||
| 47 | auli r40, r40, ha16(___hv_console_putc) | ||
| 48 | |||
| 49 | #ifdef RELOCATE_NEW_KERNEL_VERBOSE | ||
| 50 | moveli r0, 'r' | ||
| 51 | jalr r40 | ||
| 52 | |||
| 53 | moveli r0, '_' | ||
| 54 | jalr r40 | ||
| 55 | |||
| 56 | moveli r0, 'n' | ||
| 57 | jalr r40 | ||
| 58 | |||
| 59 | moveli r0, '_' | ||
| 60 | jalr r40 | ||
| 61 | |||
| 62 | moveli r0, 'k' | ||
| 63 | jalr r40 | ||
| 64 | |||
| 65 | moveli r0, '\n' | ||
| 66 | jalr r40 | ||
| 67 | #endif | ||
| 68 | |||
| 69 | /* | ||
| 70 | * Throughout this code r30 is pointer to the element of page | ||
| 71 | * list we are working on. | ||
| 72 | * | ||
| 73 | * Normally we get to the next element of the page list by | ||
| 74 | * incrementing r30 by four. The exception is if the element | ||
| 75 | * on the page list is an IND_INDIRECTION in which case we use | ||
| 76 | * the element with the low bits masked off as the new value | ||
| 77 | * of r30. | ||
| 78 | * | ||
| 79 | * To get this started, we need the value passed to us (which | ||
| 80 | * will always be an IND_INDIRECTION) in memory somewhere with | ||
| 81 | * r30 pointing at it. To do that, we push the value passed | ||
| 82 | * to us on the stack and make r30 point to it. | ||
| 83 | */ | ||
| 84 | |||
| 85 | sw sp, r30 | ||
| 86 | move r30, sp | ||
| 87 | addi sp, sp, -8 | ||
| 88 | |||
| 89 | #if CHIP_HAS_CBOX_HOME_MAP() | ||
| 90 | /* | ||
| 91 | * On TILEPro, we need to flush all tiles' caches, since we may | ||
| 92 | * have been doing hash-for-home caching there. Note that we | ||
| 93 | * must do this _after_ we're completely done modifying any memory | ||
| 94 | * other than our output buffer (which we know is locally cached). | ||
| 95 | * We want the caches to be fully clean when we do the reexec, | ||
| 96 | * because the hypervisor is going to do this flush again at that | ||
| 97 | * point, and we don't want that second flush to overwrite any memory. | ||
| 98 | */ | ||
| 99 | { | ||
| 100 | move r0, zero /* cache_pa */ | ||
| 101 | move r1, zero | ||
| 102 | } | ||
| 103 | { | ||
| 104 | auli r2, zero, ha16(HV_FLUSH_EVICT_L2) /* cache_control */ | ||
| 105 | movei r3, -1 /* cache_cpumask; -1 means all client tiles */ | ||
| 106 | } | ||
| 107 | { | ||
| 108 | move r4, zero /* tlb_va */ | ||
| 109 | move r5, zero /* tlb_length */ | ||
| 110 | } | ||
| 111 | { | ||
| 112 | move r6, zero /* tlb_pgsize */ | ||
| 113 | move r7, zero /* tlb_cpumask */ | ||
| 114 | } | ||
| 115 | { | ||
| 116 | move r8, zero /* asids */ | ||
| 117 | moveli r20, lo16(___hv_flush_remote) | ||
| 118 | } | ||
| 119 | { | ||
| 120 | move r9, zero /* asidcount */ | ||
| 121 | auli r20, r20, ha16(___hv_flush_remote) | ||
| 122 | } | ||
| 123 | |||
| 124 | jalr r20 | ||
| 125 | #endif | ||
| 126 | |||
| 127 | /* r33 is destination pointer, default to zero */ | ||
| 128 | |||
| 129 | moveli r33, 0 | ||
| 130 | |||
| 131 | .Lloop: lw r10, r30 | ||
| 132 | |||
| 133 | andi r9, r10, 0xf /* low 4 bits tell us what type it is */ | ||
| 134 | xor r10, r10, r9 /* r10 is now value with low 4 bits stripped */ | ||
| 135 | |||
| 136 | seqi r0, r9, 0x1 /* IND_DESTINATION */ | ||
| 137 | bzt r0, .Ltry2 | ||
| 138 | |||
| 139 | move r33, r10 | ||
| 140 | |||
| 141 | #ifdef RELOCATE_NEW_KERNEL_VERBOSE | ||
| 142 | moveli r0, 'd' | ||
| 143 | jalr r40 | ||
| 144 | #endif | ||
| 145 | |||
| 146 | addi r30, r30, 4 | ||
| 147 | j .Lloop | ||
| 148 | |||
| 149 | .Ltry2: | ||
| 150 | seqi r0, r9, 0x2 /* IND_INDIRECTION */ | ||
