Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Milkymist SoC (Software)
- * Copyright (C) 2012 Yann Sionneau <yann.sionneau@gmail.com>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- #include <hal/mmu.h>
- #include <base/mmu.h>
- #include <base/stdio.h>
- #ifdef __ASSEMBLER__
- #define MMPTR(x) x
- #else
- #define MMPTR(x) (*((volatile unsigned int *)(x)))
- #endif
- #define CSR_UART_RXTX MMPTR(0xe0000000)
- void f(void) {
- char c = '@';
- CSR_UART_RXTX = c;
- // asm volatile("bi f" ::: ); // We intinitely loop to f()
- asm volatile("xor r0, r0, r0\n\t"
- "xor r0, r0, r0" ::: );
- }
- void itlbtest(void) {
- register unsigned int stack, f_addr;
- unsigned int *p;
- unsigned int *pdest;
- unsigned int addr;
- asm volatile("mv %0, sp" : "=r"(stack) :: );
- printf("stack == 0x%08X\n", stack);
- printf("f() is located at 0x%p\n", f);
- f_addr = 0x44004000;
- printf("Mapping f() into virtual memory at 0x%08X [physical == 0x%08X]\n", f_addr, f_addr+0x1000);
- // for (addr = 0x00860000 ; addr <= 0x00874000 ; addr += 0x1000)
- // mmu_map(addr, addr, DTLB_MAPPING | MAPPING_CAN_READ);
- mmu_map(stack, stack, DTLB_MAPPING | MAPPING_CAN_READ | MAPPING_CAN_WRITE);
- mmu_map(f_addr, f_addr + 0x1000, ITLB_MAPPING | MAPPING_CAN_READ);
- mmu_map(itlbtest, itlbtest, ITLB_MAPPING | MAPPING_CAN_READ);
- mmu_map(call_function_with_itlb_enabled, call_function_with_itlb_enabled, ITLB_MAPPING | MAPPING_CAN_READ);
- puts("Mapping DONE");
- // mmu_itlb_invalidate_line(f_addr);
- // We copy f's code to 0x44005000
- for (p = f, pdest = 0x44005000 ; p < f + 0x1000 ; p++, pdest++)
- *pdest = *p;
- puts("Copy DONE");
- asm volatile("wcsr DCC, r0\n\t"
- "xor r0, r0, r0\n\t"
- "xor r0, r0, r0\n\t"
- "xor r0, r0, r0\n\t"
- "xor r0, r0, r0");
- asm volatile("wcsr ICC, r0\n\t"
- "xor r0, r0, r0");
- puts("Instruction and Data caches have been invalidated");
- call_function_with_itlb_enabled(f_addr);
- disable_dtlb();
- disable_itlb();
- puts("Call DONE");
- }
- 00865a44 <f>:
- 865a44: 34 02 00 40 mvi r2,64
- 865a48: 78 01 e0 00 mvhi r1,0xe000
- 865a4c: 58 22 00 00 sw (r1+0),r2
- 865a50: 98 00 00 00 xor r0,r0,r0
- 865a54: 98 00 00 00 xor r0,r0,r0
- 865a58: c3 a0 00 00 ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement