qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Marcel Apfelbaum <marcel@redhat.com>
To: "Hervé Poussineau" <hpoussin@reactos.org>,
	"Aurelien Jarno" <aurelien@aurel32.net>,
	"Yongbok Kim" <yongbok.kim@mips.com>,
	"Michael S . Tsirkin" <mst@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v3 06/16] piix4: add Reset Control Register
Date: Thu, 4 Jan 2018 17:50:06 +0200	[thread overview]
Message-ID: <f888dde1-6b46-b9f5-f819-6fb8d48019de@redhat.com> (raw)
In-Reply-To: <20171229142922.31701-7-hpoussin@reactos.org>

On 29/12/2017 16:29, Hervé Poussineau wrote:
> The RCR I/O port (0xcf9) is used to generate a hard reset or a soft reset.
> 
> Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
> ---
>   hw/isa/piix4.c | 35 +++++++++++++++++++++++++++++++++++
>   1 file changed, 35 insertions(+)
> 
> diff --git a/hw/isa/piix4.c b/hw/isa/piix4.c
> index 4f476dc7e6..7c83e7c23d 100644
> --- a/hw/isa/piix4.c
> +++ b/hw/isa/piix4.c
> @@ -2,6 +2,7 @@
>    * QEMU PIIX4 PCI Bridge Emulation
>    *
>    * Copyright (c) 2006 Fabrice Bellard
> + * Copyright (c) 2016 Hervé Poussineau

I think 2018 :)

>    *
>    * Permission is hereby granted, free of charge, to any person obtaining a copy
>    * of this software and associated documentation files (the "Software"), to deal
> @@ -33,6 +34,10 @@ PCIDevice *piix4_dev;
>   
>   typedef struct PIIX4State {
>       PCIDevice dev;
> +
> +    /* Reset Control Register */
> +    MemoryRegion rcr_mem;
> +    uint8_t rcr;
>   } PIIX4State;
>   
>   #define TYPE_PIIX4_PCI_DEVICE "PIIX4"
> @@ -87,6 +92,30 @@ static const VMStateDescription vmstate_piix4 = {
>       }
>   };
>   
> +static void piix4_rcr_write(void *opaque, hwaddr addr, uint64_t val,
> +                            unsigned int len)
> +{
> +    PIIX4State *s = opaque;
> +
> +    if (val & 4) {
> +        qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
> +        return;
> +    }
> +    s->rcr = val & 2; /* keep System Reset type only */

How does it work? When do we reset the value?

> +}
> +
> +static uint64_t piix4_rcr_read(void *opaque, hwaddr addr, unsigned int len)
> +{
> +    PIIX4State *s = opaque;
> +    return s->rcr;
> +}
> +
> +static const MemoryRegionOps piix4_rcr_ops = {
> +    .read = piix4_rcr_read,
> +    .write = piix4_rcr_write,
> +    .endianness = DEVICE_LITTLE_ENDIAN

Maybe we need to specify the access_size.
Something like:
.impl = {
         .min_access_size = 1,
         .max_access_size = 1,
     },

Thanks,
Marcel

> +};
> +
>   static void piix4_realize(PCIDevice *pci, Error **errp)
>   {
>       DeviceState *dev = DEVICE(pci);
> @@ -96,6 +125,12 @@ static void piix4_realize(PCIDevice *pci, Error **errp)
>                        pci_address_space_io(pci), errp)) {
>           return;
>       }
> +
> +    memory_region_init_io(&s->rcr_mem, OBJECT(dev), &piix4_rcr_ops, s,
> +                          "reset-control", 1);
> +    memory_region_add_subregion_overlap(pci_address_space_io(pci), 0xcf9,
> +                                        &s->rcr_mem, 1);
> +
>       piix4_dev = pci;
>       qemu_register_reset(piix4_reset, s);
>   }
> 

  reply	other threads:[~2018-01-04 15:50 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-29 14:29 [Qemu-devel] [PATCH v3 00/16] piix4: cleanup and improvements Hervé Poussineau
2017-12-29 14:29 ` [Qemu-devel] [PATCH v3 01/16] fdc: move object structures to header file Hervé Poussineau
2018-01-04 13:11   ` Marcel Apfelbaum
2018-01-04 20:33     ` Hervé Poussineau
2017-12-29 14:29 ` [Qemu-devel] [PATCH v3 02/16] serial/parallel: " Hervé Poussineau
2017-12-29 14:29 ` [Qemu-devel] [PATCH v3 03/16] mc146818rtc: move structure " Hervé Poussineau
2017-12-29 14:29 ` [Qemu-devel] [PATCH v3 04/16] mc146818rtc: always register rtc to rtc list Hervé Poussineau
2018-01-04 14:30   ` Marcel Apfelbaum
2018-01-04 20:34     ` Hervé Poussineau
2017-12-29 14:29 ` [Qemu-devel] [PATCH v3 05/16] piix4: rename some variables in realize function Hervé Poussineau
2018-01-04 14:33   ` Marcel Apfelbaum
2018-01-04 20:36     ` Hervé Poussineau
2017-12-29 14:29 ` [Qemu-devel] [PATCH v3 06/16] piix4: add Reset Control Register Hervé Poussineau
2018-01-04 15:50   ` Marcel Apfelbaum [this message]
2018-01-04 20:53     ` Hervé Poussineau
2017-12-29 14:29 ` [Qemu-devel] [PATCH v3 07/16] piix4: add a i8259 interrupt controller as specified in datasheet Hervé Poussineau
2018-01-04 23:21   ` Michael S. Tsirkin
2018-01-05  6:13     ` Hervé Poussineau
2017-12-29 14:29 ` [Qemu-devel] [PATCH v3 08/16] piix4: add a i8257 dma " Hervé Poussineau
2017-12-29 14:29 ` [Qemu-devel] [PATCH v3 09/16] piix4: add a i8254 pit " Hervé Poussineau
2017-12-29 14:29 ` [Qemu-devel] [PATCH v3 10/16] piix4: add a i8042 keyboard/mouse " Hervé Poussineau
2017-12-29 14:29 ` [Qemu-devel] [PATCH v3 11/16] piix4: add a floppy controller, 1 parallel port and 2 serial ports Hervé Poussineau
2017-12-29 14:29 ` [Qemu-devel] [PATCH v3 12/16] piix4: add a mc146818rtc controller as specified in datasheet Hervé Poussineau
2017-12-29 14:29 ` [Qemu-devel] [PATCH v3 13/16] piix4: add a speaker " Hervé Poussineau
2017-12-29 14:29 ` [Qemu-devel] [PATCH v3 14/16] piix4: convert reset function to QOM Hervé Poussineau
2017-12-29 14:29 ` [Qemu-devel] [PATCH v3 15/16] piix4: rename PIIX4 object to piix4-isa Hervé Poussineau
2017-12-29 14:29 ` [Qemu-devel] [PATCH v3 16/16] piix4: we can now instanciate a PIIX4 with -device Hervé Poussineau
2018-01-04 23:25 ` [Qemu-devel] [PATCH v3 00/16] piix4: cleanup and improvements Michael S. Tsirkin
2018-01-05 11:07 ` Paolo Bonzini
2018-01-05 11:53   ` Philippe Mathieu-Daudé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f888dde1-6b46-b9f5-f819-6fb8d48019de@redhat.com \
    --to=marcel@redhat.com \
    --cc=aurelien@aurel32.net \
    --cc=hpoussin@reactos.org \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=yongbok.kim@mips.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).