lm32: Milkymist board support
cover lm32: Milkymist board support
This is the second (and last) patchset of the LatticeMico32 support. It adds almost complete support for the opensource and openhardware Milkymist One board [1].
PATCH 1/14 lm32: add Milkymist AC97 support
This patch adds support for the Milkymist AC97 compatible sound output and input core.
--- Makefile.target | 1 + configure | 3 + hw/milkymist-ac97.c | 335 +++++++++++++++++++++++++++++++++++++++++++++++++++ trace-events | 12 ++ 4 files changed, 351 insertions(+), 0 deletions(-) create mode 100644 hw/milkymist-ac97.c
Makefile.target +1 -0
@@ -256,6 +256,7 @@ obj-lm32-y += lm32_juart.o obj-lm32-y += lm32_timer.o obj-lm32-y += lm32_uart.o obj-lm32-y += lm32_sys.o +obj-lm32-y += milkymist-ac97.o obj-mips-y = mips_r4k.o mips_jazz.o mips_malta.o mips_mipssim.o obj-mips-y += mips_addr.o mips_timer.o mips_int.o
configure +3 -0
@@ -3281,6 +3281,9 @@ if test "$target_softmmu" = "yes" ; then arm) cflags="-DHAS_AUDIO $cflags" ;; + lm32) + cflags="-DHAS_AUDIO $cflags" + ;; i386|mips|ppc) cflags="-DHAS_AUDIO -DHAS_AUDIO_CHOICE $cflags" ;;
hw/milkymist-ac97.c new file +335 -0
335 lines not on this page · raw message
trace-events +12 -0
@@ -283,3 +283,15 @@ disable lm32_uart_irq_state(int level) "irq state %d" # hw/lm32_sys.c disable lm32_sys_memory_write(uint32_t addr, uint32_t value) "addr 0x%08x value 0x%08x" + +# hw/milkymist-ac97.c +disable milkymist_ac97_memory_read(uint32_t addr, uint32_t value) "addr %08x value %08x" +disable milkymist_ac97_memory_write(uint32_t addr, uint32_t value) "addr %08x value %08x" +disable milkymist_ac97_pulse_irq_crrequest(void) "Pulse IRQ CR request" +disable milkymist_ac97_pulse_irq_crreply(void) "Pulse IRQ CR reply" +disable milkymist_ac97_pulse_irq_dmaw(void) "Pulse IRQ DMA write" +disable milkymist_ac97_pulse_irq_dmar(void) "Pulse IRQ DMA read" +disable milkymist_ac97_in_cb(int avail, uint32_t remaining) "avail %d remaining %u" +disable milkymist_ac97_in_cb_transferred(int transferred) "transferred %d" +disable milkymist_ac97_out_cb(int free, uint32_t remaining) "free %d remaining %u" +disable milkymist_ac97_out_cb_transferred(int transferred) "transferred %d"
Signature · 1 line
1.7.2.3
[Qemu-devel] Re: [PATCH 01/14] lm32: add Milkymist AC97 support
Quoted 2 lines · Michael Walle
This patch adds support for the Milkymist AC97 compatible sound output and input core.
Malc, could you please take a look at this? :)
Quoted 396 lines
Signed-off-by Michael Walle<[email protected]>--- Makefile.target | 1 + configure | 3 + hw/milkymist-ac97.c | 335 +++++++++++++++++++++++++++++++++++++++++++++++++++ trace-events | 12 ++ 4 files changed, 351 insertions(+), 0 deletions(-)create mode 100644
hw/milkymist-ac97.cMakefile.target +1
-0@@ -256,6 +256,7 @@ obj-lm32-y += lm32_juart.o obj-lm32-y += lm32_timer.o obj-lm32-y += lm32_uart.o obj-lm32-y += lm32_sys.o +obj-lm32-y += milkymist-ac97.o obj-mips-y = mips_r4k.o mips_jazz.o mips_malta.o mips_mipssim.o obj-mips-y += mips_addr.o mips_timer.o mips_int.oconfigure +3
-0@@ -3281,6 +3281,9 @@ if test "$target_softmmu" = "yes" ; then arm) cflags="-DHAS_AUDIO $cflags" ;; + lm32) + cflags="-DHAS_AUDIO $cflags" + ;; i386|mips|ppc) cflags="-DHAS_AUDIO -DHAS_AUDIO_CHOICE $cflags" ;;hw/milkymist-ac97.c new file +335
-0@@ -0,0 +1,335 @@ +/* +* QEMU model of the Milkymist System Controller. +* +* Copyright (c) 2010 Michael Walle<[email protected]> +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library 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 +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, see<http://www.gnu.org/licenses/>. +* +* +* Specification available at: +* http://www.milkymist.org/socdoc/ac97.pdf +*/ + +#include "hw.h" +#include "sysbus.h" +#include "trace.h" +#include "audio/audio.h" +#include "qemu-error.h" + +enum { +R_AC97_CTRL =0 , +R_AC97_ADDR , +R_AC97_DATAOUT , +R_AC97_DATAIN , +R_D_CTRL , +R_D_ADDR , +R_D_REMAINING , +R_RESERVED , +R_U_CTRL , +R_U_ADDR , +R_U_REMAINING , +R_MAX +}; + +enum { +AC97_CTRL_RQEN = (1 <<0 ), +AC97_CTRL_WRITE = (1 <<1 ), +}; + +enum { +CTRL_EN = (1 <<0 ), +}; + +struct MilkymistAC97State { +SysBusDevice busdev; + +QEMUSoundCard card; +SWVoiceIn *voice_in; +SWVoiceOut *voice_out; + +uint32_t regs[R_MAX ]; + +qemu_irq crrequest_irq; +qemu_irq crreply_irq; +qemu_irq dmar_irq; +qemu_irq dmaw_irq; +}; +typedef struct MilkymistAC97State MilkymistAC97State ; + +static void update_voices (MilkymistAC97State *s) +{ +if (s->regs[R_D_CTRL ]&CTRL_EN ) { +AUD_set_active_out (s->voice_out,1 ); + }else { +AUD_set_active_out (s->voice_out,0 ); + } + +if (s->regs[R_U_CTRL ]&CTRL_EN ) { +AUD_set_active_in (s->voice_in,1 ); + }else { +AUD_set_active_in (s->voice_in,0 ); + } +} + +static uint32_t ac97_read (void *opaque,target_phys_addr_t addr) +{ +MilkymistAC97State *s = opaque; +uint32_t r =0 ; + + addr>>=2 ; +switch (addr) { +case R_AC97_CTRL : +case R_AC97_ADDR : +case R_AC97_DATAOUT : +case R_AC97_DATAIN : +case R_D_CTRL : +case R_D_ADDR : +case R_D_REMAINING : +case R_U_CTRL : +case R_U_ADDR : +case R_U_REMAINING : + r = s->regs[addr]; +break ; + +default : +error_report ("milkymist_ac97: read access to unkown register 0x" + TARGET_FMT_plx, addr<<2 ); +break ; + } + +trace_milkymist_ac97_memory_read (addr<<2 , r); + +return r; +} + +static void ac97_write (void *opaque,target_phys_addr_t addr,uint32_t value) +{ +MilkymistAC97State *s = opaque; + +trace_milkymist_ac97_memory_write (addr, value); + + addr>>=2 ; +switch (addr) { +case R_AC97_CTRL : +/* always raise an IRQ according to the direction */ +if (value&AC97_CTRL_RQEN ) { +if (value&AC97_CTRL_WRITE ) { +trace_milkymist_ac97_pulse_irq_crrequest (); +qemu_irq_pulse (s->crrequest_irq); + }else { +trace_milkymist_ac97_pulse_irq_crreply (); +qemu_irq_pulse (s->crreply_irq); + } + } + +/* RQEN is self clearing */ + s->regs[addr] = value& ~AC97_CTRL_RQEN ; +break ; +case R_D_CTRL : +case R_U_CTRL : + s->regs[addr] = value; +update_voices (s); +break ; +case R_AC97_ADDR : +case R_AC97_DATAOUT : +case R_AC97_DATAIN : +case R_D_ADDR : +case R_D_REMAINING : +case R_U_ADDR : +case R_U_REMAINING : + s->regs[addr] = value; +break ; + +default : +error_report ("milkymist_ac97: write access to unkown register 0x" + TARGET_FMT_plx, addr); +break ; + } + +} + +static CPUReadMemoryFunc *const ac97_read_fn[] = { +NULL , +NULL , +&ac97_read, +}; + +static CPUWriteMemoryFunc *const ac97_write_fn[] = { +NULL , +NULL , +&ac97_write, +}; + +static void ac97_in_cb (void *opaque,int avail_b) +{ +MilkymistAC97State *s = opaque; +uint8_t buf[4096 ]; +uint32_t remaining = s->regs[R_U_REMAINING ]; +int temp =audio_MIN (remaining, avail_b); +uint32_t addr = s->regs[R_U_ADDR ]; +int transferred =0 ; + +trace_milkymist_ac97_in_cb (avail_b, remaining); + +/* prevent from raising an IRQ */ +if (temp ==0 ) { +return ; + } + +while (temp) { +int acquired, to_copy; + + to_copy =audio_MIN (temp,sizeof (buf)); + acquired =AUD_read (s->voice_in, buf, to_copy); +if (!acquired) { +break ; + } + +cpu_physical_memory_write (addr, buf, acquired); + + temp -= acquired; + addr += acquired; + transferred += acquired; + } + +trace_milkymist_ac97_in_cb_transferred (transferred); + + s->regs[R_U_ADDR ] = addr; + s->regs[R_U_REMAINING ] -= transferred; + +if ((s->regs[R_U_CTRL ]&CTRL_EN )&& (s->regs[R_U_REMAINING ] ==0 )) { +trace_milkymist_ac97_pulse_irq_dmaw (); +qemu_irq_pulse (s->dmaw_irq); + } +} + +static void ac97_out_cb (void *opaque,int free_b) +{ +MilkymistAC97State *s = opaque; +uint8_t buf[4096 ]; +uint32_t remaining = s->regs[R_D_REMAINING ]; +int temp =audio_MIN (remaining, free_b); +uint32_t addr = s->regs[R_D_ADDR ]; +int transferred =0 ; + +trace_milkymist_ac97_out_cb (free_b, remaining); + +/* prevent from raising an IRQ */ +if (temp ==0 ) { +return ; + } + +while (temp) { +int copied, to_copy; + + to_copy =audio_MIN (temp,sizeof (buf)); +cpu_physical_memory_read (addr, buf, to_copy); + copied =AUD_write (s->voice_out, buf, to_copy); +if (!copied) { +break ; + } + temp -= copied; + addr += copied; + transferred += copied; + } + +trace_milkymist_ac97_out_cb_transferred (transferred); + + s->regs[R_D_ADDR ] = addr; + s->regs[R_D_REMAINING ] -= transferred; + +if ((s->regs[R_D_CTRL ]&CTRL_EN )&& (s->regs[R_D_REMAINING ] ==0 )) { +trace_milkymist_ac97_pulse_irq_dmar (); +qemu_irq_pulse (s->dmar_irq); + } +} + +static void milkymist_ac97_reset (DeviceState *d) +{ +MilkymistAC97State *s =container_of (d, MilkymistAC97State, busdev.qdev); +int i; + +for (i =0 ; i<R_MAX ; i++) { + s->regs[i] =0 ; + } + +AUD_set_active_in (s->voice_in,0 ); +AUD_set_active_out (s->voice_out,0 ); +} + +static int ac97_post_load (void *opaque,int version_id) +{ +MilkymistAC97State *s = opaque; + +update_voices (s); + +return 0 ; +} + +static int milkymist_ac97_init (SysBusDevice *dev) +{ +MilkymistAC97State *s =FROM_SYSBUS (typeof (*s), dev); +int ac97_regs; + +struct audsettings as; +sysbus_init_irq (dev,&s->crrequest_irq); +sysbus_init_irq (dev,&s->crreply_irq); +sysbus_init_irq (dev,&s->dmar_irq); +sysbus_init_irq (dev,&s->dmaw_irq); + +AUD_register_card ("Milkymist AC'97" ,&s->card); + + as.freq =48000 ; + as.nchannels =2 ; + as.fmt =AUD_FMT_S16 ; + as.endianness =1 ; + + s->voice_in =AUD_open_in (&s->card, s->voice_in, +"mm_ac97.in" , s, ac97_in_cb,&as); + s->voice_out =AUD_open_out (&s->card, s->voice_out, +"mm_ac97.out" , s, ac97_out_cb,&as); + + ac97_regs =cpu_register_io_memory (ac97_read_fn, ac97_write_fn, s, +DEVICE_NATIVE_ENDIAN ); +sysbus_init_mmio (dev,R_MAX *4 , ac97_regs); + +return 0 ; +} + +static const VMStateDescription vmstate_milkymist_ac97 = { + .name ="milkymist-ac97" , + .version_id =1 , + .minimum_version_id =1 , + .minimum_version_id_old =1 , + .post_load = ac97_post_load, + .fields = (VMStateField []) { +VMSTATE_UINT32_ARRAY (regs, MilkymistAC97State,R_MAX ), +VMSTATE_END_OF_LIST () + } +}; + +static SysBusDeviceInfo milkymist_ac97_info = { + .init = milkymist_ac97_init, + .qdev.name ="milkymist-ac97" , + .qdev.size =sizeof (MilkymistAC97State), + .qdev.vmsd =&vmstate_milkymist_ac97, + .qdev.reset = milkymist_ac97_reset, +}; + +static void milkymist_ac97_register (void ) +{ +sysbus_register_withprop (&milkymist_ac97_info); +} + +device_init (milkymist_ac97_register)trace-events +12
-0@@ -283,3 +283,15 @@ disable lm32_uart_irq_state(int level) "irq state %d" # hw/lm32_sys.c disable lm32_sys_memory_write(uint32_t addr, uint32_t value) "addr 0x%08x value 0x%08x" + +# hw/milkymist-ac97.c +disable milkymist_ac97_memory_read(uint32_t addr, uint32_t value) "addr %08x value %08x" +disable milkymist_ac97_memory_write(uint32_t addr, uint32_t value) "addr %08x value %08x" +disable milkymist_ac97_pulse_irq_crrequest(void) "Pulse IRQ CR request" +disable milkymist_ac97_pulse_irq_crreply(void) "Pulse IRQ CR reply" +disable milkymist_ac97_pulse_irq_dmaw(void) "Pulse IRQ DMA write" +disable milkymist_ac97_pulse_irq_dmar(void) "Pulse IRQ DMA read" +disable milkymist_ac97_in_cb(int avail, uint32_t remaining) "avail %d remaining %u" +disable milkymist_ac97_in_cb_transferred(int transferred) "transferred %d" +disable milkymist_ac97_out_cb(int free, uint32_t remaining) "free %d remaining %u" +disable milkymist_ac97_out_cb_transferred(int transferred) "transferred %d"
[Qemu-devel] Re: [PATCH 01/14] lm32: add Milkymist AC97 support
Quoted 5 lines · Alexander Graf
Quoted 2 lines · Michael Walle
This patch adds support for the Milkymist AC97 compatible sound output and input core.
Malc, could you please take a look at this? :)
Okay...
Quoted 67 lines
Quoted 67 lines
Signed-off-by Michael Walle<[email protected]>--- Makefile.target | 1 + configure | 3 + hw/milkymist-ac97.c | 335 +++++++++++++++++++++++++++++++++++++++++++++++++++ trace-events | 12 ++ 4 files changed, 351 insertions(+), 0 deletions(-)create mode 100644
hw/milkymist-ac97.cMakefile.target +1
-0@@ -256,6 +256,7 @@ obj-lm32-y += lm32_juart.o obj-lm32-y += lm32_timer.o obj-lm32-y += lm32_uart.o obj-lm32-y += lm32_sys.o +obj-lm32-y += milkymist-ac97.o obj-mips-y = mips_r4k.o mips_jazz.o mips_malta.o mips_mipssim.o obj-mips-y += mips_addr.o mips_timer.o mips_int.oconfigure +3
-0@@ -3281,6 +3281,9 @@ if test "$target_softmmu" = "yes" ; then arm) cflags="-DHAS_AUDIO $cflags" ;; + lm32) + cflags="-DHAS_AUDIO $cflags" + ;; i386|mips|ppc) cflags="-DHAS_AUDIO -DHAS_AUDIO_CHOICE $cflags" ;;hw/milkymist-ac97.c new file +17
-0@@ -0,0 +1,335 @@ +/* +* QEMU model of the Milkymist System Controller. +* +* Copyright (c) 2010 Michael Walle<[email protected]> +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library 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 +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, see<http://www.gnu.org/licenses/>.
+ *
+ *
+ * Specification available at:
+ * http://www.milkymist.org/socdoc/ac97.pdf
+ */
+
Quoted 8 lines
hw/milkymist-ac97.c line 31
Quoted 8 lines
hw/milkymist-ac97.c new file +8
-0+#include "hw.h" +#include "sysbus.h" +#include "trace.h" +#include "audio/audio.h" +#include "qemu-error.h" + +enum { +R_AC97_CTRL =0 ,
Unneeded..
Quoted 7 lines
Quoted 7 lines
hw/milkymist-ac97.c new file +7
-0+R_AC97_ADDR , +R_AC97_DATAOUT , +R_AC97_DATAIN , +R_D_CTRL , +R_D_ADDR , +R_D_REMAINING , + R_RESERVED,
Quoted 8 lines
hw/milkymist-ac97.c line 46
Quoted 8 lines
hw/milkymist-ac97.c new file +8
-0+R_U_CTRL , +R_U_ADDR , +R_U_REMAINING , +R_MAX +}; + +enum { + AC97_CTRL_RQEN = (1<<0),
Oookay..
Quoted 1 line
Quoted 1 line
+
AC97_CTRL_WRITE= (1<<1),
Incinsistent(with previous enum formatting) comma (and C99 only at that)
Quoted 4 lines
hw/milkymist-ac97.c line 51
Quoted 4 lines
hw/milkymist-ac97.c new file +4
-0+}; + +enum { +CTRL_EN = (1 <<0 ),
Ditto x2
Quoted 13 lines
Quoted 13 lines
hw/milkymist-ac97.c new file +13
-0+}; + +struct MilkymistAC97State { +SysBusDevice busdev; + +QEMUSoundCard card; +SWVoiceIn *voice_in; +SWVoiceOut *voice_out; + +uint32_t regs[R_MAX ]; + +qemu_irq crrequest_irq; +qemu_irq crreply_irq;
Quoted 8 lines
hw/milkymist-ac97.c
Quoted 8 lines
hw/milkymist-ac97.c new file +8
-0+qemu_irq dmar_irq; +qemu_irq dmaw_irq; +}; +typedef struct MilkymistAC97State MilkymistAC97State ; + +static void update_voices (MilkymistAC97State *s) +{ +if (s->regs[R_D_CTRL ]&CTRL_EN ) {
Space before ampersand would be nice.
Quoted 10 lines
Quoted 10 lines
hw/milkymist-ac97.c new file +10
-0+AUD_set_active_out (s->voice_out,1 ); + }else { +AUD_set_active_out (s->voice_out,0 ); + } + +if (s->regs[R_U_CTRL ]&CTRL_EN ) { +AUD_set_active_in (s->voice_in,1 ); + }else { +AUD_set_active_in (s->voice_in,0 ); + }
Quoted 8 lines
hw/milkymist-ac97.c
Quoted 8 lines
hw/milkymist-ac97.c new file +8
-0+} + +static uint32_t ac97_read (void *opaque,target_phys_addr_t addr) +{ +MilkymistAC97State *s = opaque; +uint32_t r =0 ; + + addr>>=2 ;
Again space here and elsewhere.
Quoted 264 lines
Quoted 264 lines
hw/milkymist-ac97.c new file +26
-0+switch (addr) { +case R_AC97_CTRL : +case R_AC97_ADDR : +case R_AC97_DATAOUT : +case R_AC97_DATAIN : +case R_D_CTRL : +case R_D_ADDR : +case R_D_REMAINING : +case R_U_CTRL : +case R_U_ADDR : +case R_U_REMAINING : + r = s->regs[addr]; +break ; + +default : +error_report ("milkymist_ac97: read access to unkown register 0x" + TARGET_FMT_plx, addr<<2 ); +break ; + } + +trace_milkymist_ac97_memory_read (addr<<2 , r); + +return r; +} + +static void ac97_write(void *opaque, target_phys_addr_t addr, uint32_tvalue)
hw/milkymist-ac97.c new file +144
-0+{ +MilkymistAC97State *s = opaque; + +trace_milkymist_ac97_memory_write (addr, value); + + addr>>=2 ; +switch (addr) { +case R_AC97_CTRL : +/* always raise an IRQ according to the direction */ +if (value&AC97_CTRL_RQEN ) { +if (value&AC97_CTRL_WRITE ) { +trace_milkymist_ac97_pulse_irq_crrequest (); +qemu_irq_pulse (s->crrequest_irq); + }else { +trace_milkymist_ac97_pulse_irq_crreply (); +qemu_irq_pulse (s->crreply_irq); + } + } + +/* RQEN is self clearing */ + s->regs[addr] = value& ~AC97_CTRL_RQEN ; +break ; +case R_D_CTRL : +case R_U_CTRL : + s->regs[addr] = value; +update_voices (s); +break ; +case R_AC97_ADDR : +case R_AC97_DATAOUT : +case R_AC97_DATAIN : +case R_D_ADDR : +case R_D_REMAINING : +case R_U_ADDR : +case R_U_REMAINING : + s->regs[addr] = value; +break ; + +default : +error_report ("milkymist_ac97: write access to unkown register 0x" + TARGET_FMT_plx, addr); +break ; + } + +} + +static CPUReadMemoryFunc *const ac97_read_fn[] = { +NULL , +NULL , +&ac97_read, +}; + +static CPUWriteMemoryFunc *const ac97_write_fn[] = { +NULL , +NULL , +&ac97_write, +}; + +static void ac97_in_cb (void *opaque,int avail_b) +{ +MilkymistAC97State *s = opaque; +uint8_t buf[4096 ]; +uint32_t remaining = s->regs[R_U_REMAINING ]; +int temp =audio_MIN (remaining, avail_b); +uint32_t addr = s->regs[R_U_ADDR ]; +int transferred =0 ; + +trace_milkymist_ac97_in_cb (avail_b, remaining); + +/* prevent from raising an IRQ */ +if (temp ==0 ) { +return ; + } + +while (temp) { +int acquired, to_copy; + + to_copy =audio_MIN (temp,sizeof (buf)); + acquired =AUD_read (s->voice_in, buf, to_copy); +if (!acquired) { +break ; + } + +cpu_physical_memory_write (addr, buf, acquired); + + temp -= acquired; + addr += acquired; + transferred += acquired; + } + +trace_milkymist_ac97_in_cb_transferred (transferred); + + s->regs[R_U_ADDR ] = addr; + s->regs[R_U_REMAINING ] -= transferred; + +if ((s->regs[R_U_CTRL ]&CTRL_EN )&& (s->regs[R_U_REMAINING ] ==0 )) { +trace_milkymist_ac97_pulse_irq_dmaw (); +qemu_irq_pulse (s->dmaw_irq); + } +} + +static void ac97_out_cb (void *opaque,int free_b) +{ +MilkymistAC97State *s = opaque; +uint8_t buf[4096 ]; +uint32_t remaining = s->regs[R_D_REMAINING ]; +int temp =audio_MIN (remaining, free_b); +uint32_t addr = s->regs[R_D_ADDR ]; +int transferred =0 ; + +trace_milkymist_ac97_out_cb (free_b, remaining); + +/* prevent from raising an IRQ */ +if (temp ==0 ) { +return ; + } + +while (temp) { +int copied, to_copy; + + to_copy =audio_MIN (temp,sizeof (buf)); +cpu_physical_memory_read (addr, buf, to_copy); + copied =AUD_write (s->voice_out, buf, to_copy); +if (!copied) { +break ; + } + temp -= copied; + addr += copied; + transferred += copied; + } + +trace_milkymist_ac97_out_cb_transferred (transferred); + + s->regs[R_D_ADDR ] = addr; + s->regs[R_D_REMAINING ] -= transferred; + +if ((s->regs[R_D_CTRL ]&CTRL_EN )&& (s->regs[R_D_REMAINING ] ==0 )) { +trace_milkymist_ac97_pulse_irq_dmar (); +qemu_irq_pulse (s->dmar_irq); + } +} + +static void milkymist_ac97_reset (DeviceState *d) +{ + MilkymistAC97State *s = container_of(d, MilkymistAC97State,busdev.qdev);
hw/milkymist-ac97.c new file +75
-0+int i; + +for (i =0 ; i<R_MAX ; i++) { + s->regs[i] =0 ; + } + +AUD_set_active_in (s->voice_in,0 ); +AUD_set_active_out (s->voice_out,0 ); +} + +static int ac97_post_load (void *opaque,int version_id) +{ +MilkymistAC97State *s = opaque; + +update_voices (s); + +return 0 ; +} + +static int milkymist_ac97_init (SysBusDevice *dev) +{ +MilkymistAC97State *s =FROM_SYSBUS (typeof (*s), dev); +int ac97_regs; + +struct audsettings as; +sysbus_init_irq (dev,&s->crrequest_irq); +sysbus_init_irq (dev,&s->crreply_irq); +sysbus_init_irq (dev,&s->dmar_irq); +sysbus_init_irq (dev,&s->dmaw_irq); + +AUD_register_card ("Milkymist AC'97" ,&s->card); + + as.freq =48000 ; + as.nchannels =2 ; + as.fmt =AUD_FMT_S16 ; + as.endianness =1 ; + + s->voice_in =AUD_open_in (&s->card, s->voice_in, +"mm_ac97.in" , s, ac97_in_cb,&as); + s->voice_out =AUD_open_out (&s->card, s->voice_out, +"mm_ac97.out" , s, ac97_out_cb,&as); + + ac97_regs =cpu_register_io_memory (ac97_read_fn, ac97_write_fn, s, +DEVICE_NATIVE_ENDIAN ); +sysbus_init_mmio (dev,R_MAX *4 , ac97_regs); + +return 0 ; +} + +static const VMStateDescription vmstate_milkymist_ac97 = { + .name ="milkymist-ac97" , + .version_id =1 , + .minimum_version_id =1 , + .minimum_version_id_old =1 , + .post_load = ac97_post_load, + .fields = (VMStateField []) { +VMSTATE_UINT32_ARRAY (regs, MilkymistAC97State,R_MAX ), +VMSTATE_END_OF_LIST () + } +}; + +static SysBusDeviceInfo milkymist_ac97_info = { + .init = milkymist_ac97_init, + .qdev.name ="milkymist-ac97" , + .qdev.size =sizeof (MilkymistAC97State), + .qdev.vmsd =&vmstate_milkymist_ac97, + .qdev.reset = milkymist_ac97_reset, +}; + +static void milkymist_ac97_register (void ) +{ +sysbus_register_withprop (&milkymist_ac97_info); +} + +device_init (milkymist_ac97_register)trace-events +0
-0@@ -283,3 +283,15 @@ disable lm32_uart_irq_state(int level) "irq state %d" # hw/lm32_sys.c disable lm32_sys_memory_write(uint32_t addr, uint32_t value) "addr 0x%08xvalue 0x%08x"
trace-events +3
-0+ +# hw/milkymist-ac97.c +disable milkymist_ac97_memory_read(uint32_t addr, uint32_t value) "addr%08x value %08x"
+disablemilkymist_ac97_memory_write(uint32_t addr, uint32_t value)"addr %08x value %08x"trace-events +2
-0+disable milkymist_ac97_pulse_irq_crrequest(void) "Pulse IRQ CR request" +disable milkymist_ac97_pulse_irq_crreply(void) "Pulse IRQ CR reply"
Quoted 9 lines
Quoted 8 lines
trace-events +3
-0+disable milkymist_ac97_pulse_irq_dmaw(void) "Pulse IRQ DMA write" +disable milkymist_ac97_pulse_irq_dmar(void) "Pulse IRQ DMA read" +disable milkymist_ac97_in_cb(int avail, uint32_t remaining) "avail %dremaining %u"
trace-events +2
-0+disable milkymist_ac97_in_cb_transferred(int transferred) "transferred %d" +disable milkymist_ac97_out_cb(int free, uint32_t remaining) "free %dremaining %u"
+disablemilkymist_ac97_out_cb_transferred(int transferred)"transferred %d"
IOW looks good to me.
Signature · 1 line
mailto:[email protected]
[Qemu-devel] Re: [PATCH 01/14] lm32: add Milkymist AC97 support
Am Mittwoch 16 März 2011, 19:12:44 schrieb malc:
Quoted 32 lines
Quoted 32 lines
Quoted 32 lines
hw/milkymist-ac97.c new file +17
-0@@ -0,0 +1,335 @@ +/* +* QEMU model of the Milkymist System Controller. +* +* Copyright (c) 2010 Michael Walle<[email protected]> +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library 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 +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, see<http://www.gnu.org/licenses/>.
+ *
+ *
+ * Specification available at:
+ * http://www.milkymist.org/socdoc/ac97.pdf
+ */hw/milkymist-ac97.c new file +3
-0+ +#include "hw.h" +#include "sysbus.h"
Quoted 8 lines
Quoted 6 lines
hw/milkymist-ac97.c line 31
Quoted 6 lines
hw/milkymist-ac97.c new file +6
-0+#include "trace.h" +#include "audio/audio.h" +#include "qemu-error.h" + +enum { +R_AC97_CTRL =0 ,Unneeded..
I wanted to point out, that the registers begin at offset 0. If i change this, i'll need to change all other models, too. Including the ones that have been committed.
Quoted 20 lines
Quoted 7 lines
Quoted 7 lines
hw/milkymist-ac97.c new file +7
-0+R_AC97_ADDR , +R_AC97_DATAOUT , +R_AC97_DATAIN , +R_D_CTRL , +R_D_ADDR , +R_D_REMAINING , + R_RESERVED,Quoted 8 lines
hw/milkymist-ac97.c line 46
Quoted 8 lines
hw/milkymist-ac97.c new file +8
-0+R_U_CTRL , +R_U_ADDR , +R_U_REMAINING , +R_MAX +}; + +enum { + AC97_CTRL_RQEN = (1<<0),Oookay..
Quoted 1 line
Quoted 1 line
+
AC97_CTRL_WRITE= (1<<1),
Quoted 8 lines
Incinsistent(with previous enum formatting) comma (and C99 only at that)
Quoted 4 lines
hw/milkymist-ac97.c line 51
Quoted 4 lines
hw/milkymist-ac97.c new file +4
-0+}; + +enum { +CTRL_EN = (1 <<0 ),Ditto x2
Ok, but it has a hidden agenda. R_MAX must always be the last entry, therefore i omitted the comma. Whereas the bit flags could still be extended. Again if this is a concern for you, i'll change that and all other models too.
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
hw/milkymist-ac97.c new file +15
-0+}; + +struct MilkymistAC97State { +SysBusDevice busdev; + +QEMUSoundCard card; +SWVoiceIn *voice_in; +SWVoiceOut *voice_out; + +uint32_t regs[R_MAX ]; + +qemu_irq crrequest_irq; +qemu_irq crreply_irq; +qemu_irq dmar_irq; +qemu_irq dmaw_irq;
Quoted 8 lines
Quoted 6 lines
hw/milkymist-ac97.c
Quoted 6 lines
hw/milkymist-ac97.c new file +6
-0+}; +typedef struct MilkymistAC97State MilkymistAC97State ; + +static void update_voices (MilkymistAC97State *s) +{ +if (s->regs[R_D_CTRL ]&CTRL_EN ) {Space before ampersand would be nice.
mh i think Alex email client messed this up. At least for me, there is one space before and one space after the ampersand in my original email.
Signature · 1 line
Michael
[Qemu-devel] Re: [PATCH 01/14] lm32: add Milkymist AC97 support
Quoted 100 lines · Michael Walle
Am Mittwoch 16 März 2011, 19:12:44 schrieb malc:
Quoted 32 lines
Quoted 32 lines
Quoted 32 lines
hw/milkymist-ac97.c new file +17
-0@@ -0,0 +1,335 @@ +/* +* QEMU model of the Milkymist System Controller. +* +* Copyright (c) 2010 Michael Walle<[email protected]> +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library 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 +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, see<http://www.gnu.org/licenses/>.
+ *
+ *
+ * Specification available at:
+ * http://www.milkymist.org/socdoc/ac97.pdf
+ */hw/milkymist-ac97.c new file +3
-0+ +#include "hw.h" +#include "sysbus.h" Quoted 8 lines
Quoted 6 lines
hw/milkymist-ac97.c line 31
Quoted 6 lines
hw/milkymist-ac97.c new file +6
-0+#include "trace.h" +#include "audio/audio.h" +#include "qemu-error.h" + +enum { +R_AC97_CTRL =0 ,Unneeded..
I wanted to point out, that the registers begin at offset 0. If i change this, i'll need to change all other models, too. Including the ones that have been committed.
Quoted 20 lines
Quoted 7 lines
Quoted 7 lines
hw/milkymist-ac97.c new file +7
-0+R_AC97_ADDR , +R_AC97_DATAOUT , +R_AC97_DATAIN , +R_D_CTRL , +R_D_ADDR , +R_D_REMAINING , + R_RESERVED,Quoted 8 lines
hw/milkymist-ac97.c line 46
Quoted 8 lines
hw/milkymist-ac97.c new file +8
-0+R_U_CTRL , +R_U_ADDR , +R_U_REMAINING , +R_MAX +}; + +enum { + AC97_CTRL_RQEN = (1<<0),Oookay..
Quoted 1 line
Quoted 1 line
+
AC97_CTRL_WRITE= (1<<1),Quoted 8 lines
Incinsistent(with previous enum formatting) comma (and C99 only at that)
Quoted 4 lines
hw/milkymist-ac97.c line 51
Quoted 4 lines
hw/milkymist-ac97.c new file +4
-0+}; + +enum { +CTRL_EN = (1 <<0 ),Ditto x2
Ok, but it has a hidden agenda.
R_MAXmust always be the last entry, therefore i omitted the comma. Whereas the bit flags could still be extended. Again if this is a concern for you, i'll change that and all other models too.Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
hw/milkymist-ac97.c new file +15
-0+}; + +struct MilkymistAC97State { +SysBusDevice busdev; + +QEMUSoundCard card; +SWVoiceIn *voice_in; +SWVoiceOut *voice_out; + +uint32_t regs[R_MAX ]; + +qemu_irq crrequest_irq; +qemu_irq crreply_irq; +qemu_irq dmar_irq; +qemu_irq dmaw_irq;Quoted 8 lines
Quoted 6 lines
hw/milkymist-ac97.c
Quoted 6 lines
hw/milkymist-ac97.c new file +6
-0+}; +typedef struct MilkymistAC97State MilkymistAC97State ; + +static void update_voices (MilkymistAC97State *s) +{ +if (s->regs[R_D_CTRL ]&CTRL_EN ) {Space before ampersand would be nice.
Quoted 2 lines
mh i think Alex email client messed this up. At least for me, there is one space before and one space after the ampersand in my original email.
Yes, thunderbird breaks those. Sorry :).
Alex
Quoted 3 lines
Signature · 2 lines
-- Michael
[Qemu-devel] Re: [PATCH 01/14] lm32: add Milkymist AC97 support
In reply to Michael WalleQuoted 41 lines · Michael Walle
Am Mittwoch 16 M?rz 2011, 19:12:44 schrieb malc:
Quoted 32 lines
Quoted 32 lines
Quoted 32 lines
hw/milkymist-ac97.c new file +17
-0@@ -0,0 +1,335 @@ +/* +* QEMU model of the Milkymist System Controller. +* +* Copyright (c) 2010 Michael Walle<[email protected]> +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library 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 +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, see<http://www.gnu.org/licenses/>.
+ *
+ *
+ * Specification available at:
+ * http://www.milkymist.org/socdoc/ac97.pdf
+ */hw/milkymist-ac97.c new file +3
-0+ +#include "hw.h" +#include "sysbus.h" Quoted 8 lines
Quoted 6 lines
hw/milkymist-ac97.c line 31
Quoted 6 lines
hw/milkymist-ac97.c new file +6
-0+#include "trace.h" +#include "audio/audio.h" +#include "qemu-error.h" + +enum { +R_AC97_CTRL =0 ,Unneeded..
Quoted 3 lines
I wanted to point out, that the registers begin at offset 0. If i change this, i'll need to change all other models, too. Including the ones that have been committed.
And i just wanted to nitpick that it would be zero even without '= 0' part (6.7.2.2#3 of ISO/IEC 9899:201x)
Quoted 56 lines
Quoted 21 lines
Quoted 16 lines
Quoted 6 lines
hw/milkymist-ac97.c new file +5
-0+R_AC97_ADDR , +R_AC97_DATAOUT , +R_AC97_DATAIN , +R_D_CTRL , + R_D_ADDR,hw/milkymist-ac97.c line 46
Quoted 10 lines
hw/milkymist-ac97.c new file +10
-0+R_D_REMAINING , +R_RESERVED , +R_U_CTRL , +R_U_ADDR , +R_U_REMAINING , +R_MAX +}; + +enum { + AC97_CTRL_RQEN = (1<<0),Oookay..
Quoted 1 line
Quoted 1 line
+
AC97_CTRL_WRITE= (1<<1),Quoted 8 lines
Incinsistent(with previous enum formatting) comma (and C99 only at that)
Quoted 4 lines
hw/milkymist-ac97.c line 51
Quoted 4 lines
hw/milkymist-ac97.c new file +4
-0+}; + +enum { +CTRL_EN = (1 <<0 ),Ditto x2
Ok, but it has a hidden agenda.
R_MAXmust always be the last entry, therefore i omitted the comma. Whereas the bit flags could still be extended. Again if this is a concern for you, i'll change that and all other models too.Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
hw/milkymist-ac97.c new file +15
-0+}; + +struct MilkymistAC97State { +SysBusDevice busdev; + +QEMUSoundCard card; +SWVoiceIn *voice_in; +SWVoiceOut *voice_out; + +uint32_t regs[R_MAX ]; + +qemu_irq crrequest_irq; +qemu_irq crreply_irq; +qemu_irq dmar_irq; +qemu_irq dmaw_irq;Quoted 8 lines
Quoted 6 lines
hw/milkymist-ac97.c
Quoted 6 lines
hw/milkymist-ac97.c new file +6
-0+}; +typedef struct MilkymistAC97State MilkymistAC97State ; + +static void update_voices (MilkymistAC97State *s) +{ +if (s->regs[R_D_CTRL ]&CTRL_EN ) {Space before ampersand would be nice.
Quoted 3 lines
mh i think Alex email client messed this up. At least for me, there is one space before and one space after the ampersand in my original email.
Sorry for the noise then. (to Alexander: real men don't use crap MUA you use)
Signature · 1 line
mailto:[email protected]
PATCH 2/14 lm32: add Milkymist HPDMC support
In reply to Michael WalleThis patch adds support for the Milkymist's High Performance Dynamic Memory Controller. This is just a dumb model without any functionality. While the real hardware acts for example as a bridge between software and hardware for sending SDRAM commans, this model will only eat up these commands and always returns the expected hardware states, eg. PLL locked etc.
--- Makefile.target | 1 + hw/milkymist-hpdmc.c | 161 ++++++++++++++++++++++++++++++++++++++++++++++++++ trace-events | 4 + 3 files changed, 166 insertions(+), 0 deletions(-) create mode 100644 hw/milkymist-hpdmc.c
Makefile.target +1 -0
@@ -257,6 +257,7 @@ obj-lm32-y += lm32_timer.o obj-lm32-y += lm32_uart.o obj-lm32-y += lm32_sys.o obj-lm32-y += milkymist-ac97.o +obj-lm32-y += milkymist-hpdmc.o obj-mips-y = mips_r4k.o mips_jazz.o mips_malta.o mips_mipssim.o obj-mips-y += mips_addr.o mips_timer.o mips_int.o
hw/milkymist-hpdmc.c new file +161 -0
161 lines not on this page · raw message
trace-events +4 -0
@@ -295,3 +295,7 @@ disable milkymist_ac97_in_cb(int avail, uint32_t remaining) "avail %d remaining disable milkymist_ac97_in_cb_transferred(int transferred) "transferred %d" disable milkymist_ac97_out_cb(int free, uint32_t remaining) "free %d remaining %u" disable milkymist_ac97_out_cb_transferred(int transferred) "transferred %d" + +# hw/milkymist-hpdmc.c +disable milkymist_hpdmc_memory_read(uint32_t addr, uint32_t value) "addr %08x value %08x" +disable milkymist_hpdmc_memory_write(uint32_t addr, uint32_t value) "addr %08x value %08x"
Signature · 1 line
1.7.2.3
PATCH 3/14 lm32: add Milkymist memory card support
In reply to Michael WalleThis patch adds support for Milkymist's memory card core.
--- Makefile.target | 1 + default-configs/lm32-softmmu.mak | 1 + hw/milkymist-memcard.c | 294 ++++++++++++++++++++++++++++++++++++++ trace-events | 8 +- 4 files changed, 302 insertions(+), 2 deletions(-) create mode 100644 hw/milkymist-memcard.c
Makefile.target +1 -0
@@ -258,6 +258,7 @@ obj-lm32-y += lm32_uart.o obj-lm32-y += lm32_sys.o obj-lm32-y += milkymist-ac97.o obj-lm32-y += milkymist-hpdmc.o +obj-lm32-y += milkymist-memcard.o obj-mips-y = mips_r4k.o mips_jazz.o mips_malta.o mips_mipssim.o obj-mips-y += mips_addr.o mips_timer.o mips_int.o
default-configs/lm32-softmmu.mak +1 -0
@@ -2,3 +2,4 @@ CONFIG_PTIMER=y CONFIG_PFLASH_CFI02=y +CONFIG_SD=y
hw/milkymist-memcard.c new file +294 -0
294 lines not on this page · raw message
trace-events +6 -2
@@ -297,5 +297,9 @@ disable milkymist_ac97_out_cb(int free, uint32_t remaining) "free %d remaining % disable milkymist_ac97_out_cb_transferred(int transferred) "transferred %d" # hw/milkymist-hpdmc.c -disable milkymist_hpdmc_memory_read(uint32_t addr, uint32_t value) "addr %08x value %08x" -disable milkymist_hpdmc_memory_write(uint32_t addr, uint32_t value) "addr %08x value %08x" +disable milkymist_hpdmc_memory_read(uint32_t addr, uint32_t value) "addr=%08x value=%08x" +disable milkymist_hpdmc_memory_write(uint32_t addr, uint32_t value) "addr=%08x value=%08x" + +# hw/milkymist-memcard.c +disable milkymist_memcard_memory_read(uint32_t addr, uint32_t value) "addr %08x value %08x" +disable milkymist_memcard_memory_write(uint32_t addr, uint32_t value) "addr %08x value %08x"
Signature · 1 line
1.7.2.3
PATCH 4/14 lm32: add Milkymist Minimac support
In reply to Michael WalleThis patch adds support for Milkymist's minimal Ethernet MAC.
--- Makefile.target | 1 + hw/milkymist-minimac.c | 568 ++++++++++++++++++++++++++++++++++++++++++++++++ trace-events | 12 + 3 files changed, 581 insertions(+), 0 deletions(-) create mode 100644 hw/milkymist-minimac.c
Makefile.target +1 -0
@@ -259,6 +259,7 @@ obj-lm32-y += lm32_sys.o obj-lm32-y += milkymist-ac97.o obj-lm32-y += milkymist-hpdmc.o obj-lm32-y += milkymist-memcard.o +obj-lm32-y += milkymist-minimac.o obj-mips-y = mips_r4k.o mips_jazz.o mips_malta.o mips_mipssim.o obj-mips-y += mips_addr.o mips_timer.o mips_int.o
hw/milkymist-minimac.c new file +568 -0
568 lines not on this page · raw message
trace-events +12 -0
@@ -303,3 +303,15 @@ disable milkymist_hpdmc_memory_write(uint32_t addr, uint32_t value) "addr=%08x v # hw/milkymist-memcard.c disable milkymist_memcard_memory_read(uint32_t addr, uint32_t value) "addr %08x value %08x" disable milkymist_memcard_memory_write(uint32_t addr, uint32_t value) "addr %08x value %08x" + +# hw/milkymist-minimac.c +disable milkymist_minimac_memory_read(uint32_t addr, uint32_t value) "addr %08x value %08x" +disable milkymist_minimac_memory_write(uint32_t addr, uint32_t value) "addr %08x value %08x" +disable milkymist_minimac_mdio_write(uint8_t phy_addr, uint8_t addr, uint16_t value) "phy_addr %02x addr %02x value %04x" +disable milkymist_minimac_mdio_read(uint8_t phy_addr, uint8_t addr, uint16_t value) "phy_addr %02x addr %02x value %04x" +disable milkymist_minimac_tx_frame(uint32_t length) "length %u" +disable milkymist_minimac_rx_frame(const void *buf, uint32_t length) "buf %p length %u" +disable milkymist_minimac_drop_rx_frame(const void *buf) "buf %p" +disable milkymist_minimac_rx_transfer(const void *buf, uint32_t length) "buf %p length %d" +disable milkymist_minimac_pulse_irq_rx(void) "Pulse IRQ RX" +disable milkymist_minimac_pulse_irq_tx(void) "Pulse IRQ TX"
Signature · 1 line
1.7.2.3
PATCH 5/14 lm32: add Milkymist PFPU support
In reply to Michael WalleThis patch adds support for Milkymist's Programmable FPU.
--- Makefile.target | 1 + hw/milkymist-pfpu.c | 536 +++++++++++++++++++++++++++++++++++++++++++++++++++ trace-events | 6 + 3 files changed, 543 insertions(+), 0 deletions(-) create mode 100644 hw/milkymist-pfpu.c
Makefile.target +1 -0
@@ -260,6 +260,7 @@ obj-lm32-y += milkymist-ac97.o obj-lm32-y += milkymist-hpdmc.o obj-lm32-y += milkymist-memcard.o obj-lm32-y += milkymist-minimac.o +obj-lm32-y += milkymist-pfpu.o obj-mips-y = mips_r4k.o mips_jazz.o mips_malta.o mips_mipssim.o obj-mips-y += mips_addr.o mips_timer.o mips_int.o
hw/milkymist-pfpu.c new file +536 -0
536 lines not on this page · raw message
trace-events +6 -0
@@ -315,3 +315,9 @@ disable milkymist_minimac_drop_rx_frame(const void *buf) "buf %p" disable milkymist_minimac_rx_transfer(const void *buf, uint32_t length) "buf %p length %d" disable milkymist_minimac_pulse_irq_rx(void) "Pulse IRQ RX" disable milkymist_minimac_pulse_irq_tx(void) "Pulse IRQ TX" + +# hw/milkymist-pfpu.c +disable milkymist_pfpu_memory_read(uint32_t addr, uint32_t value) "addr %08x value %08x" +disable milkymist_pfpu_memory_write(uint32_t addr, uint32_t value) "addr %08x value %08x" +disable milkymist_pfpu_vectout(uint32_t a, uint32_t b, uint32_t dma_ptr) "a %08x b %08x dma_ptr %08x" +disable milkymist_pfpu_pulse_irq(void) "Pulse IRQ"
Signature · 1 line
1.7.2.3
PATCH 6/14 lm32: add Milkymist SoftUSB support
In reply to Michael WalleThis patch adds support for Milkymist's SoftUSB core. This model differ from the real hardware in its functionality. The real hardware consits of a tiny freely programmable microcontroller which controls the USB ports. For simplicity reasons, this model emulates only keyboard and mouse input devices, eg. input events translates directly to the corresponding expected messages.
--- Makefile.target | 1 + hw/milkymist-softusb.c | 357 ++++++++++++++++++++++++++++++++++++++++++++++++ trace-events | 8 + 3 files changed, 366 insertions(+), 0 deletions(-) create mode 100644 hw/milkymist-softusb.c
Makefile.target +1 -0
@@ -261,6 +261,7 @@ obj-lm32-y += milkymist-hpdmc.o obj-lm32-y += milkymist-memcard.o obj-lm32-y += milkymist-minimac.o obj-lm32-y += milkymist-pfpu.o +obj-lm32-y += milkymist-softusb.o obj-mips-y = mips_r4k.o mips_jazz.o mips_malta.o mips_mipssim.o obj-mips-y += mips_addr.o mips_timer.o mips_int.o
hw/milkymist-softusb.c new file +357 -0
357 lines not on this page · raw message
trace-events +8 -0
@@ -321,3 +321,11 @@ disable milkymist_pfpu_memory_read(uint32_t addr, uint32_t value) "addr %08x val disable milkymist_pfpu_memory_write(uint32_t addr, uint32_t value) "addr %08x value %08x" disable milkymist_pfpu_vectout(uint32_t a, uint32_t b, uint32_t dma_ptr) "a %08x b %08x dma_ptr %08x" disable milkymist_pfpu_pulse_irq(void) "Pulse IRQ" + +# hw/milkymist-softusb.c +disable milkymist_softusb_memory_read(uint32_t addr, uint32_t value) "addr %08x value %08x" +disable milkymist_softusb_memory_write(uint32_t addr, uint32_t value) "addr %08x value %08x" +disable milkymist_softusb_mevt(uint8_t m) "m %d" +disable milkymist_softusb_kevt(uint8_t m) "m %d" +disable milkymist_softusb_mouse_event(int dx, int dy, int dz, int bs) "dx %d dy %d dz %d bs %02x" +disable milkymist_softusb_pulse_irq(void) "Pulse IRQ"
Signature · 1 line
1.7.2.3
PATCH 7/14 lm32: add Milkymist System Controller support
In reply to Michael WalleThis patch adds support for Milkymist's System Controller core. The model has the following features:
- support for shutting down and restarting the board
- provide two timers and GPIO
- provide registers for system identification and reading the boards capabilities
--- Makefile.target | 1 + hw/milkymist-sysctl.c | 330 +++++++++++++++++++++++++++++++++++++++++++++++++ trace-events | 11 ++ 3 files changed, 342 insertions(+), 0 deletions(-) create mode 100644 hw/milkymist-sysctl.c
Makefile.target +1 -0
@@ -262,6 +262,7 @@ obj-lm32-y += milkymist-memcard.o obj-lm32-y += milkymist-minimac.o obj-lm32-y += milkymist-pfpu.o obj-lm32-y += milkymist-softusb.o +obj-lm32-y += milkymist-sysctl.o obj-mips-y = mips_r4k.o mips_jazz.o mips_malta.o mips_mipssim.o obj-mips-y += mips_addr.o mips_timer.o mips_int.o
hw/milkymist-sysctl.c new file +330 -0
330 lines not on this page · raw message
trace-events +11 -0
@@ -329,3 +329,14 @@ disable milkymist_softusb_mevt(uint8_t m) "m %d" disable milkymist_softusb_kevt(uint8_t m) "m %d" disable milkymist_softusb_mouse_event(int dx, int dy, int dz, int bs) "dx %d dy %d dz %d bs %02x" disable milkymist_softusb_pulse_irq(void) "Pulse IRQ" + +# hw/milkymist-sysctl.c +disable milkymist_sysctl_memory_read(uint32_t addr, uint32_t value) "addr %08x value %08x" +disable milkymist_sysctl_memory_write(uint32_t addr, uint32_t value) "addr %08x value %08x" +disable milkymist_sysctl_icap_write(uint32_t value) "value %08x" +disable milkymist_sysctl_start_timer0(void) "Start timer0" +disable milkymist_sysctl_stop_timer0(void) "Stop timer0" +disable milkymist_sysctl_start_timer1(void) "Start timer1" +disable milkymist_sysctl_stop_timer1(void) "Stop timer1" +disable milkymist_sysctl_pulse_irq_timer0(void) "Pulse IRQ Timer0" +disable milkymist_sysctl_pulse_irq_timer1(void) "Pulse IRQ Timer1"
Signature · 1 line
1.7.2.3
PATCH 8/14 configure: add opengl detection
In reply to Michael WalleThis patch introduce a new config option CONFIG_OPENGL.
--- configure | 33 +++++++++++++++++++++++++++++++++ 1 files changed, 33 insertions(+), 0 deletions(-)
configure +33 -0
@@ -130,6 +130,7 @@ linux_aio="" attr="" vhost_net="" xfs="" +opengl="" gprof="no" debug_tcg="no"
@@ -713,6 +714,10 @@ for opt do ;; --enable-vhost-net) vhost_net="yes" ;; + --disable-opengl) opengl="no" + ;; + --enable-opengl) opengl="yes" + ;; --*dir) ;; --disable-rbd) rbd="no"
@@ -872,6 +877,8 @@ echo " --disable-kvm disable KVM acceleration support" echo " --enable-kvm enable KVM acceleration support" echo " --disable-nptl disable usermode NPTL support" echo " --enable-nptl enable usermode NPTL support" +echo " --disable-opengl disable OpenGL support" +echo " --enable-opengl enable OpenGL support" echo " --enable-system enable all system emulation targets" echo " --disable-system disable all system emulation targets" echo " --enable-user enable supported user emulation targets"
@@ -1923,6 +1930,27 @@ EOF fi fi +########################################## +# opengl probe, used by milkymist-tmu2 +if test "$opengl" != "no" ; then + opengl_libs="-lGL" + cat > $TMPC << EOF +#include <X11/Xlib.h> +#include <GL/gl.h> +#include <GL/glx.h> +int main(void) { GL_VERSION; return 0; } +EOF + if compile_prog "" "-lGL" ; then + opengl=yes + libs_softmmu="$opengl_libs $libs_softmmu" + else + if test "$opengl" = "yes" ; then + feature_not_found "opengl" + fi + opengl=no + fi +fi + # # Check for xxxat() functions when we are building linux-user # emulator. This is done because older glibc versions don't
@@ -2530,6 +2558,7 @@ echo "Trace output file $trace_file-<pid>" echo "spice support $spice" echo "rbd support $rbd" echo "xfsctl support $xfs" +echo "OpenGL support $opengl" if test $sdl_too_old = "yes"; then echo "-> Your SDL version is too old - please upgrade to have SDL support"
@@ -2811,6 +2840,10 @@ if test "$spice" = "yes" ; then echo "CONFIG_SPICE=y" >> $config_host_mak fi +if test "$opengl" = "yes" ; then + echo "CONFIG_OPENGL=y" >> $config_host_mak +fi + # XXX: suppress that if [ "$bsd" = "yes" ] ; then echo "CONFIG_BSD=y" >> $config_host_mak
Signature · 1 line
1.7.2.3
PATCH 9/14 lm32: add Milkymist TMU2 support
In reply to Michael WalleThis patch adds support for Milkymist's texture mapping unit. For fast computation this model needs hardware accelerated 3D graphics support (OpenGL). There is no graphical output, all computations belong to internal framebuffers only.
--- Makefile.target | 1 + hw/milkymist-tmu2.c | 481 +++++++++++++++++++++++++++++++++++++++++++++++++++ trace-events | 6 + 3 files changed, 488 insertions(+), 0 deletions(-) create mode 100644 hw/milkymist-tmu2.c
Makefile.target +1 -0
@@ -263,6 +263,7 @@ obj-lm32-y += milkymist-minimac.o obj-lm32-y += milkymist-pfpu.o obj-lm32-y += milkymist-softusb.o obj-lm32-y += milkymist-sysctl.o +obj-lm32-$(CONFIG_OPENGL) += milkymist-tmu2.o obj-mips-y = mips_r4k.o mips_jazz.o mips_malta.o mips_mipssim.o obj-mips-y += mips_addr.o mips_timer.o mips_int.o
hw/milkymist-tmu2.c new file +481 -0
481 lines not on this page · raw message
trace-events +6 -0
@@ -340,3 +340,9 @@ disable milkymist_sysctl_start_timer1(void) "Start timer1" disable milkymist_sysctl_stop_timer1(void) "Stop timer1" disable milkymist_sysctl_pulse_irq_timer0(void) "Pulse IRQ Timer0" disable milkymist_sysctl_pulse_irq_timer1(void) "Pulse IRQ Timer1" + +# hw/milkymist-tmu2.c +disable milkymist_tmu2_memory_read(uint32_t addr, uint32_t value) "addr %08x value %08x" +disable milkymist_tmu2_memory_write(uint32_t addr, uint32_t value) "addr %08x value %08x" +disable milkymist_tmu2_start(void) "Start TMU" +disable milkymist_tmu2_pulse_irq(void) "Pulse IRQ"
Signature · 1 line
1.7.2.3
PATCH 10/14 lm32: add Milkymist UART support
In reply to Michael WalleThis patch adds support for Milkymist's simple UART.
--- Makefile.target | 1 + hw/milkymist-uart.c | 180 +++++++++++++++++++++++++++++++++++++++++++++++++++ trace-events | 6 ++ 3 files changed, 187 insertions(+), 0 deletions(-) create mode 100644 hw/milkymist-uart.c
Makefile.target +1 -0
@@ -264,6 +264,7 @@ obj-lm32-y += milkymist-pfpu.o obj-lm32-y += milkymist-softusb.o obj-lm32-y += milkymist-sysctl.o obj-lm32-$(CONFIG_OPENGL) += milkymist-tmu2.o +obj-lm32-y += milkymist-uart.o obj-mips-y = mips_r4k.o mips_jazz.o mips_malta.o mips_mipssim.o obj-mips-y += mips_addr.o mips_timer.o mips_int.o
hw/milkymist-uart.c new file +180 -0
180 lines not on this page · raw message
trace-events +6 -0
@@ -346,3 +346,9 @@ disable milkymist_tmu2_memory_read(uint32_t addr, uint32_t value) "addr %08x val disable milkymist_tmu2_memory_write(uint32_t addr, uint32_t value) "addr %08x value %08x" disable milkymist_tmu2_start(void) "Start TMU" disable milkymist_tmu2_pulse_irq(void) "Pulse IRQ" + +# hw/milkymist-uart.c +disable milkymist_uart_memory_read(uint32_t addr, uint32_t value) "addr %08x value %08x" +disable milkymist_uart_memory_write(uint32_t addr, uint32_t value) "addr %08x value %08x" +disable milkymist_uart_pulse_irq_rx(void) "Pulse IRQ RX" +disable milkymist_uart_pulse_irq_tx(void) "Pulse IRQ TX"
Signature · 1 line
1.7.2.3
PATCH 11/14 lm32: add Milkymist VGAFB support
In reply to Michael WalleThis patch adds support for Milkymist's VGA framebuffer.
--- Makefile.target | 2 + hw/milkymist-vgafb.c | 318 +++++++++++++++++++++++++++++++++++++++++ hw/milkymist-vgafb_template.h | 74 ++++++++++ trace-events | 4 + 4 files changed, 398 insertions(+), 0 deletions(-) create mode 100644 hw/milkymist-vgafb.c create mode 100644 hw/milkymist-vgafb_template.h
Makefile.target +2 -0
@@ -265,6 +265,8 @@ obj-lm32-y += milkymist-softusb.o obj-lm32-y += milkymist-sysctl.o obj-lm32-$(CONFIG_OPENGL) += milkymist-tmu2.o obj-lm32-y += milkymist-uart.o +obj-lm32-y += milkymist-vgafb.o +obj-lm32-y += framebuffer.o obj-mips-y = mips_r4k.o mips_jazz.o mips_malta.o mips_mipssim.o obj-mips-y += mips_addr.o mips_timer.o mips_int.o
hw/milkymist-vgafb.c new file +318 -0
318 lines not on this page · raw message
hw/milkymist-vgafb_template.h new file +74 -0
74 lines not on this page · raw message
trace-events +4 -0
@@ -352,3 +352,7 @@ disable milkymist_uart_memory_read(uint32_t addr, uint32_t value) "addr %08x val disable milkymist_uart_memory_write(uint32_t addr, uint32_t value) "addr %08x value %08x" disable milkymist_uart_pulse_irq_rx(void) "Pulse IRQ RX" disable milkymist_uart_pulse_irq_tx(void) "Pulse IRQ TX" + +# hw/milkymist-vgafb.c +disable milkymist_vgafb_memory_read(uint32_t addr, uint32_t value) "addr %08x value %08x" +disable milkymist_vgafb_memory_write(uint32_t addr, uint32_t value) "addr %08x value %08x"
Signature · 1 line
1.7.2.3
PATCH 12/14 lm32: add milkymist hw support functions
In reply to Michael WalleThis patch adds wrappers for easy creation of the qdev devices.
--- hw/milkymist-hw.h | 204 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 204 insertions(+), 0 deletions(-) create mode 100644 hw/milkymist-hw.h
hw/milkymist-hw.h new file +204 -0
@@ -0,0 +1,204 @@ +#ifndef QEMU_HW_MILKYMIST_H +#define QEMU_HW_MILKYMIST_H + +static inline DeviceState *milkymist_uart_create (target_phys_addr_t base, +qemu_irq rx_irq,qemu_irq tx_irq) +{ +DeviceState *dev; + + dev =qdev_create (NULL ,"milkymist-uart" ); +qdev_init_nofail (dev); +sysbus_mmio_map (sysbus_from_qdev (dev),0 , base); +sysbus_connect_irq (sysbus_from_qdev (dev),0 , rx_irq); +sysbus_connect_irq (sysbus_from_qdev (dev),1 , tx_irq); + +return dev; +} + +static inline DeviceState *milkymist_hpdmc_create (target_phys_addr_t base) +{ +DeviceState *dev; + + dev =qdev_create (NULL ,"milkymist-hpdmc" ); +qdev_init_nofail (dev); +sysbus_mmio_map (sysbus_from_qdev (dev),0 , base); + +return dev; +} + +static inline DeviceState *milkymist_memcard_create (target_phys_addr_t base) +{ +DeviceState *dev; + + dev =qdev_create (NULL ,"milkymist-memcard" ); +qdev_init_nofail (dev); +sysbus_mmio_map (sysbus_from_qdev (dev),0 , base); + +return dev; +} + +static inline DeviceState *milkymist_vgafb_create (target_phys_addr_t base, +uint32_t fb_offset,uint32_t fb_mask) +{ +DeviceState *dev; + + dev =qdev_create (NULL ,"milkymist-vgafb" ); +qdev_prop_set_uint32 (dev,"fb_offset" , fb_offset); +qdev_prop_set_uint32 (dev,"fb_mask" , fb_mask); +qdev_init_nofail (dev); +sysbus_mmio_map (sysbus_from_qdev (dev),0 , base); + +return dev; +} + +static inline DeviceState *milkymist_sysctl_create (target_phys_addr_t base, +qemu_irq gpio_irq,qemu_irq timer0_irq,qemu_irq timer1_irq, +uint32_t freq_hz,uint32_t system_id,uint32_t capabilities, +uint32_t gpio_strappings) +{ +DeviceState *dev; + + dev =qdev_create (NULL ,"milkymist-sysctl" ); +qdev_prop_set_uint32 (dev,"frequency" , freq_hz); +qdev_prop_set_uint32 (dev,"systemid" , system_id); +qdev_prop_set_uint32 (dev,"capabilities" , capabilities); +qdev_prop_set_uint32 (dev,"gpio_strappings" , gpio_strappings); +qdev_init_nofail (dev); +sysbus_mmio_map (sysbus_from_qdev (dev),0 , base); +sysbus_connect_irq (sysbus_from_qdev (dev),0 , gpio_irq); +sysbus_connect_irq (sysbus_from_qdev (dev),1 , timer0_irq); +sysbus_connect_irq (sysbus_from_qdev (dev),2 , timer1_irq); + +return dev; +} + +static inline DeviceState *milkymist_pfpu_create (target_phys_addr_t base, +qemu_irq irq) +{ +DeviceState *dev; + + dev =qdev_create (NULL ,"milkymist-pfpu" ); +qdev_init_nofail (dev); +sysbus_mmio_map (sysbus_from_qdev (dev),0 , base); +sysbus_connect_irq (sysbus_from_qdev (dev),0 , irq); +return dev; +} + +#ifdef CONFIG_OPENGL +#include <X11/Xlib.h> +#include <GL/glx.h> +static const int glx_fbconfig_attr[] = { +GLX_GREEN_SIZE ,5 , +GLX_GREEN_SIZE ,6 , +GLX_BLUE_SIZE ,5 , + None +}; +#endif + +static inline DeviceState *milkymist_tmu2_create (target_phys_addr_t base, +qemu_irq irq) +{ +#ifdef CONFIG_OPENGL +DeviceState *dev; +Display *d; +GLXFBConfig *configs; +int nelements; +int ver_major, ver_minor; + +if (display_type ==DT_NOGRAPHIC ) { +return NULL ; + } + +/* check that GLX will work */ + d =XOpenDisplay (NULL ); +if (d ==NULL ) { +return NULL ; + } + +if (!glXQueryVersion (d, &ver_major, &ver_minor)) { +/* Yeah, sometimes getting the GLX version can fail. +* Isn't X beautiful? */ +XCloseDisplay (d); +return NULL ; + } + +if ((ver_major <1 ) || ((ver_major ==1 ) && (ver_minor <3 ))) { +printf ("Your GLX version is %d.%d," +"but TMU emulation needs at least 1.3. TMU disabled.\n" , + ver_major, ver_minor); +XCloseDisplay (d); +return NULL ; + } + + configs =glXChooseFBConfig (d,0 , glx_fbconfig_attr, &nelements); +if (configs ==NULL ) { +XCloseDisplay (d); +return NULL ; + } + +XFree (configs); +XCloseDisplay (d); + + dev =qdev_create (NULL ,"milkymist-tmu2" ); +qdev_init_nofail (dev); +sysbus_mmio_map (sysbus_from_qdev (dev),0 , base); +sysbus_connect_irq (sysbus_from_qdev (dev),0 , irq); + +return dev; +#else +return NULL ; +#endif +} + +static inline DeviceState *milkymist_ac97_create (target_phys_addr_t base, +qemu_irq crrequest_irq,qemu_irq crreply_irq,qemu_irq dmar_irq, +qemu_irq dmaw_irq) +{ +DeviceState *dev; + + dev =qdev_create (NULL ,"milkymist-ac97" ); +qdev_init_nofail (dev); +sysbus_mmio_map (sysbus_from_qdev (dev),0 , base); +sysbus_connect_irq (sysbus_from_qdev (dev),0 , crrequest_irq); +sysbus_connect_irq (sysbus_from_qdev (dev),1 , crreply_irq); +sysbus_connect_irq (sysbus_from_qdev (dev),2 , dmar_irq); +sysbus_connect_irq (sysbus_from_qdev (dev),3 , dmaw_irq); + +return dev; +} + +static inline DeviceState *milkymist_minimac_create (target_phys_addr_t base, +qemu_irq rx_irq,qemu_irq tx_irq) +{ +DeviceState *dev; + +qemu_check_nic_model (&nd_table[0 ],"minimac" ); + dev =qdev_create (NULL ,"milkymist-minimac" ); +qdev_set_nic_properties (dev, &nd_table[0 ]); +qdev_init_nofail (dev); +sysbus_mmio_map (sysbus_from_qdev (dev),0 , base); +sysbus_connect_irq (sysbus_from_qdev (dev),0 , rx_irq); +sysbus_connect_irq (sysbus_from_qdev (dev),1 , tx_irq); + +return dev; +} + +static inline DeviceState *milkymist_softusb_create (target_phys_addr_t base, +qemu_irq irq,uint32_t pmem_base,uint32_t pmem_size, +uint32_t dmem_base,uint32_t dmem_size) +{ +DeviceState *dev; + + dev =qdev_create (NULL ,"milkymist-softusb" ); +qdev_prop_set_uint32 (dev,"pmem_base" , pmem_base); +qdev_prop_set_uint32 (dev,"pmem_size" , pmem_size); +qdev_prop_set_uint32 (dev,"dmem_base" , dmem_base); +qdev_prop_set_uint32 (dev,"dmem_size" , dmem_size); +qdev_init_nofail (dev); +sysbus_mmio_map (sysbus_from_qdev (dev),0 , base); +sysbus_connect_irq (sysbus_from_qdev (dev),0 , irq); + +return dev; +} + +#endif /* QEMU_HW_MILKYMIST_H */
Signature · 1 line
1.7.2.3
PATCH 13/14 lm32: add support for the Milkymist board
In reply to Michael WalleThis patch adds almost complete support for the Milkymist system-on-chip
(http://www.milkymist.org).
Additional to running bare metal applications, booting a linux kernel with initrd is supported.
--- Makefile.target | 1 + default-configs/lm32-softmmu.mak | 1 + hw/milkymist.c | 216 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 218 insertions(+), 0 deletions(-) create mode 100644 hw/milkymist.c
Makefile.target +1 -0
@@ -249,6 +249,7 @@ obj-ppc-y += xilinx_ethlite.o # LM32 boards obj-lm32-y += lm32_boards.o +obj-lm32-y += milkymist.o # LM32 peripherals obj-lm32-y += lm32_pic.o
default-configs/lm32-softmmu.mak +1 -0
@@ -1,5 +1,6 @@ # Default configuration for lm32-softmmu CONFIG_PTIMER=y +CONFIG_PFLASH_CFI01=y CONFIG_PFLASH_CFI02=y CONFIG_SD=y
hw/milkymist.c new file +216 -0
216 lines not on this page · raw message
Signature · 1 line
1.7.2.3
PATCH 14/14 MAINTAINERS: add Milkymist board
In reply to Michael Walle--- MAINTAINERS | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
MAINTAINERS +5 -0
@@ -214,6 +214,11 @@ M: Michael Walle <[email protected]> S: Maintained F: hw/lm32_boards.c +milkymist +M: Michael Walle <[email protected]> +S: Maintained +F: hw/milkymist.c + M68K Machines ------------- an5206
Signature · 1 line
1.7.2.3
Quoted 6 lines · Michael Walle
This is the second (and last) patchset of the LatticeMico32 support. It adds almost complete support for the opensource and openhardware Milkymist One board [1].
From my side you get:
But it'd be great if the respective subsystem maintainers could also take a look at code affecting them.
Alex
Quoted 5 lines · Alexander Graf
Quoted 4 lines · Michael Walle
This is the second (and last) patchset of the LatticeMico32 support. It adds almost complete support for the opensource and openhardware Milkymist One board [1].
Quoted 8 lines
Quoted 2 lines
From my side you get:
Acked-by Alexander Graf <[email protected]>But it'd be great if the respective subsystem maintainers could also take a look at code affecting them.
Ping? Enough time passed for people to comment now, no?
Alex
Edgar E. Iglesias
AppliedQuoted 11 lines · Alexander Graf
Quoted 8 lines · Alexander Graf
Quoted 6 lines · Michael Walle
This is the second (and last) patchset of the LatticeMico32 support. It adds almost complete support for the opensource and openhardware Milkymist One board [1].
Quoted 7 lines
Quoted 5 lines
From my side you get:
Acked-by Alexander Graf <[email protected]>But it'd be great if the respective subsystem maintainers could also take a look at code affecting them.
Ping? Enough time passed for people to comment now, no?
I've applied this now, thanks Michael and Alex.
Cheers