1 /* This file is included from monitor.c, it's purpose is to hold as much 2 * Android-specific stuff as possible to ease upstream integrations. 3 */ 4 5 Monitor* 6 monitor_fake_new(void* opaque, MonitorFakeFunc cb) 7 { 8 Monitor* mon; 9 10 assert(cb != NULL); 11 mon = qemu_mallocz(sizeof(*mon)); 12 mon->fake_opaque = opaque; 13 mon->fake_func = cb; 14 mon->fake_count = 0; 15 16 return mon; 17 } 18 19 int 20 monitor_fake_get_bytes(Monitor* mon) 21 { 22 assert(mon->fake_func != NULL); 23 return mon->fake_count; 24 } 25 26 void 27 monitor_fake_free(Monitor* mon) 28 { 29 assert(mon->fake_func != NULL); 30 free(mon); 31 } 32 33 /* This replaces the definition in monitor.c which is in a 34 * #ifndef CONFIG_ANDROID .. #endif block. 35 */ 36 void monitor_flush(Monitor *mon) 37 { 38 if (!mon) 39 return; 40 41 if (mon->fake_func != NULL) { 42 mon->fake_func(mon->fake_opaque, (void*)mon->outbuf, mon->outbuf_index); 43 mon->outbuf_index = 0; 44 mon->fake_count += mon->outbuf_index; 45 } else if (!mon->mux_out) { 46 qemu_chr_write(mon->chr, mon->outbuf, mon->outbuf_index); 47 mon->outbuf_index = 0; 48 } 49 } 50