Skip to contentSkip to conversation

ARM XScale core features and PXA270 and PXA255 emulation.

PATCH In review andrzej zaborowski 2 participants 3 messages Mar 16, 2007 – Apr 17, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM XScale core features and PXA270 and PXA255 emulation.

Implements basic differences between XScale and plain ARM. The patch also adds the main on-chip peripherals of PXA2xx: interrupt controller, DMA, GPIO controller, SSP, I2C, I2S busses, UARTs, FIR port, RTC, Clock/Power/Memory managers.

There's also an api to hook funcitons to coprocessor writes and reads becaue PXA uses those in various on-chip peripherals (and they're supposed to be faster than memory IO access to the same peripherals, on the real hardware).

Cheers,
Andrew

From e0700c2da24f97d10037e3f1517e3d3179b2ad8d Mon Sep 17 00:00:00 2001
From: Andrzej Zaborowski <[email protected]>
Date: Fri, 16 Mar 2007 18:03:11 +0100
Subject: [PATCH] ARM XScale core features. PXA270 and PXA255 emulation.

---
 hw/pxa.h               |  192 +++++
 hw/pxa2xx.c            | 1875 ++++++++++++++++++++++++++++++++++++++++++++++++
 hw/pxa2xx_dma.c        |  500 +++++++++++++
 hw/pxa2xx_gpio.c       |  290 ++++++++
 hw/pxa2xx_pic.c        |  284 ++++++++
 target-arm/cpu.h       |   37 +-
 target-arm/exec.h      |    2 +
 target-arm/helper.c    |  151 ++++-
 target-arm/op.c        |   14 +-
 target-arm/translate.c |   32 +
 vl.h                   |    2 +
 11 files changed, 3362 insertions(+), 17 deletions(-)
hw/pxa.h new file +192 -0
new file mode 100644
index 0000000..16eb32f
@@ -0,0 +1,192 @@
+/*
+ * Intel XScale PXA255/270 processor support.
+ *
+ * Copyright (c) 2006 Openedhand Ltd.
+ * Written by Andrzej Zaborowski <[email protected]>
+ *
+ * This code is licenced under the GPL.
+ */
+#ifndef PXA_H
+# define PXA_H			"pxa.h"
+
+/* Interrupt numbers */
+# define PXA2XX_PIC_SSP3	0
+# define PXA2XX_PIC_USBH2	2
+# define PXA2XX_PIC_USBH1	3
+# define PXA2XX_PIC_PWRI2C	6
+# define PXA25X_PIC_HWUART	7
+# define PXA27X_PIC_OST_4_11	7
+# define PXA2XX_PIC_GPIO_0	8
+# define PXA2XX_PIC_GPIO_1	9
+# define PXA2XX_PIC_GPIO_X	10
+# define PXA2XX_PIC_I2S 	13
+# define PXA26X_PIC_ASSP	15
+# define PXA25X_PIC_NSSP	16
+# define PXA27X_PIC_SSP2	16
+# define PXA2XX_PIC_LCD		17
+# define PXA2XX_PIC_I2C		18
+# define PXA2XX_PIC_ICP		19
+# define PXA2XX_PIC_STUART	20
+# define PXA2XX_PIC_BTUART	21
+# define PXA2XX_PIC_FFUART	22
+# define PXA2XX_PIC_MMC		23
+# define PXA2XX_PIC_SSP		24
+# define PXA2XX_PIC_DMA		25
+# define PXA2XX_PIC_OST_0	26
+# define PXA2XX_PIC_RTC1HZ	30
+# define PXA2XX_PIC_RTCALARM	31
+
+/* DMA requests */
+# define PXA2XX_RX_RQ_I2S	2
+# define PXA2XX_TX_RQ_I2S	3
+# define PXA2XX_RX_RQ_BTUART	4
+# define PXA2XX_TX_RQ_BTUART	5
+# define PXA2XX_RX_RQ_FFUART	6
+# define PXA2XX_TX_RQ_FFUART	7
+# define PXA2XX_RX_RQ_SSP1	13
+# define PXA2XX_TX_RQ_SSP1	14
+# define PXA2XX_RX_RQ_SSP2	15
+# define PXA2XX_TX_RQ_SSP2	16
+# define PXA2XX_RX_RQ_ICP	17
+# define PXA2XX_TX_RQ_ICP	18
+# define PXA2XX_RX_RQ_STUART	19
+# define PXA2XX_TX_RQ_STUART	20
+# define PXA2XX_RX_RQ_MMCI	21
+# define PXA2XX_TX_RQ_MMCI	22
+# define PXA2XX_USB_RQ(x)	((x) + 24)
+# define PXA2XX_RX_RQ_SSP3	66
+# define PXA2XX_TX_RQ_SSP3	67
+
+# define PXA2XX_RAM_BASE	0xa0000000
+
+/* pxa2xx_pic.c */
+struct pxa2xx_pic_state_s;
+struct pxa2xx_pic_state_s *pxa2xx_pic_init(target_phys_addr_t base,
+                CPUState *env);
+
+/* pxa2xx_gpio.c */
+struct pxa2xx_gpio_info_s;
+struct pxa2xx_gpio_info_s *pxa2xx_gpio_init(target_phys_addr_t base,
+                CPUState *env, void *pic, int lines);
+void pxa2xx_gpio_set(struct pxa2xx_gpio_info_s *s, int line, int level);
+void pxa2xx_gpio_handler_set(struct pxa2xx_gpio_info_s *s, int line,
+                gpio_handler_t handler, void *opaque);
+void pxa2xx_gpio_read_notifier(struct pxa2xx_gpio_info_s *s,
+                void (*handler)(void *opaque), void *opaque);
+
+/* pxa2xx_dma.c */
+struct pxa2xx_dma_state_s;
+struct pxa2xx_dma_state_s *pxa255_dma_init(target_phys_addr_t base,
+                void *pic, int irq);
+struct pxa2xx_dma_state_s *pxa27x_dma_init(target_phys_addr_t base,
+                void *pic, int irq);
+void pxa2xx_dma_request(struct pxa2xx_dma_state_s *s, int req_num, int on);
+
+/* pxa2xx.c */
+struct pxa2xx_ssp_s;
+void pxa2xx_ssp_attach(struct pxa2xx_ssp_s *port,
+                uint32_t (*readfn)(void *opaque),
+                void (*writefn)(void *opaque, uint32_t value), void *opaque);
+
+struct pxa2xx_i2c_s;
+struct pxa2xx_i2s_s;
+struct pxa2xx_fir_s;
+
+struct pxa2xx_state_s {
+    CPUState *env;
+    struct pxa2xx_pic_state_s *pic;
+    struct pxa2xx_dma_state_s *dma;
+    struct pxa2xx_gpio_info_s *gpio;
+    struct pxa2xx_ssp_s **ssp;
+    struct pxa2xx_i2c_s *i2c[2];
+    struct pxa2xx_i2s_s *i2s;
+    struct pxa2xx_fir_s *fir;
+
+    /* Power management */
+    target_phys_addr_t pm_base;
+    uint32_t pm_regs[0x40];
+
+    /* Clock management */
+    target_phys_addr_t cm_base;
+    uint32_t cm_regs[4];
+    uint32_t clkcfg;
+
+    /* Memory management */
+    target_phys_addr_t mm_base;
+    uint32_t mm_regs[0x1a];
+
+    /* Performance monitoring */
+    uint32_t pmnc;
+
+    /* Real-Time clock */
+    target_phys_addr_t rtc_base;
+    uint32_t rttr;
+    uint32_t rtsr;
+    uint32_t rtar;
+    uint32_t rdar1;
+    uint32_t rdar2;
+    uint32_t ryar1;
+    uint32_t ryar2;
+    uint32_t swar1;
+    uint32_t swar2;
+    uint32_t piar;
+    uint32_t last_rcnr;
+    uint32_t last_rdcr;
+    uint32_t last_rycr;
+    uint32_t last_swcr;
+    uint32_t last_rtcpicr;
+    int64_t last_hz;
+    int64_t last_sw;
+    int64_t last_pi;
+    QEMUTimer *rtc_hz;
+    QEMUTimer *rtc_rdal1;
+    QEMUTimer *rtc_rdal2;
+    QEMUTimer *rtc_swal1;
+    QEMUTimer *rtc_swal2;
+    QEMUTimer *rtc_pi;
+};
+
+struct pxa2xx_i2c_s {
+    target_phys_addr_t base;
+    int irq;
+    struct pxa2xx_pic_state_s *pic;
+    struct i2c_master_s master;
+    struct i2c_slave_s slave;
+
+    uint16_t control;
+    uint16_t status;
+    uint8_t ibmr;
+};
+
+struct pxa2xx_i2s_s {
+    target_phys_addr_t base;
+    int irq;
+    struct pxa2xx_dma_state_s *dma;
+    struct pxa2xx_pic_state_s *pic;
+    void (*data_req)(void *, int, int);
+
+    uint32_t control[2];
+    uint32_t status;
+    uint32_t mask;
+    uint32_t clk;
+
+    int enable;
+    int rx_len;
+    int tx_len;
+    void (*codec_out)(void *, uint32_t);
+    uint32_t (*codec_in)(void *);
+    void *opaque;
+
+    int fifo_len;
+    uint32_t fifo[16];
+};
+
+# define PA_FMT			"0x%08lx"
+# define REG_FMT		"0x%lx"
+
+struct pxa2xx_state_s *pxa270_init(DisplayState *ds, const char *revision);
+struct pxa2xx_state_s *pxa255_init(DisplayState *ds);
+
+void pxa2xx_reset(int line, int level, void *opaque);
+
+#endif	/* PXA_H */
hw/pxa2xx.c new file +1875 -0

1,875 lines not on this page · raw message

hw/pxa2xx_dma.c new file +500 -0

500 lines not on this page · raw message

hw/pxa2xx_gpio.c new file +290 -0

290 lines not on this page · raw message

hw/pxa2xx_pic.c new file +284 -0

143 lines not on this page · raw message

target-arm/cpu.h +33 -4
index 68bf3fd..738bb3a 100644

Lines of this file are not shown. View the raw message.

target-arm/exec.h +2 -0
index deba893..af06f48 100644

Lines of this file are not shown. View the raw message.

target-arm/helper.c +138 -12

150 lines not on this page · raw message

target-arm/op.c +13 -1
index f17b812..9cfb462 100644

Lines of this file are not shown. View the raw message.

target-arm/translate.c +32 -0
index 055ccfa..24e8eee 100644

Lines of this file are not shown. View the raw message.

vl.h +2 -0
index b30fb87..563f437 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.4.4.3

Part of the diff is not shown here. View the raw message.

#1 lore raw
Quoted 9 lines · andrzej zaborowski

Implements basic differences between XScale and plain ARM. The patch also adds the main on-chip peripherals of PXA2xx: interrupt controller, DMA, GPIO controller, SSP, I2C, I2S busses, UARTs, FIR port, RTC, Clock/Power/Memory managers.

Cheers,
Andrew

interesting (I haven't tested it yet)...

how to use this patch ? beside the "-portrait" extra switch, applying this patch would make arm-softmmu a pxa2xx by default ?

if so, it's very interesting: I've an ipaq (H2210) and I was taking part of a port of linux on it. One big drawback then is that I burned a few SD cards to get a kernel working, but this patch could be a good fix to my problems...

Do I just need the 2 emails with pxa2xx patches ? or is there more needed ?

Last, but not least: do you think we could emulate a windows CE pocketpc in this way ?

Signature · 1 line
Christian
#2 lore raw

Hi,

Quoted 11 lines · Christian MICHON
Quoted 9 lines · andrzej zaborowski

Implements basic differences between XScale and plain ARM. The patch also adds the main on-chip peripherals of PXA2xx: interrupt controller, DMA, GPIO controller, SSP, I2C, I2S busses, UARTs, FIR port, RTC, Clock/Power/Memory managers.

Cheers,
Andrew

Quoted 4 lines

interesting (I haven't tested it yet)...

how to use this patch ? beside the "-portrait" extra switch, applying this patch would make arm-softmmu a pxa2xx by default ?

No, default is whatever the machine uses (-M). Use this patch together with the rest of the series.

Quoted 8 lines

if so, it's very interesting: I've an ipaq (H2210) and I was taking part of a port of linux on it. One big drawback then is that I burned a few SD cards to get a kernel working, but this patch could be a good fix to my problems...

Do I just need the 2 emails with pxa2xx patches ? or is there more needed ?

For PXA you need only the two patches. But PXA is only a processor and the processor alone is useless.

Quoted 3 lines

Last, but not least: do you think we could emulate a windows CE pocketpc in this way ?

See http://lists.gnu.org/archive/html/qemu-devel/2007-02/msg00109.html

Regards,
Andrew