diff options
author | Vladimir Chtchetkine <vchtchetkine@google.com> | 2010-07-15 12:27:56 -0700 |
---|---|---|
committer | Vladimir Chtchetkine <vchtchetkine@google.com> | 2010-07-15 12:27:56 -0700 |
commit | eb8382507c6b802f378cf940fae4775633c1d84e (patch) | |
tree | d5974956e7487b2cb3af339abff2139d28e4b091 | |
parent | 7258f6b1539906849d02fa9f5e75360b0d01f48c (diff) | |
download | external_qemu-eb8382507c6b802f378cf940fae4775633c1d84e.zip external_qemu-eb8382507c6b802f378cf940fae4775633c1d84e.tar.gz external_qemu-eb8382507c6b802f378cf940fae4775633c1d84e.tar.bz2 |
Move net-related routines from main.c to net-android.c
Change-Id: If102220e6db913f4a51bb1809ce60f4bf24bdd6a
-rw-r--r-- | Makefile.android | 8 | ||||
-rw-r--r-- | android/android.h | 4 | ||||
-rw-r--r-- | android/cmdline-option.h | 4 | ||||
-rw-r--r-- | android/main.c | 106 | ||||
-rw-r--r-- | net-android.c | 100 | ||||
-rw-r--r-- | vl-android.c | 14 |
6 files changed, 121 insertions, 115 deletions
diff --git a/Makefile.android b/Makefile.android index dfbfdd3..533fc2b 100644 --- a/Makefile.android +++ b/Makefile.android @@ -602,7 +602,8 @@ endif # misc. sources # -CORE_MISC_SOURCES = console.c \ +CORE_MISC_SOURCES = vl-android.c \ + console.c \ loader.c \ monitor.c \ readline.c \ @@ -688,7 +689,6 @@ CORE_SOURCES += android/ui-core-protocol.c # UI_SOURCES = loadpng.c \ - keymaps.c \ android/user-config.c \ android/resource.c \ android/qemulator.c \ @@ -702,6 +702,7 @@ UI_SOURCES = loadpng.c \ UI_AND_CORE_SOURCES = osdep.c \ cutils.c \ sockets.c \ + keymaps.c \ android/keycode-array.c \ android/charmap.c \ android/hw-qemud.c \ @@ -785,8 +786,7 @@ endif # include other sources # -VL_SOURCES := vl-android.c \ - framebuffer.c \ +VL_SOURCES := framebuffer.c \ user-events-qemu.c \ android/cmdline-option.c \ android/config.c \ diff --git a/android/android.h b/android/android.h index ca6cfaf..62ef789 100644 --- a/android/android.h +++ b/android/android.h @@ -51,6 +51,10 @@ typedef struct { extern const NetworkLatency android_netdelays[]; +/* default network settings for emulator */ +#define DEFAULT_NETSPEED "full" +#define DEFAULT_NETDELAY "none" + /* enable/disable interrupt polling mode. the emulator will always use 100% * of host CPU time, but will get high-quality time measurments. this is * required for the tracing mode unless you can bear 10ms granularities diff --git a/android/cmdline-option.h b/android/cmdline-option.h index 90a7e64..6fba00a 100644 --- a/android/cmdline-option.h +++ b/android/cmdline-option.h @@ -43,8 +43,4 @@ android_parse_options( int *pargc, char** *pargv, AndroidOptions* opt ); */ #define DEFAULT_DEVICE_DPI 165 -/* default network settings for emulator */ -#define DEFAULT_NETSPEED "full" -#define DEFAULT_NETDELAY "none" - #endif /* _ANDROID_OPTION_H */ diff --git a/android/main.c b/android/main.c index 9248992..08e2966 100644 --- a/android/main.c +++ b/android/main.c @@ -223,30 +223,6 @@ sdl_set_window_icon( void ) } } -/* see http://en.wikipedia.org/wiki/List_of_device_bandwidths or a complete list */ -const NetworkSpeed android_netspeeds[] = { - { "gsm", "GSM/CSD", 14400, 14400 }, - { "hscsd", "HSCSD", 14400, 43200 }, - { "gprs", "GPRS", 40000, 80000 }, - { "edge", "EDGE/EGPRS", 118400, 236800 }, - { "umts", "UMTS/3G", 128000, 1920000 }, - { "hsdpa", "HSDPA", 348000, 14400000 }, - { "full", "no limit", 0, 0 }, - { NULL, NULL, 0, 0 } -}; - -const NetworkLatency android_netdelays[] = { - /* FIXME: these numbers are totally imaginary */ - { "gprs", "GPRS", 150, 550 }, - { "edge", "EDGE/EGPRS", 80, 400 }, - { "umts", "UMTS/3G", 35, 200 }, - { "none", "no latency", 0, 0 }, - { NULL, NULL, 0, 0 } -}; - - - - #define ONE_MB (1024*1024) unsigned convertBytesToMB( uint64_t size ) @@ -839,83 +815,6 @@ verbose_options[] = { { 0, 0, 0 } }; -int -android_parse_network_speed(const char* speed) -{ - int n; - char* end; - double sp; - - if (speed == NULL || speed[0] == 0) { - speed = DEFAULT_NETSPEED; - } - - for (n = 0; android_netspeeds[n].name != NULL; n++) { - if (!strcmp(android_netspeeds[n].name, speed)) { - qemu_net_download_speed = android_netspeeds[n].download; - qemu_net_upload_speed = android_netspeeds[n].upload; - return 0; - } - } - - /* is this a number ? */ - sp = strtod(speed, &end); - if (end == speed) { - return -1; - } - - qemu_net_download_speed = qemu_net_upload_speed = sp*1000.; - if (*end == ':') { - speed = end+1; - sp = strtod(speed, &end); - if (end > speed) { - qemu_net_download_speed = sp*1000.; - } - } - - if (android_modem) - amodem_set_data_network_type( android_modem, - android_parse_network_type(speed) ); - return 0; -} - - -int -android_parse_network_latency(const char* delay) -{ - int n; - char* end; - double sp; - - if (delay == NULL || delay[0] == 0) - delay = DEFAULT_NETDELAY; - - for (n = 0; android_netdelays[n].name != NULL; n++) { - if ( !strcmp( android_netdelays[n].name, delay ) ) { - qemu_net_min_latency = android_netdelays[n].min_ms; - qemu_net_max_latency = android_netdelays[n].max_ms; - return 0; - } - } - - /* is this a number ? */ - sp = strtod(delay, &end); - if (end == delay) { - return -1; - } - - qemu_net_min_latency = qemu_net_max_latency = (int)sp; - if (*end == ':') { - delay = (const char*)end+1; - sp = strtod(delay, &end); - if (end > delay) { - qemu_net_max_latency = (int)sp; - } - } - return 0; -} - - static int load_keyset(const char* path) { @@ -2320,8 +2219,3 @@ int main(int argc, char **argv) } return qemu_main(n, args); } - -void android_emulation_teardown( void ) -{ - android_charmap_done(); -} diff --git a/net-android.c b/net-android.c index 8649b82..cc1db96 100644 --- a/net-android.c +++ b/net-android.c @@ -130,8 +130,32 @@ #include "shaper.h" #endif +#include "android/android.h" +#include "telephony/modem_driver.h" + static VLANState *first_vlan; +/* see http://en.wikipedia.org/wiki/List_of_device_bandwidths or a complete list */ +const NetworkSpeed android_netspeeds[] = { + { "gsm", "GSM/CSD", 14400, 14400 }, + { "hscsd", "HSCSD", 14400, 43200 }, + { "gprs", "GPRS", 40000, 80000 }, + { "edge", "EDGE/EGPRS", 118400, 236800 }, + { "umts", "UMTS/3G", 128000, 1920000 }, + { "hsdpa", "HSDPA", 348000, 14400000 }, + { "full", "no limit", 0, 0 }, + { NULL, NULL, 0, 0 } +}; + +const NetworkLatency android_netdelays[] = { + /* FIXME: these numbers are totally imaginary */ + { "gprs", "GPRS", 150, 550 }, + { "edge", "EDGE/EGPRS", 80, 400 }, + { "umts", "UMTS/3G", 35, 200 }, + { "none", "no latency", 0, 0 }, + { NULL, NULL, 0, 0 } +}; + /***********************************************************/ /* network device redirectors */ @@ -2608,3 +2632,79 @@ void net_client_check(void) vlan->id); } } + +int +android_parse_network_speed(const char* speed) +{ + int n; + char* end; + double sp; + + if (speed == NULL || speed[0] == 0) { + speed = DEFAULT_NETSPEED; + } + + for (n = 0; android_netspeeds[n].name != NULL; n++) { + if (!strcmp(android_netspeeds[n].name, speed)) { + qemu_net_download_speed = android_netspeeds[n].download; + qemu_net_upload_speed = android_netspeeds[n].upload; + return 0; + } + } + + /* is this a number ? */ + sp = strtod(speed, &end); + if (end == speed) { + return -1; + } + + qemu_net_download_speed = qemu_net_upload_speed = sp*1000.; + if (*end == ':') { + speed = end+1; + sp = strtod(speed, &end); + if (end > speed) { + qemu_net_download_speed = sp*1000.; + } + } + + if (android_modem) + amodem_set_data_network_type( android_modem, + android_parse_network_type(speed) ); + return 0; +} + + +int +android_parse_network_latency(const char* delay) +{ + int n; + char* end; + double sp; + + if (delay == NULL || delay[0] == 0) + delay = DEFAULT_NETDELAY; + + for (n = 0; android_netdelays[n].name != NULL; n++) { + if ( !strcmp( android_netdelays[n].name, delay ) ) { + qemu_net_min_latency = android_netdelays[n].min_ms; + qemu_net_max_latency = android_netdelays[n].max_ms; + return 0; + } + } + + /* is this a number ? */ + sp = strtod(delay, &end); + if (end == delay) { + return -1; + } + + qemu_net_min_latency = qemu_net_max_latency = (int)sp; + if (*end == ':') { + delay = (const char*)end+1; + sp = strtod(delay, &end); + if (end > delay) { + qemu_net_max_latency = (int)sp; + } + } + return 0; +} diff --git a/vl-android.c b/vl-android.c index 4a373b3..1673426 100644 --- a/vl-android.c +++ b/vl-android.c @@ -53,6 +53,7 @@ #include "android/gps.h" #include "android/hw-qemud.h" #include "android/hw-kmsg.h" +#include "android/charmap.h" #include "targphys.h" #include <unistd.h> @@ -180,6 +181,11 @@ #include "kvm.h" #include "balloon.h" +#ifdef CONFIG_STANDALONE_CORE +/* Verbose value used by the standalone emulator core (without UI) */ +unsigned long android_verbose; +#endif // CONFIG_STANDALONE_CORE + #ifdef CONFIG_SKINS #undef main #define main qemu_main @@ -6168,7 +6174,7 @@ int main(int argc, char **argv, char **envp) curses_display_init(ds, full_screen); break; #endif -#if defined(CONFIG_SDL) +#if defined(CONFIG_SDL) && !defined(CONFIG_STANDALONE_CORE) case DT_SDL: sdl_display_init(ds, full_screen, no_frame); break; @@ -6326,3 +6332,9 @@ int main(int argc, char **argv, char **envp) android_emulation_teardown(); return 0; } + +void +android_emulation_teardown(void) +{ + android_charmap_done(); +} |