1 /* 2 * QEMU model of the Canon DIGIC boards (cameras indeed :). 3 * 4 * Copyright (C) 2013 Antony Pavlov <antonynpavlov@gmail.com> 5 * 6 * This model is based on reverse engineering efforts 7 * made by CHDK (http://chdk.wikia.com) and 8 * Magic Lantern (http://www.magiclantern.fm) projects 9 * contributors. 10 * 11 * See docs here: 12 * http://magiclantern.wikia.com/wiki/Register_Map 13 * 14 * This program is free software; you can redistribute it and/or modify 15 * it under the terms of the GNU General Public License as published by 16 * the Free Software Foundation; either version 2 of the License, or 17 * (at your option) any later version. 18 * 19 * This program is distributed in the hope that it will be useful, 20 * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 * GNU General Public License for more details. 23 * 24 */ 25 26 #include "hw/boards.h" 27 #include "exec/address-spaces.h" 28 #include "qemu/error-report.h" 29 #include "hw/arm/digic.h" 30 31 typedef struct DigicBoardState { 32 DigicState *digic; 33 MemoryRegion ram; 34 } DigicBoardState; 35 36 typedef struct DigicBoard { 37 hwaddr ram_size; 38 } DigicBoard; 39 40 static void digic4_board_setup_ram(DigicBoardState *s, hwaddr ram_size) 41 { 42 memory_region_init_ram(&s->ram, NULL, "ram", ram_size); 43 memory_region_add_subregion(get_system_memory(), 0, &s->ram); 44 vmstate_register_ram_global(&s->ram); 45 } 46 47 static void digic4_board_init(DigicBoard *board) 48 { 49 Error *err = NULL; 50 51 DigicBoardState *s = g_new(DigicBoardState, 1); 52 53 s->digic = DIGIC(object_new(TYPE_DIGIC)); 54 object_property_set_bool(OBJECT(s->digic), true, "realized", &err); 55 if (err != NULL) { 56 error_report("Couldn't realize DIGIC SoC: %s\n", 57 error_get_pretty(err)); 58 exit(1); 59 } 60 61 digic4_board_setup_ram(s, board->ram_size); 62 } 63 64 static DigicBoard digic4_board_canon_a1100 = { 65 .ram_size = 64 * 1024 * 1024, 66 }; 67 68 static void canon_a1100_init(QEMUMachineInitArgs *args) 69 { 70 digic4_board_init(&digic4_board_canon_a1100); 71 } 72 73 static QEMUMachine canon_a1100 = { 74 .name = "canon-a1100", 75 .desc = "Canon PowerShot A1100 IS", 76 .init = &canon_a1100_init, 77 }; 78 79 static void digic_register_machines(void) 80 { 81 qemu_register_machine(&canon_a1100); 82 } 83 84 machine_init(digic_register_machines) 85