diff --git a/hw/rtc/mc146818rtc.c b/hw/rtc/mc146818rtc.c
index 3b7a3563087..d155444c4ef 100644
--- a/hw/rtc/mc146818rtc.c
+++ b/hw/rtc/mc146818rtc.c
@@ -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)
diff --git a/hw/xbox/xbox.c b/hw/xbox/xbox.c
index 9dda7a4cc04..c37483ee413 100644
--- a/hw/xbox/xbox.c
+++ b/hw/xbox/xbox.c
@@ -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;
 
@@ -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);