Skip to content

Commit

Permalink
Wire up TC signal from Aux1 to FDC
Browse files Browse the repository at this point in the history
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4096 c046a42c-6fe2-441c-8c8c-71466251a162
  • Loading branch information
blueswir1 committed Mar 21, 2008
1 parent cf2be98 commit 2be17eb
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 13 deletions.
13 changes: 12 additions & 1 deletion hw/fdc.c
Original file line number Diff line number Diff line change
Expand Up @@ -766,8 +766,18 @@ fdctrl_t *fdctrl_init (qemu_irq irq, int dma_chann, int mem_mapped,
return fdctrl;
}

static void fdctrl_handle_tc(void *opaque, int irq, int level)
{
//fdctrl_t *s = opaque;

if (level) {
// XXX
FLOPPY_DPRINTF("TC pulsed\n");
}
}

fdctrl_t *sun4m_fdctrl_init (qemu_irq irq, target_phys_addr_t io_base,
BlockDriverState **fds)
BlockDriverState **fds, qemu_irq *fdc_tc)
{
fdctrl_t *fdctrl;
int io_mem;
Expand All @@ -778,6 +788,7 @@ fdctrl_t *sun4m_fdctrl_init (qemu_irq irq, target_phys_addr_t io_base,
fdctrl_mem_write_strict,
fdctrl);
cpu_register_physical_memory(io_base, 0x08, io_mem);
*fdc_tc = *qemu_allocate_irqs(fdctrl_handle_tc, fdctrl, 1);

return fdctrl;
}
Expand Down
2 changes: 1 addition & 1 deletion hw/fdc.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ fdctrl_t *fdctrl_init (qemu_irq irq, int dma_chann, int mem_mapped,
target_phys_addr_t io_base,
BlockDriverState **fds);
fdctrl_t *sun4m_fdctrl_init (qemu_irq irq, target_phys_addr_t io_base,
BlockDriverState **fds);
BlockDriverState **fds, qemu_irq *fdc_tc);
int fdctrl_get_drive_type(fdctrl_t *fdctrl, int drive_num);
14 changes: 13 additions & 1 deletion hw/slavio_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ typedef struct MiscState {
uint32_t sysctrl;
uint16_t leds;
CPUState *env;
qemu_irq fdc_tc;
} MiscState;

#define MISC_SIZE 1
Expand All @@ -66,6 +67,8 @@ typedef struct MiscState {
#define MISC_MDM 0x01b00000
#define MISC_SYS 0x01f00000

#define AUX1_TC 0x02

#define AUX2_PWROFF 0x01
#define AUX2_PWRINTCLR 0x02
#define AUX2_PWRFAIL 0x20
Expand Down Expand Up @@ -175,6 +178,14 @@ static void slavio_aux1_mem_writeb(void *opaque, target_phys_addr_t addr,
MiscState *s = opaque;

MISC_DPRINTF("Write aux1 %2.2x\n", val & 0xff);
if (val & AUX1_TC) {
// Send a pulse to floppy terminal count line
if (s->fdc_tc) {
qemu_irq_raise(s->fdc_tc);
qemu_irq_lower(s->fdc_tc);
}
val &= ~AUX1_TC;
}
s->aux1 = val & 0xff;
}

Expand Down Expand Up @@ -407,7 +418,7 @@ static int slavio_misc_load(QEMUFile *f, void *opaque, int version_id)
void *slavio_misc_init(target_phys_addr_t base, target_phys_addr_t power_base,
target_phys_addr_t aux1_base,
target_phys_addr_t aux2_base, qemu_irq irq,
CPUState *env)
CPUState *env, qemu_irq **fdc_tc)
{
int io;
MiscState *s;
Expand Down Expand Up @@ -462,6 +473,7 @@ void *slavio_misc_init(target_phys_addr_t base, target_phys_addr_t power_base,

s->irq = irq;
s->env = env;
*fdc_tc = &s->fdc_tc;

register_savevm("slavio_misc", base, 1, slavio_misc_save, slavio_misc_load,
s);
Expand Down
24 changes: 15 additions & 9 deletions hw/sun4m.c
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ static void sun4m_hw_init(const struct hwdef *hwdef, int RAM_size,
qemu_irq *cpu_irqs[MAX_CPUS], *slavio_irq, *slavio_cpu_irq,
*espdma_irq, *ledma_irq;
qemu_irq *esp_reset, *le_reset;
qemu_irq *fdc_tc;
unsigned long prom_offset, kernel_size;
int ret;
char buf[1024];
Expand Down Expand Up @@ -494,14 +495,20 @@ static void sun4m_hw_init(const struct hwdef *hwdef, int RAM_size,
slavio_serial_init(hwdef->serial_base, slavio_irq[hwdef->ser_irq],
serial_hds[1], serial_hds[0]);

slavio_misc = slavio_misc_init(hwdef->slavio_base, hwdef->apc_base,
hwdef->aux1_base, hwdef->aux2_base,
slavio_irq[hwdef->me_irq], envs[0],
&fdc_tc);

if (hwdef->fd_base != (target_phys_addr_t)-1) {
/* there is zero or one floppy drive */
memset(fd, 0, sizeof(fd));
index = drive_get_index(IF_FLOPPY, 0, 0);
if (index != -1)
fd[0] = drives_table[index].bdrv;

sun4m_fdctrl_init(slavio_irq[hwdef->fd_irq], hwdef->fd_base, fd);
sun4m_fdctrl_init(slavio_irq[hwdef->fd_irq], hwdef->fd_base, fd,
fdc_tc);
}

if (drive_get_max_bus(IF_SCSI) > 0) {
Expand All @@ -520,9 +527,6 @@ static void sun4m_hw_init(const struct hwdef *hwdef, int RAM_size,
esp_scsi_attach(main_esp, drives_table[index].bdrv, i);
}

slavio_misc = slavio_misc_init(hwdef->slavio_base, hwdef->apc_base,
hwdef->aux1_base, hwdef->aux2_base,
slavio_irq[hwdef->me_irq], envs[0]);
if (hwdef->cs_base != (target_phys_addr_t)-1)
cs_init(hwdef->cs_base, hwdef->cs_irq, slavio_intctl);

Expand All @@ -549,6 +553,7 @@ static void sun4c_hw_init(const struct hwdef *hwdef, int RAM_size,
void *iommu, *espdma, *ledma, *main_esp, *nvram;
qemu_irq *cpu_irqs, *slavio_irq, *espdma_irq, *ledma_irq;
qemu_irq *esp_reset, *le_reset;
qemu_irq *fdc_tc;
unsigned long prom_offset, kernel_size;
int ret;
char buf[1024];
Expand Down Expand Up @@ -643,14 +648,19 @@ static void sun4c_hw_init(const struct hwdef *hwdef, int RAM_size,
slavio_serial_init(hwdef->serial_base, slavio_irq[hwdef->ser_irq],
serial_hds[1], serial_hds[0]);

slavio_misc = slavio_misc_init(-1, hwdef->apc_base,
hwdef->aux1_base, hwdef->aux2_base,
slavio_irq[hwdef->me_irq], env, &fdc_tc);

if (hwdef->fd_base != (target_phys_addr_t)-1) {
/* there is zero or one floppy drive */
fd[1] = fd[0] = NULL;
index = drive_get_index(IF_FLOPPY, 0, 0);
if (index != -1)
fd[0] = drives_table[index].bdrv;

sun4m_fdctrl_init(slavio_irq[hwdef->fd_irq], hwdef->fd_base, fd);
sun4m_fdctrl_init(slavio_irq[hwdef->fd_irq], hwdef->fd_base, fd,
fdc_tc);
}

if (drive_get_max_bus(IF_SCSI) > 0) {
Expand All @@ -669,10 +679,6 @@ static void sun4c_hw_init(const struct hwdef *hwdef, int RAM_size,
esp_scsi_attach(main_esp, drives_table[index].bdrv, i);
}

slavio_misc = slavio_misc_init(-1, hwdef->apc_base,
hwdef->aux1_base, hwdef->aux2_base,
slavio_irq[hwdef->me_irq], env);

kernel_size = sun4m_load_kernel(kernel_filename, kernel_cmdline,
initrd_filename);

Expand Down
2 changes: 1 addition & 1 deletion hw/sun4m.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void slavio_serial_ms_kbd_init(target_phys_addr_t base, qemu_irq irq,
void *slavio_misc_init(target_phys_addr_t base, target_phys_addr_t power_base,
target_phys_addr_t aux1_base,
target_phys_addr_t aux2_base, qemu_irq irq,
CPUState *env);
CPUState *env, qemu_irq **fdc_tc);
void slavio_set_power_fail(void *opaque, int power_failing);

/* cs4231.c */
Expand Down

0 comments on commit 2be17eb

Please sign in to comment.