root / hw / sun4m.c @ 546fa6ab
History | View | Annotate | Download (4.6 kB)
1 | 420557e8 | bellard | /*
|
---|---|---|---|
2 | 420557e8 | bellard | * QEMU Sun4m System Emulator
|
3 | 420557e8 | bellard | *
|
4 | 420557e8 | bellard | * Copyright (c) 2003-2004 Fabrice Bellard
|
5 | 420557e8 | bellard | *
|
6 | 420557e8 | bellard | * Permission is hereby granted, free of charge, to any person obtaining a copy
|
7 | 420557e8 | bellard | * of this software and associated documentation files (the "Software"), to deal
|
8 | 420557e8 | bellard | * in the Software without restriction, including without limitation the rights
|
9 | 420557e8 | bellard | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10 | 420557e8 | bellard | * copies of the Software, and to permit persons to whom the Software is
|
11 | 420557e8 | bellard | * furnished to do so, subject to the following conditions:
|
12 | 420557e8 | bellard | *
|
13 | 420557e8 | bellard | * The above copyright notice and this permission notice shall be included in
|
14 | 420557e8 | bellard | * all copies or substantial portions of the Software.
|
15 | 420557e8 | bellard | *
|
16 | 420557e8 | bellard | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 | 420557e8 | bellard | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 | 420557e8 | bellard | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 | 420557e8 | bellard | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 | 420557e8 | bellard | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21 | 420557e8 | bellard | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22 | 420557e8 | bellard | * THE SOFTWARE.
|
23 | 420557e8 | bellard | */
|
24 | 420557e8 | bellard | #include "vl.h" |
25 | 420557e8 | bellard | #include "m48t08.h" |
26 | 420557e8 | bellard | |
27 | 420557e8 | bellard | #define KERNEL_LOAD_ADDR 0x00004000 |
28 | 420557e8 | bellard | #define MMU_CONTEXT_TBL 0x00003000 |
29 | 420557e8 | bellard | #define MMU_L1PTP (MMU_CONTEXT_TBL + 0x0400) |
30 | 420557e8 | bellard | #define MMU_L2PTP (MMU_CONTEXT_TBL + 0x0800) |
31 | 420557e8 | bellard | #define PROM_ADDR 0xffd04000 |
32 | 8d5f07fa | bellard | #define PROM_FILENAMEB "proll.bin" |
33 | 8d5f07fa | bellard | #define PROM_FILENAMEE "proll.elf" |
34 | 8d5f07fa | bellard | #define PROLL_MAGIC_ADDR 0x20000000 |
35 | 420557e8 | bellard | #define PHYS_JJ_EEPROM 0x71200000 /* [2000] MK48T08 */ |
36 | 420557e8 | bellard | #define PHYS_JJ_IDPROM_OFF 0x1FD8 |
37 | 420557e8 | bellard | #define PHYS_JJ_EEPROM_SIZE 0x2000 |
38 | 8d5f07fa | bellard | #define PHYS_JJ_IOMMU 0x10000000 /* First page of sun4m IOMMU */ |
39 | 8d5f07fa | bellard | #define PHYS_JJ_TCX_FB 0x50800000 /* Start address, frame buffer body */ |
40 | 8d5f07fa | bellard | #define PHYS_JJ_TCX_0E 0x5E000000 /* Top address, one byte used. */ |
41 | 8d5f07fa | bellard | #define PHYS_JJ_IOMMU 0x10000000 /* First page of sun4m IOMMU */ |
42 | 8d5f07fa | bellard | #define PHYS_JJ_LEDMA 0x78400010 /* ledma, off by 10 from unused SCSI */ |
43 | 8d5f07fa | bellard | #define PHYS_JJ_LE 0x78C00000 /* LANCE, typical sun4m */ |
44 | 8d5f07fa | bellard | #define PHYS_JJ_LE_IRQ 6 |
45 | 8d5f07fa | bellard | #define PHYS_JJ_CLOCK 0x71D00000 |
46 | 8d5f07fa | bellard | #define PHYS_JJ_CLOCK_IRQ 10 |
47 | 8d5f07fa | bellard | #define PHYS_JJ_CLOCK1 0x71D10000 |
48 | 8d5f07fa | bellard | #define PHYS_JJ_CLOCK1_IRQ 14 |
49 | 8d5f07fa | bellard | #define PHYS_JJ_INTR0 0x71E00000 /* CPU0 interrupt control registers */ |
50 | 8d5f07fa | bellard | #define PHYS_JJ_INTR_G 0x71E10000 /* Master interrupt control registers */ |
51 | 420557e8 | bellard | |
52 | 420557e8 | bellard | /* TSC handling */
|
53 | 420557e8 | bellard | |
54 | 420557e8 | bellard | uint64_t cpu_get_tsc() |
55 | 420557e8 | bellard | { |
56 | 420557e8 | bellard | return qemu_get_clock(vm_clock);
|
57 | 420557e8 | bellard | } |
58 | 420557e8 | bellard | |
59 | 420557e8 | bellard | void DMA_run() {}
|
60 | 420557e8 | bellard | void SB16_run() {}
|
61 | 420557e8 | bellard | int serial_can_receive(SerialState *s) { return 0; } |
62 | 420557e8 | bellard | void serial_receive_byte(SerialState *s, int ch) {} |
63 | 420557e8 | bellard | void serial_receive_break(SerialState *s) {}
|
64 | 420557e8 | bellard | |
65 | 420557e8 | bellard | static m48t08_t *nvram;
|
66 | 420557e8 | bellard | |
67 | 420557e8 | bellard | /* Sun4m hardware initialisation */
|
68 | 420557e8 | bellard | void sun4m_init(int ram_size, int vga_ram_size, int boot_device, |
69 | 420557e8 | bellard | DisplayState *ds, const char **fd_filename, int snapshot, |
70 | 420557e8 | bellard | const char *kernel_filename, const char *kernel_cmdline, |
71 | 420557e8 | bellard | const char *initrd_filename) |
72 | 420557e8 | bellard | { |
73 | 420557e8 | bellard | char buf[1024]; |
74 | 8d5f07fa | bellard | int ret, linux_boot;
|
75 | 420557e8 | bellard | unsigned long bios_offset; |
76 | 420557e8 | bellard | |
77 | 420557e8 | bellard | linux_boot = (kernel_filename != NULL);
|
78 | 420557e8 | bellard | |
79 | 420557e8 | bellard | /* allocate RAM */
|
80 | 420557e8 | bellard | cpu_register_physical_memory(0, ram_size, 0); |
81 | 420557e8 | bellard | bios_offset = ram_size; |
82 | 420557e8 | bellard | |
83 | 8d5f07fa | bellard | iommu_init(PHYS_JJ_IOMMU); |
84 | 8d5f07fa | bellard | sched_init(PHYS_JJ_INTR0, PHYS_JJ_INTR_G); |
85 | 8d5f07fa | bellard | tcx_init(ds, PHYS_JJ_TCX_FB); |
86 | 8d5f07fa | bellard | lance_init(&nd_table[0], PHYS_JJ_LE_IRQ, PHYS_JJ_LE, PHYS_JJ_LEDMA);
|
87 | 8d5f07fa | bellard | nvram = m48t08_init(PHYS_JJ_EEPROM, PHYS_JJ_EEPROM_SIZE, &nd_table[0].macaddr);
|
88 | 8d5f07fa | bellard | timer_init(PHYS_JJ_CLOCK, PHYS_JJ_CLOCK_IRQ); |
89 | 8d5f07fa | bellard | timer_init(PHYS_JJ_CLOCK1, PHYS_JJ_CLOCK1_IRQ); |
90 | 8d5f07fa | bellard | magic_init(kernel_filename, phys_ram_base + KERNEL_LOAD_ADDR, PROLL_MAGIC_ADDR); |
91 | 420557e8 | bellard | |
92 | 420557e8 | bellard | /* We load Proll as the kernel and start it. It will issue a magic
|
93 | 420557e8 | bellard | IO to load the real kernel */
|
94 | 420557e8 | bellard | if (linux_boot) {
|
95 | 8d5f07fa | bellard | snprintf(buf, sizeof(buf), "%s/%s", bios_dir, PROM_FILENAMEB); |
96 | 420557e8 | bellard | ret = load_kernel(buf, |
97 | 8d5f07fa | bellard | phys_ram_base + KERNEL_LOAD_ADDR); |
98 | 420557e8 | bellard | if (ret < 0) { |
99 | 420557e8 | bellard | fprintf(stderr, "qemu: could not load kernel '%s'\n",
|
100 | 420557e8 | bellard | buf); |
101 | 420557e8 | bellard | exit(1);
|
102 | 420557e8 | bellard | } |
103 | 420557e8 | bellard | } |
104 | 420557e8 | bellard | /* Setup a MMU entry for entire address space */
|
105 | 420557e8 | bellard | stl_raw(phys_ram_base + MMU_CONTEXT_TBL, (MMU_L1PTP >> 4) | 1); |
106 | 420557e8 | bellard | stl_raw(phys_ram_base + MMU_L1PTP, (MMU_L2PTP >> 4) | 1); |
107 | 8d5f07fa | bellard | stl_raw(phys_ram_base + MMU_L1PTP + (0x01 << 2), (MMU_L2PTP >> 4) | 1); // 01.. == 00.. |
108 | 420557e8 | bellard | stl_raw(phys_ram_base + MMU_L1PTP + (0xff << 2), (MMU_L2PTP >> 4) | 1); // ff.. == 00.. |
109 | 8d5f07fa | bellard | stl_raw(phys_ram_base + MMU_L1PTP + (0xf0 << 2), (MMU_L2PTP >> 4) | 1); // f0.. == 00.. |
110 | 420557e8 | bellard | /* 3 = U:RWX S:RWX */
|
111 | 420557e8 | bellard | stl_raw(phys_ram_base + MMU_L2PTP, (3 << PTE_ACCESS_SHIFT) | 2); |
112 | 8d5f07fa | bellard | stl_raw(phys_ram_base + MMU_L2PTP, ((0x01 << PTE_PPN_SHIFT) >> 4 ) | (3 << PTE_ACCESS_SHIFT) | 2); |
113 | 420557e8 | bellard | } |