All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Hervé Poussineau" <hpoussin@reactos.org>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] ESP: Add it_shift parameter
Date: Wed, 09 Apr 2008 13:13:11 +0200	[thread overview]
Message-ID: <47FCA4C7.9010307@reactos.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 322 bytes --]

Hi,

At the moment, ESP SCSI adapter is wired with an interface shift of 2 
(ie lower 2 bits of the address are ignored). This is true on SPARC 
Sun4c/Sun4d/Sun4m machines, but it is not true for MIPS Jazz machines.

Attached patches adds an arguments to the init function to define the 
interface shift.

Hervé

[-- Attachment #2: esp_it_shift.diff --]
[-- Type: text/plain, Size: 4123 bytes --]

Index: hw/esp.c
===================================================================
--- hw/esp.c	(revision 4183)
+++ hw/esp.c	(working copy)
@@ -21,8 +21,8 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+
 #include "hw.h"
-#include "block.h"
 #include "scsi-disk.h"
 #include "scsi.h"
 
@@ -44,14 +44,13 @@
 #define DPRINTF(fmt, args...)
 #endif
 
-#define ESP_MASK 0x3f
 #define ESP_REGS 16
-#define ESP_SIZE (ESP_REGS * 4)
 #define TI_BUFSZ 32
 
 typedef struct ESPState ESPState;
 
 struct ESPState {
+    uint32_t it_shift;
     qemu_irq irq;
     uint8_t rregs[ESP_REGS];
     uint8_t wregs[ESP_REGS];
@@ -403,7 +402,7 @@
     ESPState *s = opaque;
     uint32_t saddr;
 
-    saddr = (addr & ESP_MASK) >> 2;
+    saddr = (addr >> s->it_shift) & (ESP_REGS - 1);
     DPRINTF("read reg[%d]: 0x%2.2x\n", saddr, s->rregs[saddr]);
     switch (saddr) {
     case ESP_FIFO:
@@ -439,7 +438,7 @@
     ESPState *s = opaque;
     uint32_t saddr;
 
-    saddr = (addr & ESP_MASK) >> 2;
+    saddr = (addr >> s->it_shift) & (ESP_REGS - 1);
     DPRINTF("write reg[%d]: 0x%2.2x -> 0x%2.2x\n", saddr, s->wregs[saddr],
             val);
     switch (saddr) {
@@ -621,7 +620,7 @@
         s->scsi_dev[id] = scsi_disk_init(bd, 0, esp_command_complete, s);
 }
 
-void *esp_init(target_phys_addr_t espaddr,
+void *esp_init(target_phys_addr_t espaddr, int it_shift,
                espdma_memory_read_write dma_memory_read,
                espdma_memory_read_write dma_memory_write,
                void *dma_opaque, qemu_irq irq, qemu_irq *reset)
@@ -634,12 +633,13 @@
         return NULL;
 
     s->irq = irq;
+    s->it_shift = it_shift;
     s->dma_memory_read = dma_memory_read;
     s->dma_memory_write = dma_memory_write;
     s->dma_opaque = dma_opaque;
 
     esp_io_memory = cpu_register_io_memory(0, esp_mem_read, esp_mem_write, s);
-    cpu_register_physical_memory(espaddr, ESP_SIZE, esp_io_memory);
+    cpu_register_physical_memory(espaddr, ESP_REGS << it_shift, esp_io_memory);
 
     esp_reset(s);
 
Index: hw/mips_jazz.c
===================================================================
--- hw/mips_jazz.c	(revision 4183)
+++ hw/mips_jazz.c	(working copy)
@@ -200,7 +200,7 @@
     /* FIXME: missing NS SONIC DP83932 */
 
     /* SCSI adapter */
-    scsi_hba = esp_init(0x80002000,
+    scsi_hba = esp_init(0x80002000, 0,
                         espdma_memory_read, espdma_memory_write, NULL,
                         rc4030[5], &esp_reset);
     for (n = 0; n < ESP_MAX_DEVS; n++) {
Index: hw/scsi.h
===================================================================
--- hw/scsi.h	(revision 4183)
+++ hw/scsi.h	(working copy)
@@ -2,7 +2,7 @@
 #define ESP_MAX_DEVS 7
 typedef void (*espdma_memory_read_write)(void *opaque, uint8_t *buf, int len);
 void esp_scsi_attach(void *opaque, BlockDriverState *bd, int id);
-void *esp_init(target_phys_addr_t espaddr,
+void *esp_init(target_phys_addr_t espaddr, int it_shift,
                espdma_memory_read_write dma_memory_read,
                espdma_memory_read_write dma_memory_write,
                void *dma_opaque, qemu_irq irq, qemu_irq *reset);
Index: hw/sun4m.c
===================================================================
--- hw/sun4m.c	(revision 4183)
+++ hw/sun4m.c	(working copy)
@@ -516,7 +516,7 @@
         exit(1);
     }
 
-    main_esp = esp_init(hwdef->esp_base,
+    main_esp = esp_init(hwdef->esp_base, 2,
                         espdma_memory_read, espdma_memory_write,
                         espdma, *espdma_irq, esp_reset);
 
@@ -668,7 +668,7 @@
         exit(1);
     }
 
-    main_esp = esp_init(hwdef->esp_base,
+    main_esp = esp_init(hwdef->esp_base, 2,
                         espdma_memory_read, espdma_memory_write,
                         espdma, *espdma_irq, esp_reset);
 
@@ -1460,7 +1460,7 @@
         exit(1);
     }
 
-    main_esp = esp_init(hwdef->esp_base,
+    main_esp = esp_init(hwdef->esp_base, 2,
                         espdma_memory_read, espdma_memory_write,
                         espdma, *espdma_irq, esp_reset);
 

                 reply	other threads:[~2008-04-09 11:13 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=47FCA4C7.9010307@reactos.org \
    --to=hpoussin@reactos.org \
    --cc=qemu-devel@nongnu.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.