|
| 1 | +// Copyright 2015 The Android Open Source Project |
| 2 | +// |
| 3 | +// This software is licensed under the terms of the GNU General Public |
| 4 | +// License version 2, as published by the Free Software Foundation, and |
| 5 | +// may be copied, distributed, and modified under those terms. |
| 6 | +// |
| 7 | +// This program is distributed in the hope that it will be useful, |
| 8 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | +// GNU General Public License for more details. |
| 11 | + |
| 12 | +#include "android-qemu1-glue/telephony/modem_init.h" |
| 13 | + |
| 14 | +#include "android/telephony/modem_driver.h" |
| 15 | + |
| 16 | +extern "C" { |
| 17 | + #include "hw/hw.h" |
| 18 | +} |
| 19 | + |
| 20 | +#define MODEM_DEV_STATE_SAVE_VERSION 1 |
| 21 | + |
| 22 | +static void modem_state_save(QEMUFile* file, void* opaque) |
| 23 | +{ |
| 24 | + amodem_state_save((AModem)opaque, (SysFile*)file); |
| 25 | +} |
| 26 | + |
| 27 | +static int modem_state_load(QEMUFile* file, void* opaque, int version_id) |
| 28 | +{ |
| 29 | + if (version_id != MODEM_DEV_STATE_SAVE_VERSION) |
| 30 | + return -1; |
| 31 | + |
| 32 | + return amodem_state_load((AModem)opaque, (SysFile*)file); |
| 33 | +} |
| 34 | + |
| 35 | + |
| 36 | +void qemu_android_modem_init(int base_port) { |
| 37 | + android_modem_init(base_port); |
| 38 | + |
| 39 | + if (android_modem_serial_line != nullptr) { |
| 40 | + register_savevm(nullptr, |
| 41 | + "android_modem", |
| 42 | + 0, |
| 43 | + MODEM_DEV_STATE_SAVE_VERSION, |
| 44 | + modem_state_save, |
| 45 | + modem_state_load, |
| 46 | + android_modem); |
| 47 | + } |
| 48 | +} |
0 commit comments