Re: [Qemu-devel] [PATCH v23 1/7] target/avr: Add outward facing interfaces and core CPU logic

2019-06-28 Thread Michael Rolnik
thanks.
new version is out.

Michael

On Fri, Jun 28, 2019 at 1:01 PM Richard Henderson <
richard.hender...@linaro.org> wrote:

> On 6/28/19 11:22 AM, Igor Mammedov wrote:
> > On Fri, 28 Jun 2019 11:43:22 +0300
> > Michael Rolnik  wrote:
> >
> >> Nobody else does it.
> > it doesn't mean that we should blindly copy pre-existing patterns
> > which might/will exist for compatibility reasons.
> >
> > pls see the same argument on RX CPU for reasons not to support
> > anything else beside typename there.
> >   [Qemu-devel] [PATCH v16 13/23] target/rx: Fix cpu types and  names
> >   [Qemu-devel] [PATCH v19 03/21] target/rx: CPU definition
> >
> >
> >> Richard.
> >> What do you think?
>
> We are going with Igor's advice for target/rx, yes.
> You should do the same here in target/avr.
>
>
> r~
>


-- 
Best Regards,
Michael Rolnik


Re: [Qemu-devel] [PATCH v23 1/7] target/avr: Add outward facing interfaces and core CPU logic

2019-06-28 Thread Richard Henderson
On 6/28/19 11:22 AM, Igor Mammedov wrote:
> On Fri, 28 Jun 2019 11:43:22 +0300
> Michael Rolnik  wrote:
> 
>> Nobody else does it.
> it doesn't mean that we should blindly copy pre-existing patterns
> which might/will exist for compatibility reasons.
> 
> pls see the same argument on RX CPU for reasons not to support
> anything else beside typename there.
>   [Qemu-devel] [PATCH v16 13/23] target/rx: Fix cpu types and  names
>   [Qemu-devel] [PATCH v19 03/21] target/rx: CPU definition
> 
>  
>> Richard.
>> What do you think?

We are going with Igor's advice for target/rx, yes.
You should do the same here in target/avr.


r~



Re: [Qemu-devel] [PATCH v23 1/7] target/avr: Add outward facing interfaces and core CPU logic

2019-06-28 Thread Igor Mammedov
On Fri, 28 Jun 2019 11:43:22 +0300
Michael Rolnik  wrote:

> Nobody else does it.
it doesn't mean that we should blindly copy pre-existing patterns
which might/will exist for compatibility reasons.

pls see the same argument on RX CPU for reasons not to support
anything else beside typename there.
  [Qemu-devel] [PATCH v16 13/23] target/rx: Fix cpu types and  names
  [Qemu-devel] [PATCH v19 03/21] target/rx: CPU definition

 
> Richard.
> What do you think?
> 
> Sent from my cell phone, please ignore typos
> 
> On Fri, Jun 28, 2019, 11:36 AM Igor Mammedov  wrote:
> 
> > On Thu, 27 Jun 2019 21:51:23 +0300
> > Michael Rolnik  wrote:
> >  
> > > I meant that if I take the proposed code it fails in the mentioned way
> > >
> > > Sent from my cell phone, please ignore typos
> > >
> > > On Thu, Jun 27, 2019, 7:02 PM Michael Rolnik  wrote:
> > >  
> > > > Hi Igor,
> > > >
> > > > if I run `make check` it fails with
> > > > qemu-system-rx: unable to find CPU model 'rx62n'
> > > > or
> > > > qemu-system-avr: unable to find CPU model 'avr6'  
> > suggested change means that one has to user type name as is for -cpu
> > argument.
> >
> > so test should be amended to account for that,
> > something like that should be sufficient:
> >
> > diff --git a/tests/machine-none-test.c b/tests/machine-none-test.c
> > index 361927bb76..d0907e6bd4 100644
> > --- a/tests/machine-none-test.c
> > +++ b/tests/machine-none-test.c
> > @@ -27,7 +27,7 @@ static struct arch2cpu cpus_map[] = {
> >  /* tested targets list */
> >  { "arm", "cortex-a15" },
> >  { "aarch64", "cortex-a57" },
> > -{ "avr", "avr6" },
> > +{ "avr", "avr6-avr-cpu" },
> >  { "x86_64", "qemu64,apic-id=0" },
> >  { "i386", "qemu32,apic-id=0" },
> >  { "alpha", "ev67" },
> >
> >  
> > > >
> > > > On Thu, Jun 27, 2019 at 2:28 PM Igor Mammedov   
> > wrote:  
> > > >  
> > > >> On Thu, 27 Jun 2019 08:27:44 +0300
> > > >> Michael Rolnik  wrote:
> > > >>  
> > > >> > From: Sarah Harris 
> > > >> >
> > > >> > This includes:
> > > >> > - CPU data structures
> > > >> > - object model classes and functions
> > > >> > - migration functions
> > > >> > - GDB hooks
> > > >> >
> > > >> > Signed-off-by: Michael Rolnik 
> > > >> > ---
> > > >> >  gdb-xml/avr-cpu.xml|  49 
> > > >> >  target/avr/cpu-param.h |  37 +++
> > > >> >  target/avr/cpu.c   | 599  
> > +  
> > > >> >  target/avr/cpu.h   | 283 +++
> > > >> >  target/avr/gdbstub.c   |  85 ++
> > > >> >  target/avr/machine.c   | 123 +
> > > >> >  6 files changed, 1176 insertions(+)
> > > >> >  create mode 100644 gdb-xml/avr-cpu.xml
> > > >> >  create mode 100644 target/avr/cpu-param.h
> > > >> >  create mode 100644 target/avr/cpu.c
> > > >> >  create mode 100644 target/avr/cpu.h
> > > >> >  create mode 100644 target/avr/gdbstub.c
> > > >> >  create mode 100644 target/avr/machine.c
> > > >> >
> > > >> > diff --git a/gdb-xml/avr-cpu.xml b/gdb-xml/avr-cpu.xml
> > > >> > new file mode 100644
> > > >> > index 00..c4747f5b40
> > > >> > --- /dev/null
> > > >> > +++ b/gdb-xml/avr-cpu.xml
> > > >> > @@ -0,0 +1,49 @@
> > > >> > +
> > > >> > +
> > > >> > +
> > > >> > +
> > > >> > +
> > > >> > +
> > > >> > +
> > > >> > +  
> > > >> > +  
> > > >> > +  
> > > >> > +  
> > > >> > +  
> > > >> > +  
> > > >> > +  
> > > >> > +  
> > > >> > +  
> > > >> > +  
> > > >> > +  
> > > >> > +  
> > > >> > +  
> > > >> > +  
> > > >> > +  
> > > >> > +  
> > > >> > +  
> > > >> > +  
> > > >> > +  
> > > >> > +  
> > > >> > +  
> > > >> > +  
> > > >> > +  
> > > >> > +  
> > > >> > +  
> > > >> > +  
> > > >> > +  
> > > >> > +  
> > > >> > +  
> > > >> > +  
> > > >> > +  
> > > >> > +  
> > > >> > +  
> > > >> > +  
> > > >> > +  
> > > >> > +
> > > >> > diff --git a/target/avr/cpu-param.h b/target/avr/cpu-param.h
> > > >> > new file mode 100644
> > > >> > index 00..5bbf985726
> > > >> > --- /dev/null
> > > >> > +++ b/target/avr/cpu-param.h
> > > >> > @@ -0,0 +1,37 @@
> > > >> > +/*
> > > >> > + * QEMU AVR CPU
> > > >> > + *
> > > >> > + * Copyright (c) 2016 Michael Rolnik
> > > >> > + *
> > > >> > + * 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.1 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
> > > >> > + * 

Re: [Qemu-devel] [PATCH v23 1/7] target/avr: Add outward facing interfaces and core CPU logic

2019-06-28 Thread Michael Rolnik
Nobody else does it.
Richard.
What do you think?

Sent from my cell phone, please ignore typos

On Fri, Jun 28, 2019, 11:36 AM Igor Mammedov  wrote:

> On Thu, 27 Jun 2019 21:51:23 +0300
> Michael Rolnik  wrote:
>
> > I meant that if I take the proposed code it fails in the mentioned way
> >
> > Sent from my cell phone, please ignore typos
> >
> > On Thu, Jun 27, 2019, 7:02 PM Michael Rolnik  wrote:
> >
> > > Hi Igor,
> > >
> > > if I run `make check` it fails with
> > > qemu-system-rx: unable to find CPU model 'rx62n'
> > > or
> > > qemu-system-avr: unable to find CPU model 'avr6'
> suggested change means that one has to user type name as is for -cpu
> argument.
>
> so test should be amended to account for that,
> something like that should be sufficient:
>
> diff --git a/tests/machine-none-test.c b/tests/machine-none-test.c
> index 361927bb76..d0907e6bd4 100644
> --- a/tests/machine-none-test.c
> +++ b/tests/machine-none-test.c
> @@ -27,7 +27,7 @@ static struct arch2cpu cpus_map[] = {
>  /* tested targets list */
>  { "arm", "cortex-a15" },
>  { "aarch64", "cortex-a57" },
> -{ "avr", "avr6" },
> +{ "avr", "avr6-avr-cpu" },
>  { "x86_64", "qemu64,apic-id=0" },
>  { "i386", "qemu32,apic-id=0" },
>  { "alpha", "ev67" },
>
>
> > >
> > > On Thu, Jun 27, 2019 at 2:28 PM Igor Mammedov 
> wrote:
> > >
> > >> On Thu, 27 Jun 2019 08:27:44 +0300
> > >> Michael Rolnik  wrote:
> > >>
> > >> > From: Sarah Harris 
> > >> >
> > >> > This includes:
> > >> > - CPU data structures
> > >> > - object model classes and functions
> > >> > - migration functions
> > >> > - GDB hooks
> > >> >
> > >> > Signed-off-by: Michael Rolnik 
> > >> > ---
> > >> >  gdb-xml/avr-cpu.xml|  49 
> > >> >  target/avr/cpu-param.h |  37 +++
> > >> >  target/avr/cpu.c   | 599
> +
> > >> >  target/avr/cpu.h   | 283 +++
> > >> >  target/avr/gdbstub.c   |  85 ++
> > >> >  target/avr/machine.c   | 123 +
> > >> >  6 files changed, 1176 insertions(+)
> > >> >  create mode 100644 gdb-xml/avr-cpu.xml
> > >> >  create mode 100644 target/avr/cpu-param.h
> > >> >  create mode 100644 target/avr/cpu.c
> > >> >  create mode 100644 target/avr/cpu.h
> > >> >  create mode 100644 target/avr/gdbstub.c
> > >> >  create mode 100644 target/avr/machine.c
> > >> >
> > >> > diff --git a/gdb-xml/avr-cpu.xml b/gdb-xml/avr-cpu.xml
> > >> > new file mode 100644
> > >> > index 00..c4747f5b40
> > >> > --- /dev/null
> > >> > +++ b/gdb-xml/avr-cpu.xml
> > >> > @@ -0,0 +1,49 @@
> > >> > +
> > >> > +
> > >> > +
> > >> > +
> > >> > +
> > >> > +
> > >> > +
> > >> > +  
> > >> > +  
> > >> > +  
> > >> > +  
> > >> > +  
> > >> > +  
> > >> > +  
> > >> > +  
> > >> > +  
> > >> > +  
> > >> > +  
> > >> > +  
> > >> > +  
> > >> > +  
> > >> > +  
> > >> > +  
> > >> > +  
> > >> > +  
> > >> > +  
> > >> > +  
> > >> > +  
> > >> > +  
> > >> > +  
> > >> > +  
> > >> > +  
> > >> > +  
> > >> > +  
> > >> > +  
> > >> > +  
> > >> > +  
> > >> > +  
> > >> > +  
> > >> > +  
> > >> > +  
> > >> > +  
> > >> > +
> > >> > diff --git a/target/avr/cpu-param.h b/target/avr/cpu-param.h
> > >> > new file mode 100644
> > >> > index 00..5bbf985726
> > >> > --- /dev/null
> > >> > +++ b/target/avr/cpu-param.h
> > >> > @@ -0,0 +1,37 @@
> > >> > +/*
> > >> > + * QEMU AVR CPU
> > >> > + *
> > >> > + * Copyright (c) 2016 Michael Rolnik
> > >> > + *
> > >> > + * 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.1 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
> > >> > + * 
> > >> > + */
> > >> > +
> > >> > +#ifndef AVR_CPU_PARAM_H
> > >> > +#define AVR_CPU_PARAM_H 1
> > >> > +
> > >> > +#define TARGET_LONG_BITS 32
> > >> > +/*
> > >> > + * TARGET_PAGE_BITS cannot be more than 8 bits because
> > >> > + * 1.  all IO registers occupy [0x .. 0x00ff] address range,
> and
> > >> they
> > >> > + * should be implemented as a device and not memory
> > >> > + * 2.  SRAM starts at the address 0x0100
> > >> > + */
> > >> > +#define TARGET_PAGE_BITS 8
> > >> > +#define TARGET_PHYS_ADDR_SPACE_BITS 24
> > >> > +#define TARGET_VIRT_ADDR_SPACE_BITS 24
> > >> > +#define NB_MMU_MODES 2
> > >> > +
> > >> > +
> > >> > +#endif
> > >> > diff --git a/target/avr/cpu.c b/target/avr/cpu.c
> > >> > new file 

Re: [Qemu-devel] [PATCH v23 1/7] target/avr: Add outward facing interfaces and core CPU logic

2019-06-28 Thread Igor Mammedov
On Thu, 27 Jun 2019 21:51:23 +0300
Michael Rolnik  wrote:

> I meant that if I take the proposed code it fails in the mentioned way
> 
> Sent from my cell phone, please ignore typos
> 
> On Thu, Jun 27, 2019, 7:02 PM Michael Rolnik  wrote:
> 
> > Hi Igor,
> >
> > if I run `make check` it fails with
> > qemu-system-rx: unable to find CPU model 'rx62n'
> > or
> > qemu-system-avr: unable to find CPU model 'avr6'
suggested change means that one has to user type name as is for -cpu argument.

so test should be amended to account for that,
something like that should be sufficient:

diff --git a/tests/machine-none-test.c b/tests/machine-none-test.c
index 361927bb76..d0907e6bd4 100644
--- a/tests/machine-none-test.c
+++ b/tests/machine-none-test.c
@@ -27,7 +27,7 @@ static struct arch2cpu cpus_map[] = {
 /* tested targets list */
 { "arm", "cortex-a15" },
 { "aarch64", "cortex-a57" },
-{ "avr", "avr6" },
+{ "avr", "avr6-avr-cpu" },
 { "x86_64", "qemu64,apic-id=0" },
 { "i386", "qemu32,apic-id=0" },
 { "alpha", "ev67" },


> >
> > On Thu, Jun 27, 2019 at 2:28 PM Igor Mammedov  wrote:
> >  
> >> On Thu, 27 Jun 2019 08:27:44 +0300
> >> Michael Rolnik  wrote:
> >>  
> >> > From: Sarah Harris 
> >> >
> >> > This includes:
> >> > - CPU data structures
> >> > - object model classes and functions
> >> > - migration functions
> >> > - GDB hooks
> >> >
> >> > Signed-off-by: Michael Rolnik 
> >> > ---
> >> >  gdb-xml/avr-cpu.xml|  49 
> >> >  target/avr/cpu-param.h |  37 +++
> >> >  target/avr/cpu.c   | 599 +
> >> >  target/avr/cpu.h   | 283 +++
> >> >  target/avr/gdbstub.c   |  85 ++
> >> >  target/avr/machine.c   | 123 +
> >> >  6 files changed, 1176 insertions(+)
> >> >  create mode 100644 gdb-xml/avr-cpu.xml
> >> >  create mode 100644 target/avr/cpu-param.h
> >> >  create mode 100644 target/avr/cpu.c
> >> >  create mode 100644 target/avr/cpu.h
> >> >  create mode 100644 target/avr/gdbstub.c
> >> >  create mode 100644 target/avr/machine.c
> >> >
> >> > diff --git a/gdb-xml/avr-cpu.xml b/gdb-xml/avr-cpu.xml
> >> > new file mode 100644
> >> > index 00..c4747f5b40
> >> > --- /dev/null
> >> > +++ b/gdb-xml/avr-cpu.xml
> >> > @@ -0,0 +1,49 @@
> >> > +
> >> > +
> >> > +
> >> > +
> >> > +
> >> > +
> >> > +
> >> > +  
> >> > +  
> >> > +  
> >> > +  
> >> > +  
> >> > +  
> >> > +  
> >> > +  
> >> > +  
> >> > +  
> >> > +  
> >> > +  
> >> > +  
> >> > +  
> >> > +  
> >> > +  
> >> > +  
> >> > +  
> >> > +  
> >> > +  
> >> > +  
> >> > +  
> >> > +  
> >> > +  
> >> > +  
> >> > +  
> >> > +  
> >> > +  
> >> > +  
> >> > +  
> >> > +  
> >> > +  
> >> > +  
> >> > +  
> >> > +  
> >> > +
> >> > diff --git a/target/avr/cpu-param.h b/target/avr/cpu-param.h
> >> > new file mode 100644
> >> > index 00..5bbf985726
> >> > --- /dev/null
> >> > +++ b/target/avr/cpu-param.h
> >> > @@ -0,0 +1,37 @@
> >> > +/*
> >> > + * QEMU AVR CPU
> >> > + *
> >> > + * Copyright (c) 2016 Michael Rolnik
> >> > + *
> >> > + * 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.1 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
> >> > + * 
> >> > + */
> >> > +
> >> > +#ifndef AVR_CPU_PARAM_H
> >> > +#define AVR_CPU_PARAM_H 1
> >> > +
> >> > +#define TARGET_LONG_BITS 32
> >> > +/*
> >> > + * TARGET_PAGE_BITS cannot be more than 8 bits because
> >> > + * 1.  all IO registers occupy [0x .. 0x00ff] address range, and  
> >> they  
> >> > + * should be implemented as a device and not memory
> >> > + * 2.  SRAM starts at the address 0x0100
> >> > + */
> >> > +#define TARGET_PAGE_BITS 8
> >> > +#define TARGET_PHYS_ADDR_SPACE_BITS 24
> >> > +#define TARGET_VIRT_ADDR_SPACE_BITS 24
> >> > +#define NB_MMU_MODES 2
> >> > +
> >> > +
> >> > +#endif
> >> > diff --git a/target/avr/cpu.c b/target/avr/cpu.c
> >> > new file mode 100644
> >> > index 00..142fe54524
> >> > --- /dev/null
> >> > +++ b/target/avr/cpu.c
> >> > @@ -0,0 +1,599 @@
> >> > +/*
> >> > + * QEMU AVR CPU
> >> > + *
> >> > + * Copyright (c) 2016 Michael Rolnik
> >> > + *
> >> > + * 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.1 of 

Re: [Qemu-devel] [PATCH v23 1/7] target/avr: Add outward facing interfaces and core CPU logic

2019-06-27 Thread Michael Rolnik
I meant that if I take the proposed code it fails in the mentioned way

Sent from my cell phone, please ignore typos

On Thu, Jun 27, 2019, 7:02 PM Michael Rolnik  wrote:

> Hi Igor,
>
> if I run `make check` it fails with
> qemu-system-rx: unable to find CPU model 'rx62n'
> or
> qemu-system-avr: unable to find CPU model 'avr6'
>
> On Thu, Jun 27, 2019 at 2:28 PM Igor Mammedov  wrote:
>
>> On Thu, 27 Jun 2019 08:27:44 +0300
>> Michael Rolnik  wrote:
>>
>> > From: Sarah Harris 
>> >
>> > This includes:
>> > - CPU data structures
>> > - object model classes and functions
>> > - migration functions
>> > - GDB hooks
>> >
>> > Signed-off-by: Michael Rolnik 
>> > ---
>> >  gdb-xml/avr-cpu.xml|  49 
>> >  target/avr/cpu-param.h |  37 +++
>> >  target/avr/cpu.c   | 599 +
>> >  target/avr/cpu.h   | 283 +++
>> >  target/avr/gdbstub.c   |  85 ++
>> >  target/avr/machine.c   | 123 +
>> >  6 files changed, 1176 insertions(+)
>> >  create mode 100644 gdb-xml/avr-cpu.xml
>> >  create mode 100644 target/avr/cpu-param.h
>> >  create mode 100644 target/avr/cpu.c
>> >  create mode 100644 target/avr/cpu.h
>> >  create mode 100644 target/avr/gdbstub.c
>> >  create mode 100644 target/avr/machine.c
>> >
>> > diff --git a/gdb-xml/avr-cpu.xml b/gdb-xml/avr-cpu.xml
>> > new file mode 100644
>> > index 00..c4747f5b40
>> > --- /dev/null
>> > +++ b/gdb-xml/avr-cpu.xml
>> > @@ -0,0 +1,49 @@
>> > +
>> > +
>> > +
>> > +
>> > +
>> > +
>> > +
>> > +  
>> > +  
>> > +  
>> > +  
>> > +  
>> > +  
>> > +  
>> > +  
>> > +  
>> > +  
>> > +  
>> > +  
>> > +  
>> > +  
>> > +  
>> > +  
>> > +  
>> > +  
>> > +  
>> > +  
>> > +  
>> > +  
>> > +  
>> > +  
>> > +  
>> > +  
>> > +  
>> > +  
>> > +  
>> > +  
>> > +  
>> > +  
>> > +  
>> > +  
>> > +  
>> > +
>> > diff --git a/target/avr/cpu-param.h b/target/avr/cpu-param.h
>> > new file mode 100644
>> > index 00..5bbf985726
>> > --- /dev/null
>> > +++ b/target/avr/cpu-param.h
>> > @@ -0,0 +1,37 @@
>> > +/*
>> > + * QEMU AVR CPU
>> > + *
>> > + * Copyright (c) 2016 Michael Rolnik
>> > + *
>> > + * 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.1 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
>> > + * 
>> > + */
>> > +
>> > +#ifndef AVR_CPU_PARAM_H
>> > +#define AVR_CPU_PARAM_H 1
>> > +
>> > +#define TARGET_LONG_BITS 32
>> > +/*
>> > + * TARGET_PAGE_BITS cannot be more than 8 bits because
>> > + * 1.  all IO registers occupy [0x .. 0x00ff] address range, and
>> they
>> > + * should be implemented as a device and not memory
>> > + * 2.  SRAM starts at the address 0x0100
>> > + */
>> > +#define TARGET_PAGE_BITS 8
>> > +#define TARGET_PHYS_ADDR_SPACE_BITS 24
>> > +#define TARGET_VIRT_ADDR_SPACE_BITS 24
>> > +#define NB_MMU_MODES 2
>> > +
>> > +
>> > +#endif
>> > diff --git a/target/avr/cpu.c b/target/avr/cpu.c
>> > new file mode 100644
>> > index 00..142fe54524
>> > --- /dev/null
>> > +++ b/target/avr/cpu.c
>> > @@ -0,0 +1,599 @@
>> > +/*
>> > + * QEMU AVR CPU
>> > + *
>> > + * Copyright (c) 2016 Michael Rolnik
>> > + *
>> > + * 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.1 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
>> > + * 
>> > + */
>> > +
>> > +#include "qemu/osdep.h"
>> > +#include "qemu/qemu-print.h"
>> > +#include "qemu/log.h"
>> > +#include "cpu.h"
>> > +#include "exec/exec-all.h"
>> > +#include "qapi/error.h"
>> > +#include "hw/qdev-properties.h"
>> > +#include "migration/vmstate.h"
>> > +
>> > +static void avr_cpu_set_pc(CPUState *cs, vaddr value)
>> > +{
>> > +AVRCPU *cpu = AVR_CPU(cs);
>> > +
>> > +cpu->env.pc_w = value / 2; /* internally PC points to words */
>> > +}
>> > +
>> > 

Re: [Qemu-devel] [PATCH v23 1/7] target/avr: Add outward facing interfaces and core CPU logic

2019-06-27 Thread Michael Rolnik
Hi Igor,

if I run `make check` it fails with
qemu-system-rx: unable to find CPU model 'rx62n'
or
qemu-system-avr: unable to find CPU model 'avr6'

On Thu, Jun 27, 2019 at 2:28 PM Igor Mammedov  wrote:

> On Thu, 27 Jun 2019 08:27:44 +0300
> Michael Rolnik  wrote:
>
> > From: Sarah Harris 
> >
> > This includes:
> > - CPU data structures
> > - object model classes and functions
> > - migration functions
> > - GDB hooks
> >
> > Signed-off-by: Michael Rolnik 
> > ---
> >  gdb-xml/avr-cpu.xml|  49 
> >  target/avr/cpu-param.h |  37 +++
> >  target/avr/cpu.c   | 599 +
> >  target/avr/cpu.h   | 283 +++
> >  target/avr/gdbstub.c   |  85 ++
> >  target/avr/machine.c   | 123 +
> >  6 files changed, 1176 insertions(+)
> >  create mode 100644 gdb-xml/avr-cpu.xml
> >  create mode 100644 target/avr/cpu-param.h
> >  create mode 100644 target/avr/cpu.c
> >  create mode 100644 target/avr/cpu.h
> >  create mode 100644 target/avr/gdbstub.c
> >  create mode 100644 target/avr/machine.c
> >
> > diff --git a/gdb-xml/avr-cpu.xml b/gdb-xml/avr-cpu.xml
> > new file mode 100644
> > index 00..c4747f5b40
> > --- /dev/null
> > +++ b/gdb-xml/avr-cpu.xml
> > @@ -0,0 +1,49 @@
> > +
> > +
> > +
> > +
> > +
> > +
> > +
> > +  
> > +  
> > +  
> > +  
> > +  
> > +  
> > +  
> > +  
> > +  
> > +  
> > +  
> > +  
> > +  
> > +  
> > +  
> > +  
> > +  
> > +  
> > +  
> > +  
> > +  
> > +  
> > +  
> > +  
> > +  
> > +  
> > +  
> > +  
> > +  
> > +  
> > +  
> > +  
> > +  
> > +  
> > +  
> > +
> > diff --git a/target/avr/cpu-param.h b/target/avr/cpu-param.h
> > new file mode 100644
> > index 00..5bbf985726
> > --- /dev/null
> > +++ b/target/avr/cpu-param.h
> > @@ -0,0 +1,37 @@
> > +/*
> > + * QEMU AVR CPU
> > + *
> > + * Copyright (c) 2016 Michael Rolnik
> > + *
> > + * 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.1 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
> > + * 
> > + */
> > +
> > +#ifndef AVR_CPU_PARAM_H
> > +#define AVR_CPU_PARAM_H 1
> > +
> > +#define TARGET_LONG_BITS 32
> > +/*
> > + * TARGET_PAGE_BITS cannot be more than 8 bits because
> > + * 1.  all IO registers occupy [0x .. 0x00ff] address range, and
> they
> > + * should be implemented as a device and not memory
> > + * 2.  SRAM starts at the address 0x0100
> > + */
> > +#define TARGET_PAGE_BITS 8
> > +#define TARGET_PHYS_ADDR_SPACE_BITS 24
> > +#define TARGET_VIRT_ADDR_SPACE_BITS 24
> > +#define NB_MMU_MODES 2
> > +
> > +
> > +#endif
> > diff --git a/target/avr/cpu.c b/target/avr/cpu.c
> > new file mode 100644
> > index 00..142fe54524
> > --- /dev/null
> > +++ b/target/avr/cpu.c
> > @@ -0,0 +1,599 @@
> > +/*
> > + * QEMU AVR CPU
> > + *
> > + * Copyright (c) 2016 Michael Rolnik
> > + *
> > + * 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.1 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
> > + * 
> > + */
> > +
> > +#include "qemu/osdep.h"
> > +#include "qemu/qemu-print.h"
> > +#include "qemu/log.h"
> > +#include "cpu.h"
> > +#include "exec/exec-all.h"
> > +#include "qapi/error.h"
> > +#include "hw/qdev-properties.h"
> > +#include "migration/vmstate.h"
> > +
> > +static void avr_cpu_set_pc(CPUState *cs, vaddr value)
> > +{
> > +AVRCPU *cpu = AVR_CPU(cs);
> > +
> > +cpu->env.pc_w = value / 2; /* internally PC points to words */
> > +}
> > +
> > +static bool avr_cpu_has_work(CPUState *cs)
> > +{
> > +AVRCPU *cpu = AVR_CPU(cs);
> > +CPUAVRState *env = >env;
> > +
> > +return (cs->interrupt_request & (CPU_INTERRUPT_HARD |
> CPU_INTERRUPT_RESET))
> > +&& cpu_interrupts_enabled(env);
> > +}
> > +
> > +static void avr_cpu_synchronize_from_tb(CPUState *cs, TranslationBlock
> 

Re: [Qemu-devel] [PATCH v23 1/7] target/avr: Add outward facing interfaces and core CPU logic

2019-06-27 Thread Igor Mammedov
On Thu, 27 Jun 2019 08:27:44 +0300
Michael Rolnik  wrote:

> From: Sarah Harris 
> 
> This includes:
> - CPU data structures
> - object model classes and functions
> - migration functions
> - GDB hooks
> 
> Signed-off-by: Michael Rolnik 
> ---
>  gdb-xml/avr-cpu.xml|  49 
>  target/avr/cpu-param.h |  37 +++
>  target/avr/cpu.c   | 599 +
>  target/avr/cpu.h   | 283 +++
>  target/avr/gdbstub.c   |  85 ++
>  target/avr/machine.c   | 123 +
>  6 files changed, 1176 insertions(+)
>  create mode 100644 gdb-xml/avr-cpu.xml
>  create mode 100644 target/avr/cpu-param.h
>  create mode 100644 target/avr/cpu.c
>  create mode 100644 target/avr/cpu.h
>  create mode 100644 target/avr/gdbstub.c
>  create mode 100644 target/avr/machine.c
> 
> diff --git a/gdb-xml/avr-cpu.xml b/gdb-xml/avr-cpu.xml
> new file mode 100644
> index 00..c4747f5b40
> --- /dev/null
> +++ b/gdb-xml/avr-cpu.xml
> @@ -0,0 +1,49 @@
> +
> +
> +
> +
> +
> +
> +
> +  
> +  
> +  
> +  
> +  
> +  
> +  
> +  
> +  
> +  
> +  
> +  
> +  
> +  
> +  
> +  
> +  
> +  
> +  
> +  
> +  
> +  
> +  
> +  
> +  
> +  
> +  
> +  
> +  
> +  
> +  
> +  
> +  
> +  
> +  
> +
> diff --git a/target/avr/cpu-param.h b/target/avr/cpu-param.h
> new file mode 100644
> index 00..5bbf985726
> --- /dev/null
> +++ b/target/avr/cpu-param.h
> @@ -0,0 +1,37 @@
> +/*
> + * QEMU AVR CPU
> + *
> + * Copyright (c) 2016 Michael Rolnik
> + *
> + * 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.1 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
> + * 
> + */
> +
> +#ifndef AVR_CPU_PARAM_H
> +#define AVR_CPU_PARAM_H 1
> +
> +#define TARGET_LONG_BITS 32
> +/*
> + * TARGET_PAGE_BITS cannot be more than 8 bits because
> + * 1.  all IO registers occupy [0x .. 0x00ff] address range, and they
> + * should be implemented as a device and not memory
> + * 2.  SRAM starts at the address 0x0100
> + */
> +#define TARGET_PAGE_BITS 8
> +#define TARGET_PHYS_ADDR_SPACE_BITS 24
> +#define TARGET_VIRT_ADDR_SPACE_BITS 24
> +#define NB_MMU_MODES 2
> +
> +
> +#endif
> diff --git a/target/avr/cpu.c b/target/avr/cpu.c
> new file mode 100644
> index 00..142fe54524
> --- /dev/null
> +++ b/target/avr/cpu.c
> @@ -0,0 +1,599 @@
> +/*
> + * QEMU AVR CPU
> + *
> + * Copyright (c) 2016 Michael Rolnik
> + *
> + * 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.1 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
> + * 
> + */
> +
> +#include "qemu/osdep.h"
> +#include "qemu/qemu-print.h"
> +#include "qemu/log.h"
> +#include "cpu.h"
> +#include "exec/exec-all.h"
> +#include "qapi/error.h"
> +#include "hw/qdev-properties.h"
> +#include "migration/vmstate.h"
> +
> +static void avr_cpu_set_pc(CPUState *cs, vaddr value)
> +{
> +AVRCPU *cpu = AVR_CPU(cs);
> +
> +cpu->env.pc_w = value / 2; /* internally PC points to words */
> +}
> +
> +static bool avr_cpu_has_work(CPUState *cs)
> +{
> +AVRCPU *cpu = AVR_CPU(cs);
> +CPUAVRState *env = >env;
> +
> +return (cs->interrupt_request & (CPU_INTERRUPT_HARD | 
> CPU_INTERRUPT_RESET))
> +&& cpu_interrupts_enabled(env);
> +}
> +
> +static void avr_cpu_synchronize_from_tb(CPUState *cs, TranslationBlock *tb)
> +{
> +AVRCPU *cpu = AVR_CPU(cs);
> +CPUAVRState *env = >env;
> +
> +env->pc_w = tb->pc / 2; /* internally PC points to words */
> +}
> +
> +static void avr_cpu_reset(CPUState *cs)
> +{
> +AVRCPU *cpu = AVR_CPU(cs);
> +AVRCPUClass *mcc = AVR_CPU_GET_CLASS(cpu);
> +CPUAVRState *env = >env;
> +
> +mcc->parent_reset(cs);
> +
> +env->pc_w = 0;
> +env->sregI = 1;
> +env->sregC = 0;
> +env->sregZ = 0;
> +env->sregN = 0;
> +env->sregV = 0;
> +env->sregS = 0;
> +env->sregH = 0;
> +   

[Qemu-devel] [PATCH v23 1/7] target/avr: Add outward facing interfaces and core CPU logic

2019-06-26 Thread Michael Rolnik
From: Sarah Harris 

This includes:
- CPU data structures
- object model classes and functions
- migration functions
- GDB hooks

Signed-off-by: Michael Rolnik 
---
 gdb-xml/avr-cpu.xml|  49 
 target/avr/cpu-param.h |  37 +++
 target/avr/cpu.c   | 599 +
 target/avr/cpu.h   | 283 +++
 target/avr/gdbstub.c   |  85 ++
 target/avr/machine.c   | 123 +
 6 files changed, 1176 insertions(+)
 create mode 100644 gdb-xml/avr-cpu.xml
 create mode 100644 target/avr/cpu-param.h
 create mode 100644 target/avr/cpu.c
 create mode 100644 target/avr/cpu.h
 create mode 100644 target/avr/gdbstub.c
 create mode 100644 target/avr/machine.c

diff --git a/gdb-xml/avr-cpu.xml b/gdb-xml/avr-cpu.xml
new file mode 100644
index 00..c4747f5b40
--- /dev/null
+++ b/gdb-xml/avr-cpu.xml
@@ -0,0 +1,49 @@
+
+
+
+
+
+
+
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+
diff --git a/target/avr/cpu-param.h b/target/avr/cpu-param.h
new file mode 100644
index 00..5bbf985726
--- /dev/null
+++ b/target/avr/cpu-param.h
@@ -0,0 +1,37 @@
+/*
+ * QEMU AVR CPU
+ *
+ * Copyright (c) 2016 Michael Rolnik
+ *
+ * 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.1 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
+ * 
+ */
+
+#ifndef AVR_CPU_PARAM_H
+#define AVR_CPU_PARAM_H 1
+
+#define TARGET_LONG_BITS 32
+/*
+ * TARGET_PAGE_BITS cannot be more than 8 bits because
+ * 1.  all IO registers occupy [0x .. 0x00ff] address range, and they
+ * should be implemented as a device and not memory
+ * 2.  SRAM starts at the address 0x0100
+ */
+#define TARGET_PAGE_BITS 8
+#define TARGET_PHYS_ADDR_SPACE_BITS 24
+#define TARGET_VIRT_ADDR_SPACE_BITS 24
+#define NB_MMU_MODES 2
+
+
+#endif
diff --git a/target/avr/cpu.c b/target/avr/cpu.c
new file mode 100644
index 00..142fe54524
--- /dev/null
+++ b/target/avr/cpu.c
@@ -0,0 +1,599 @@
+/*
+ * QEMU AVR CPU
+ *
+ * Copyright (c) 2016 Michael Rolnik
+ *
+ * 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.1 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
+ * 
+ */
+
+#include "qemu/osdep.h"
+#include "qemu/qemu-print.h"
+#include "qemu/log.h"
+#include "cpu.h"
+#include "exec/exec-all.h"
+#include "qapi/error.h"
+#include "hw/qdev-properties.h"
+#include "migration/vmstate.h"
+
+static void avr_cpu_set_pc(CPUState *cs, vaddr value)
+{
+AVRCPU *cpu = AVR_CPU(cs);
+
+cpu->env.pc_w = value / 2; /* internally PC points to words */
+}
+
+static bool avr_cpu_has_work(CPUState *cs)
+{
+AVRCPU *cpu = AVR_CPU(cs);
+CPUAVRState *env = >env;
+
+return (cs->interrupt_request & (CPU_INTERRUPT_HARD | CPU_INTERRUPT_RESET))
+&& cpu_interrupts_enabled(env);
+}
+
+static void avr_cpu_synchronize_from_tb(CPUState *cs, TranslationBlock *tb)
+{
+AVRCPU *cpu = AVR_CPU(cs);
+CPUAVRState *env = >env;
+
+env->pc_w = tb->pc / 2; /* internally PC points to words */
+}
+
+static void avr_cpu_reset(CPUState *cs)
+{
+AVRCPU *cpu = AVR_CPU(cs);
+AVRCPUClass *mcc = AVR_CPU_GET_CLASS(cpu);
+CPUAVRState *env = >env;
+
+mcc->parent_reset(cs);
+
+env->pc_w = 0;
+env->sregI = 1;
+env->sregC = 0;
+env->sregZ = 0;
+env->sregN = 0;
+env->sregV = 0;
+env->sregS = 0;
+env->sregH = 0;
+env->sregT = 0;
+
+env->rampD = 0;
+env->rampX = 0;
+env->rampY = 0;
+env->rampZ = 0;
+env->eind = 0;
+env->sp = 0;
+
+env->skip = 0;
+
+memset(env->r, 0, sizeof(env->r));
+
+tlb_flush(cs);
+}
+
+static void avr_cpu_disas_set_info(CPUState *cpu, disassemble_info *info)
+{
+info->mach = bfd_arch_avr;
+info->print_insn = NULL;
+}
+
+static void avr_cpu_realizefn(DeviceState *dev, Error **errp)
+{
+