4 * Copyright (c) 2007 Magnus Damm
5 * Copyright (c) 2005 Samuel Tardieu
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29 #include "sh7750_regs.h"
30 #include "sh7750_regnames.h"
36 typedef struct SH7750State
{
39 /* Peripheral frequency in Hz */
41 /* SDRAM controller */
47 /* PCMCIA controller */
53 uint16_t portdira
; /* Cached */
54 uint16_t portpullupa
; /* Cached */
55 uint16_t portdirb
; /* Cached */
56 uint16_t portpullupb
; /* Cached */
59 uint16_t periph_pdtra
; /* Imposed by the peripherals */
60 uint16_t periph_portdira
; /* Direction seen from the peripherals */
61 uint16_t periph_pdtrb
; /* Imposed by the peripherals */
62 uint16_t periph_portdirb
; /* Direction seen from the peripherals */
63 sh7750_io_device
*devices
[NB_DEVICES
]; /* External peripherals */
68 struct intc_desc intc
;
71 static inline int has_bcr3_and_bcr4(SH7750State
* s
)
73 return (s
->cpu
->features
& SH_FEATURE_BCR3_AND_BCR4
);
75 /**********************************************************************
77 **********************************************************************/
79 int sh7750_register_io_device(SH7750State
* s
, sh7750_io_device
* device
)
83 for (i
= 0; i
< NB_DEVICES
; i
++) {
84 if (s
->devices
[i
] == NULL
) {
85 s
->devices
[i
] = device
;
92 static uint16_t portdir(uint32_t v
)
94 #define EVENPORTMASK(n) ((v & (1<<((n)<<1))) >> (n))
96 EVENPORTMASK(15) | EVENPORTMASK(14) | EVENPORTMASK(13) |
97 EVENPORTMASK(12) | EVENPORTMASK(11) | EVENPORTMASK(10) |
98 EVENPORTMASK(9) | EVENPORTMASK(8) | EVENPORTMASK(7) |
99 EVENPORTMASK(6) | EVENPORTMASK(5) | EVENPORTMASK(4) |
100 EVENPORTMASK(3) | EVENPORTMASK(2) | EVENPORTMASK(1) |
104 static uint16_t portpullup(uint32_t v
)
106 #define ODDPORTMASK(n) ((v & (1<<(((n)<<1)+1))) >> (n))
108 ODDPORTMASK(15) | ODDPORTMASK(14) | ODDPORTMASK(13) |
109 ODDPORTMASK(12) | ODDPORTMASK(11) | ODDPORTMASK(10) |
110 ODDPORTMASK(9) | ODDPORTMASK(8) | ODDPORTMASK(7) | ODDPORTMASK(6) |
111 ODDPORTMASK(5) | ODDPORTMASK(4) | ODDPORTMASK(3) | ODDPORTMASK(2) |
112 ODDPORTMASK(1) | ODDPORTMASK(0);
115 static uint16_t porta_lines(SH7750State
* s
)
117 return (s
->portdira
& s
->pdtra
) | /* CPU */
118 (s
->periph_portdira
& s
->periph_pdtra
) | /* Peripherals */
119 (~(s
->portdira
| s
->periph_portdira
) & s
->portpullupa
); /* Pullups */
122 static uint16_t portb_lines(SH7750State
* s
)
124 return (s
->portdirb
& s
->pdtrb
) | /* CPU */
125 (s
->periph_portdirb
& s
->periph_pdtrb
) | /* Peripherals */
126 (~(s
->portdirb
| s
->periph_portdirb
) & s
->portpullupb
); /* Pullups */
129 static void gen_port_interrupts(SH7750State
* s
)
131 /* XXXXX interrupts not generated */
134 static void porta_changed(SH7750State
* s
, uint16_t prev
)
136 uint16_t currenta
, changes
;
140 fprintf(stderr
, "porta changed from 0x%04x to 0x%04x\n",
141 prev
, porta_lines(s
));
142 fprintf(stderr
, "pdtra=0x%04x, pctra=0x%08x\n", s
->pdtra
, s
->pctra
);
144 currenta
= porta_lines(s
);
145 if (currenta
== prev
)
147 changes
= currenta
^ prev
;
149 for (i
= 0; i
< NB_DEVICES
; i
++) {
150 if (s
->devices
[i
] && (s
->devices
[i
]->portamask_trigger
& changes
)) {
151 r
|= s
->devices
[i
]->port_change_cb(currenta
, portb_lines(s
),
155 &s
->periph_portdirb
);
160 gen_port_interrupts(s
);
163 static void portb_changed(SH7750State
* s
, uint16_t prev
)
165 uint16_t currentb
, changes
;
168 currentb
= portb_lines(s
);
169 if (currentb
== prev
)
171 changes
= currentb
^ prev
;
173 for (i
= 0; i
< NB_DEVICES
; i
++) {
174 if (s
->devices
[i
] && (s
->devices
[i
]->portbmask_trigger
& changes
)) {
175 r
|= s
->devices
[i
]->port_change_cb(portb_lines(s
), currentb
,
179 &s
->periph_portdirb
);
184 gen_port_interrupts(s
);
187 /**********************************************************************
189 **********************************************************************/
191 static void error_access(const char *kind
, target_phys_addr_t addr
)
193 fprintf(stderr
, "%s to %s (0x" TARGET_FMT_plx
") not supported\n",
194 kind
, regname(addr
), addr
);
197 static void ignore_access(const char *kind
, target_phys_addr_t addr
)
199 fprintf(stderr
, "%s to %s (0x" TARGET_FMT_plx
") ignored\n",
200 kind
, regname(addr
), addr
);
203 static uint32_t sh7750_mem_readb(void *opaque
, target_phys_addr_t addr
)
207 error_access("byte read", addr
);
212 static uint32_t sh7750_mem_readw(void *opaque
, target_phys_addr_t addr
)
214 SH7750State
*s
= opaque
;
220 if(!has_bcr3_and_bcr4(s
))
221 error_access("word read", addr
);
223 case SH7750_FRQCR_A7
:
229 "Read access to refresh count register, incrementing\n");
231 case SH7750_PDTRA_A7
:
232 return porta_lines(s
);
233 case SH7750_PDTRB_A7
:
234 return portb_lines(s
);
235 case SH7750_RTCOR_A7
:
236 case SH7750_RTCNT_A7
:
237 case SH7750_RTCSR_A7
:
238 ignore_access("word read", addr
);
241 error_access("word read", addr
);
246 static uint32_t sh7750_mem_readl(void *opaque
, target_phys_addr_t addr
)
248 SH7750State
*s
= opaque
;
254 if(!has_bcr3_and_bcr4(s
))
255 error_access("long read", addr
);
261 ignore_access("long read", addr
);
263 case SH7750_MMUCR_A7
:
264 return s
->cpu
->mmucr
;
275 case SH7750_EXPEVT_A7
:
276 return s
->cpu
->expevt
;
277 case SH7750_INTEVT_A7
:
278 return s
->cpu
->intevt
;
281 case 0x1f000030: /* Processor version */
283 case 0x1f000040: /* Cache version */
285 case 0x1f000044: /* Processor revision */
288 error_access("long read", addr
);
293 #define is_in_sdrmx(a, x) (a >= SH7750_SDMR ## x ## _A7 \
294 && a <= (SH7750_SDMR ## x ## _A7 + SH7750_SDMR ## x ## _REGNB))
295 static void sh7750_mem_writeb(void *opaque
, target_phys_addr_t addr
,
299 if (is_in_sdrmx(addr
, 2) || is_in_sdrmx(addr
, 3)) {
300 ignore_access("byte write", addr
);
304 error_access("byte write", addr
);
308 static void sh7750_mem_writew(void *opaque
, target_phys_addr_t addr
,
311 SH7750State
*s
= opaque
;
315 /* SDRAM controller */
320 if(!has_bcr3_and_bcr4(s
))
321 error_access("word write", addr
);
327 case SH7750_RTCNT_A7
:
328 case SH7750_RTCOR_A7
:
329 case SH7750_RTCSR_A7
:
330 ignore_access("word write", addr
);
333 case SH7750_PDTRA_A7
:
334 temp
= porta_lines(s
);
335 s
->pdtra
= mem_value
;
336 porta_changed(s
, temp
);
338 case SH7750_PDTRB_A7
:
339 temp
= portb_lines(s
);
340 s
->pdtrb
= mem_value
;
341 portb_changed(s
, temp
);
344 fprintf(stderr
, "Write access to refresh count register\n");
347 case SH7750_GPIOIC_A7
:
348 s
->gpioic
= mem_value
;
349 if (mem_value
!= 0) {
350 fprintf(stderr
, "I/O interrupts not implemented\n");
355 error_access("word write", addr
);
360 static void sh7750_mem_writel(void *opaque
, target_phys_addr_t addr
,
363 SH7750State
*s
= opaque
;
367 /* SDRAM controller */
372 if(!has_bcr3_and_bcr4(s
))
373 error_access("long write", addr
);
380 ignore_access("long write", addr
);
383 case SH7750_PCTRA_A7
:
384 temp
= porta_lines(s
);
385 s
->pctra
= mem_value
;
386 s
->portdira
= portdir(mem_value
);
387 s
->portpullupa
= portpullup(mem_value
);
388 porta_changed(s
, temp
);
390 case SH7750_PCTRB_A7
:
391 temp
= portb_lines(s
);
392 s
->pctrb
= mem_value
;
393 s
->portdirb
= portdir(mem_value
);
394 s
->portpullupb
= portpullup(mem_value
);
395 portb_changed(s
, temp
);
397 case SH7750_MMUCR_A7
:
398 if (mem_value
& MMUCR_TI
) {
399 cpu_sh4_invalidate_tlb(s
->cpu
);
401 s
->cpu
->mmucr
= mem_value
& ~MMUCR_TI
;
404 /* If asid changes, clear all registered tlb entries. */
405 if ((s
->cpu
->pteh
& 0xff) != (mem_value
& 0xff))
406 tlb_flush(s
->cpu
, 1);
407 s
->cpu
->pteh
= mem_value
;
410 s
->cpu
->ptel
= mem_value
;
413 s
->cpu
->ptea
= mem_value
& 0x0000000f;
416 s
->cpu
->ttb
= mem_value
;
419 s
->cpu
->tea
= mem_value
;
422 s
->cpu
->tra
= mem_value
& 0x000007ff;
424 case SH7750_EXPEVT_A7
:
425 s
->cpu
->expevt
= mem_value
& 0x000007ff;
427 case SH7750_INTEVT_A7
:
428 s
->cpu
->intevt
= mem_value
& 0x000007ff;
434 error_access("long write", addr
);
439 static CPUReadMemoryFunc
* const sh7750_mem_read
[] = {
445 static CPUWriteMemoryFunc
* const sh7750_mem_write
[] = {
451 /* sh775x interrupt controller tables for sh_intc.c
452 * stolen from linux/arch/sh/kernel/cpu/sh4/setup-sh7750.c
458 /* interrupt sources */
459 IRL_0
, IRL_1
, IRL_2
, IRL_3
, IRL_4
, IRL_5
, IRL_6
, IRL_7
,
460 IRL_8
, IRL_9
, IRL_A
, IRL_B
, IRL_C
, IRL_D
, IRL_E
,
461 IRL0
, IRL1
, IRL2
, IRL3
,
463 DMAC_DMTE0
, DMAC_DMTE1
, DMAC_DMTE2
, DMAC_DMTE3
,
464 DMAC_DMTE4
, DMAC_DMTE5
, DMAC_DMTE6
, DMAC_DMTE7
,
466 PCIC0_PCISERR
, PCIC1_PCIERR
, PCIC1_PCIPWDWN
, PCIC1_PCIPWON
,
467 PCIC1_PCIDMA0
, PCIC1_PCIDMA1
, PCIC1_PCIDMA2
, PCIC1_PCIDMA3
,
468 TMU3
, TMU4
, TMU0
, TMU1
, TMU2_TUNI
, TMU2_TICPI
,
469 RTC_ATI
, RTC_PRI
, RTC_CUI
,
470 SCI1_ERI
, SCI1_RXI
, SCI1_TXI
, SCI1_TEI
,
471 SCIF_ERI
, SCIF_RXI
, SCIF_BRI
, SCIF_TXI
,
475 /* interrupt groups */
476 DMAC
, PCIC1
, TMU2
, RTC
, SCI1
, SCIF
, REF
,
483 static struct intc_vect vectors
[] = {
484 INTC_VECT(HUDI
, 0x600), INTC_VECT(GPIOI
, 0x620),
485 INTC_VECT(TMU0
, 0x400), INTC_VECT(TMU1
, 0x420),
486 INTC_VECT(TMU2_TUNI
, 0x440), INTC_VECT(TMU2_TICPI
, 0x460),
487 INTC_VECT(RTC_ATI
, 0x480), INTC_VECT(RTC_PRI
, 0x4a0),
488 INTC_VECT(RTC_CUI
, 0x4c0),
489 INTC_VECT(SCI1_ERI
, 0x4e0), INTC_VECT(SCI1_RXI
, 0x500),
490 INTC_VECT(SCI1_TXI
, 0x520), INTC_VECT(SCI1_TEI
, 0x540),
491 INTC_VECT(SCIF_ERI
, 0x700), INTC_VECT(SCIF_RXI
, 0x720),
492 INTC_VECT(SCIF_BRI
, 0x740), INTC_VECT(SCIF_TXI
, 0x760),
493 INTC_VECT(WDT
, 0x560),
494 INTC_VECT(REF_RCMI
, 0x580), INTC_VECT(REF_ROVI
, 0x5a0),
497 static struct intc_group groups
[] = {
498 INTC_GROUP(TMU2
, TMU2_TUNI
, TMU2_TICPI
),
499 INTC_GROUP(RTC
, RTC_ATI
, RTC_PRI
, RTC_CUI
),
500 INTC_GROUP(SCI1
, SCI1_ERI
, SCI1_RXI
, SCI1_TXI
, SCI1_TEI
),
501 INTC_GROUP(SCIF
, SCIF_ERI
, SCIF_RXI
, SCIF_BRI
, SCIF_TXI
),
502 INTC_GROUP(REF
, REF_RCMI
, REF_ROVI
),
505 static struct intc_prio_reg prio_registers
[] = {
506 { 0xffd00004, 0, 16, 4, /* IPRA */ { TMU0
, TMU1
, TMU2
, RTC
} },
507 { 0xffd00008, 0, 16, 4, /* IPRB */ { WDT
, REF
, SCI1
, 0 } },
508 { 0xffd0000c, 0, 16, 4, /* IPRC */ { GPIOI
, DMAC
, SCIF
, HUDI
} },
509 { 0xffd00010, 0, 16, 4, /* IPRD */ { IRL0
, IRL1
, IRL2
, IRL3
} },
510 { 0xfe080000, 0, 32, 4, /* INTPRI00 */ { 0, 0, 0, 0,
512 PCIC1
, PCIC0_PCISERR
} },
515 /* SH7750, SH7750S, SH7751 and SH7091 all have 4-channel DMA controllers */
517 static struct intc_vect vectors_dma4
[] = {
518 INTC_VECT(DMAC_DMTE0
, 0x640), INTC_VECT(DMAC_DMTE1
, 0x660),
519 INTC_VECT(DMAC_DMTE2
, 0x680), INTC_VECT(DMAC_DMTE3
, 0x6a0),
520 INTC_VECT(DMAC_DMAE
, 0x6c0),
523 static struct intc_group groups_dma4
[] = {
524 INTC_GROUP(DMAC
, DMAC_DMTE0
, DMAC_DMTE1
, DMAC_DMTE2
,
525 DMAC_DMTE3
, DMAC_DMAE
),
528 /* SH7750R and SH7751R both have 8-channel DMA controllers */
530 static struct intc_vect vectors_dma8
[] = {
531 INTC_VECT(DMAC_DMTE0
, 0x640), INTC_VECT(DMAC_DMTE1
, 0x660),
532 INTC_VECT(DMAC_DMTE2
, 0x680), INTC_VECT(DMAC_DMTE3
, 0x6a0),
533 INTC_VECT(DMAC_DMTE4
, 0x780), INTC_VECT(DMAC_DMTE5
, 0x7a0),
534 INTC_VECT(DMAC_DMTE6
, 0x7c0), INTC_VECT(DMAC_DMTE7
, 0x7e0),
535 INTC_VECT(DMAC_DMAE
, 0x6c0),
538 static struct intc_group groups_dma8
[] = {
539 INTC_GROUP(DMAC
, DMAC_DMTE0
, DMAC_DMTE1
, DMAC_DMTE2
,
540 DMAC_DMTE3
, DMAC_DMTE4
, DMAC_DMTE5
,
541 DMAC_DMTE6
, DMAC_DMTE7
, DMAC_DMAE
),
544 /* SH7750R, SH7751 and SH7751R all have two extra timer channels */
546 static struct intc_vect vectors_tmu34
[] = {
547 INTC_VECT(TMU3
, 0xb00), INTC_VECT(TMU4
, 0xb80),
550 static struct intc_mask_reg mask_registers
[] = {
551 { 0xfe080040, 0xfe080060, 32, /* INTMSK00 / INTMSKCLR00 */
552 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
553 0, 0, 0, 0, 0, 0, TMU4
, TMU3
,
554 PCIC1_PCIERR
, PCIC1_PCIPWDWN
, PCIC1_PCIPWON
,
555 PCIC1_PCIDMA0
, PCIC1_PCIDMA1
, PCIC1_PCIDMA2
,
556 PCIC1_PCIDMA3
, PCIC0_PCISERR
} },
559 /* SH7750S, SH7750R, SH7751 and SH7751R all have IRLM priority registers */
561 static struct intc_vect vectors_irlm
[] = {
562 INTC_VECT(IRL0
, 0x240), INTC_VECT(IRL1
, 0x2a0),
563 INTC_VECT(IRL2
, 0x300), INTC_VECT(IRL3
, 0x360),
566 /* SH7751 and SH7751R both have PCI */
568 static struct intc_vect vectors_pci
[] = {
569 INTC_VECT(PCIC0_PCISERR
, 0xa00), INTC_VECT(PCIC1_PCIERR
, 0xae0),
570 INTC_VECT(PCIC1_PCIPWDWN
, 0xac0), INTC_VECT(PCIC1_PCIPWON
, 0xaa0),
571 INTC_VECT(PCIC1_PCIDMA0
, 0xa80), INTC_VECT(PCIC1_PCIDMA1
, 0xa60),
572 INTC_VECT(PCIC1_PCIDMA2
, 0xa40), INTC_VECT(PCIC1_PCIDMA3
, 0xa20),
575 static struct intc_group groups_pci
[] = {
576 INTC_GROUP(PCIC1
, PCIC1_PCIERR
, PCIC1_PCIPWDWN
, PCIC1_PCIPWON
,
577 PCIC1_PCIDMA0
, PCIC1_PCIDMA1
, PCIC1_PCIDMA2
, PCIC1_PCIDMA3
),
580 static struct intc_vect vectors_irl
[] = {
581 INTC_VECT(IRL_0
, 0x200),
582 INTC_VECT(IRL_1
, 0x220),
583 INTC_VECT(IRL_2
, 0x240),
584 INTC_VECT(IRL_3
, 0x260),
585 INTC_VECT(IRL_4
, 0x280),
586 INTC_VECT(IRL_5
, 0x2a0),
587 INTC_VECT(IRL_6
, 0x2c0),
588 INTC_VECT(IRL_7
, 0x2e0),
589 INTC_VECT(IRL_8
, 0x300),
590 INTC_VECT(IRL_9
, 0x320),
591 INTC_VECT(IRL_A
, 0x340),
592 INTC_VECT(IRL_B
, 0x360),
593 INTC_VECT(IRL_C
, 0x380),
594 INTC_VECT(IRL_D
, 0x3a0),
595 INTC_VECT(IRL_E
, 0x3c0),
598 static struct intc_group groups_irl
[] = {
599 INTC_GROUP(IRL
, IRL_0
, IRL_1
, IRL_2
, IRL_3
, IRL_4
, IRL_5
, IRL_6
,
600 IRL_7
, IRL_8
, IRL_9
, IRL_A
, IRL_B
, IRL_C
, IRL_D
, IRL_E
),
603 /**********************************************************************
604 Memory mapped cache and TLB
605 **********************************************************************/
607 #define MM_REGION_MASK 0x07000000
608 #define MM_ICACHE_ADDR (0)
609 #define MM_ICACHE_DATA (1)
610 #define MM_ITLB_ADDR (2)
611 #define MM_ITLB_DATA (3)
612 #define MM_OCACHE_ADDR (4)
613 #define MM_OCACHE_DATA (5)
614 #define MM_UTLB_ADDR (6)
615 #define MM_UTLB_DATA (7)
616 #define MM_REGION_TYPE(addr) ((addr & MM_REGION_MASK) >> 24)
618 static uint32_t invalid_read(void *opaque
, target_phys_addr_t addr
)
625 static uint32_t sh7750_mmct_readl(void *opaque
, target_phys_addr_t addr
)
627 SH7750State
*s
= opaque
;
630 switch (MM_REGION_TYPE(addr
)) {
636 ret
= cpu_sh4_read_mmaped_itlb_addr(s
->cpu
, addr
);
639 ret
= cpu_sh4_read_mmaped_itlb_data(s
->cpu
, addr
);
646 ret
= cpu_sh4_read_mmaped_utlb_addr(s
->cpu
, addr
);
649 ret
= cpu_sh4_read_mmaped_utlb_data(s
->cpu
, addr
);
658 static void invalid_write(void *opaque
, target_phys_addr_t addr
,
664 static void sh7750_mmct_writel(void *opaque
, target_phys_addr_t addr
,
667 SH7750State
*s
= opaque
;
669 switch (MM_REGION_TYPE(addr
)) {
675 cpu_sh4_write_mmaped_itlb_addr(s
->cpu
, addr
, mem_value
);
678 cpu_sh4_write_mmaped_itlb_data(s
->cpu
, addr
, mem_value
);
686 cpu_sh4_write_mmaped_utlb_addr(s
->cpu
, addr
, mem_value
);
689 cpu_sh4_write_mmaped_utlb_data(s
->cpu
, addr
, mem_value
);
697 static CPUReadMemoryFunc
* const sh7750_mmct_read
[] = {
703 static CPUWriteMemoryFunc
* const sh7750_mmct_write
[] = {
709 SH7750State
*sh7750_init(CPUSH4State
* cpu
)
712 int sh7750_io_memory
;
713 int sh7750_mm_cache_and_tlb
; /* memory mapped cache and tlb */
715 s
= qemu_mallocz(sizeof(SH7750State
));
717 s
->periph_freq
= 60000000; /* 60MHz */
718 sh7750_io_memory
= cpu_register_io_memory(sh7750_mem_read
,
720 DEVICE_NATIVE_ENDIAN
);
721 cpu_register_physical_memory_offset(0x1f000000, 0x1000,
722 sh7750_io_memory
, 0x1f000000);
723 cpu_register_physical_memory_offset(0xff000000, 0x1000,
724 sh7750_io_memory
, 0x1f000000);
725 cpu_register_physical_memory_offset(0x1f800000, 0x1000,
726 sh7750_io_memory
, 0x1f800000);
727 cpu_register_physical_memory_offset(0xff800000, 0x1000,
728 sh7750_io_memory
, 0x1f800000);
729 cpu_register_physical_memory_offset(0x1fc00000, 0x1000,
730 sh7750_io_memory
, 0x1fc00000);
731 cpu_register_physical_memory_offset(0xffc00000, 0x1000,
732 sh7750_io_memory
, 0x1fc00000);
734 sh7750_mm_cache_and_tlb
= cpu_register_io_memory(sh7750_mmct_read
,
735 sh7750_mmct_write
, s
,
736 DEVICE_NATIVE_ENDIAN
);
737 cpu_register_physical_memory(0xf0000000, 0x08000000,
738 sh7750_mm_cache_and_tlb
);
740 sh_intc_init(&s
->intc
, NR_SOURCES
,
741 _INTC_ARRAY(mask_registers
),
742 _INTC_ARRAY(prio_registers
));
744 sh_intc_register_sources(&s
->intc
,
745 _INTC_ARRAY(vectors
),
746 _INTC_ARRAY(groups
));
748 cpu
->intc_handle
= &s
->intc
;
750 sh_serial_init(0x1fe00000, 0, s
->periph_freq
, serial_hds
[0],
751 s
->intc
.irqs
[SCI1_ERI
],
752 s
->intc
.irqs
[SCI1_RXI
],
753 s
->intc
.irqs
[SCI1_TXI
],
754 s
->intc
.irqs
[SCI1_TEI
],
756 sh_serial_init(0x1fe80000, SH_SERIAL_FEAT_SCIF
,
757 s
->periph_freq
, serial_hds
[1],
758 s
->intc
.irqs
[SCIF_ERI
],
759 s
->intc
.irqs
[SCIF_RXI
],
760 s
->intc
.irqs
[SCIF_TXI
],
762 s
->intc
.irqs
[SCIF_BRI
]);
764 tmu012_init(0x1fd80000,
765 TMU012_FEAT_TOCR
| TMU012_FEAT_3CHAN
| TMU012_FEAT_EXTCLK
,
769 s
->intc
.irqs
[TMU2_TUNI
],
770 s
->intc
.irqs
[TMU2_TICPI
]);
772 if (cpu
->id
& (SH_CPU_SH7750
| SH_CPU_SH7750S
| SH_CPU_SH7751
)) {
773 sh_intc_register_sources(&s
->intc
,
774 _INTC_ARRAY(vectors_dma4
),
775 _INTC_ARRAY(groups_dma4
));
778 if (cpu
->id
& (SH_CPU_SH7750R
| SH_CPU_SH7751R
)) {
779 sh_intc_register_sources(&s
->intc
,
780 _INTC_ARRAY(vectors_dma8
),
781 _INTC_ARRAY(groups_dma8
));
784 if (cpu
->id
& (SH_CPU_SH7750R
| SH_CPU_SH7751
| SH_CPU_SH7751R
)) {
785 sh_intc_register_sources(&s
->intc
,
786 _INTC_ARRAY(vectors_tmu34
),
788 tmu012_init(0x1e100000, 0, s
->periph_freq
,
794 if (cpu
->id
& (SH_CPU_SH7751_ALL
)) {
795 sh_intc_register_sources(&s
->intc
,
796 _INTC_ARRAY(vectors_pci
),
797 _INTC_ARRAY(groups_pci
));
800 if (cpu
->id
& (SH_CPU_SH7750S
| SH_CPU_SH7750R
| SH_CPU_SH7751_ALL
)) {
801 sh_intc_register_sources(&s
->intc
,
802 _INTC_ARRAY(vectors_irlm
),
806 sh_intc_register_sources(&s
->intc
,
807 _INTC_ARRAY(vectors_irl
),
808 _INTC_ARRAY(groups_irl
));
812 qemu_irq
sh7750_irl(SH7750State
*s
)
814 sh_intc_toggle_source(sh_intc_source(&s
->intc
, IRL
), 1, 0); /* enable */
815 return qemu_allocate_irqs(sh_intc_set_irl
, sh_intc_source(&s
->intc
, IRL
),