Skip to content

Commit

Permalink
mc146818rtc: Move Xbox RTC init pattern to reset handler
Browse files Browse the repository at this point in the history
  • Loading branch information
mborgerson committed Jan 6, 2025
1 parent 4a61eb8 commit 5eeb054
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
14 changes: 14 additions & 0 deletions hw/rtc/mc146818rtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,20 @@ static void rtc_reset_enter(Object *obj, ResetType type)
s->irq_coalesced = 0;
s->irq_reinject_on_ack_count = 0;
}

// xbox bios wants this bit pattern set to mark the data as valid
#ifdef XBOX
uint8_t bits = 0x55;
for (int i = 0x10; i < 0x70; i++) {
mc146818rtc_set_cmos_data(s, i, bits);
bits = ~bits;
}
bits = 0x55;
for (int i = 0x80; i < 0x100; i++) {
mc146818rtc_set_cmos_data(s, i, bits);
bits = ~bits;
}
#endif
}

static void rtc_reset_hold(Object *obj, ResetType type)
Expand Down
14 changes: 0 additions & 14 deletions hw/xbox/xbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,6 @@ void xbox_init_common(MachineState *machine,
MemoryRegion *system_memory = get_system_memory();
// MemoryRegion *system_io = get_system_io();

int i;

PCIBus *pci_bus;
ISABus *isa_bus;

Expand Down Expand Up @@ -298,18 +296,6 @@ void xbox_init_common(MachineState *machine,
// idebus[0] = qdev_get_child_bus(&dev->qdev, "ide.0");
// idebus[1] = qdev_get_child_bus(&dev->qdev, "ide.1");

// xbox bios wants this bit pattern set to mark the data as valid
uint8_t bits = 0x55;
for (i = 0x10; i < 0x70; i++) {
mc146818rtc_set_cmos_data(rtc_state, i, bits);
bits = ~bits;
}
bits = 0x55;
for (i = 0x80; i < 0x100; i++) {
mc146818rtc_set_cmos_data(rtc_state, i, bits);
bits = ~bits;
}

/* smbus devices */
smbus_xbox_smc_init(smbus, 0x10);

Expand Down

0 comments on commit 5eeb054

Please sign in to comment.