r2025 - in trunk/src/host/qemu-neo1973: gnokiigsm hw
andrew at sita.openmoko.org
andrew at sita.openmoko.org
Fri May 18 22:48:52 CEST 2007
Author: andrew
Date: 2007-05-18 22:48:49 +0200 (Fri, 18 May 2007)
New Revision: 2025
Modified:
trunk/src/host/qemu-neo1973/gnokiigsm/at-emulator.c
trunk/src/host/qemu-neo1973/gnokiigsm/at-emulator.h
trunk/src/host/qemu-neo1973/gnokiigsm/compat.h
trunk/src/host/qemu-neo1973/gnokiigsm/datapump.c
trunk/src/host/qemu-neo1973/gnokiigsm/datapump.h
trunk/src/host/qemu-neo1973/gnokiigsm/statemachine.h
trunk/src/host/qemu-neo1973/gnokiigsm/virtmodem.c
trunk/src/host/qemu-neo1973/hw/modem.c
Log:
Adapt GSM emulator more to qemu APIs.
Modified: trunk/src/host/qemu-neo1973/gnokiigsm/at-emulator.c
===================================================================
--- trunk/src/host/qemu-neo1973/gnokiigsm/at-emulator.c 2007-05-18 20:22:05 UTC (rev 2024)
+++ trunk/src/host/qemu-neo1973/gnokiigsm/at-emulator.c 2007-05-18 20:48:49 UTC (rev 2025)
@@ -1,4 +1,8 @@
/*
+ * Copyright (c) 2007 OpenMoko, Inc.
+ * Modified for use in QEMU by Andrzej Zaborowski <andrew at openedhand.com>
+ */
+/*
$Id: at-emulator.c,v 1.45 2006/10/03 21:26:37 pkot Exp $
@@ -97,15 +101,12 @@
static char imei[64], model[64], revision[64], manufacturer[64];
/* Local variables */
-static int PtyRDFD; /* File descriptor for reading and writing to/from */
-static int PtyWRFD; /* pty interface - only different in debug mode. */
-
static u8 ModemRegisters[MAX_MODEM_REGISTERS];
static char CmdBuffer[MAX_CMD_BUFFERS][CMD_BUFFER_LENGTH];
static int CurrentCmdBuffer;
static int CurrentCmdBufferIndex;
static int IncomingCallNo;
-static int MessageFormat; /* Message Format (text or pdu) */
+static int MessageFormat; /* Message Format (text or pdu) */
static int CallerIDMode;
/* Current command parser */
@@ -117,11 +118,8 @@
/* If initialised in debug mode, stdin/out is used instead
of ptys for interface. */
-bool gn_atem_initialise(int read_fd, int write_fd, struct gn_statemachine *vmsm)
+bool gn_atem_initialise(struct gn_statemachine *vmsm)
{
- PtyRDFD = read_fd;
- PtyWRFD = write_fd;
-
gn_data_clear(&data);
memset(&sms, 0, sizeof(sms));
memset(&callinfo, 0, sizeof(callinfo));
@@ -197,14 +195,14 @@
gn_sm_functions(GN_OP_CancelCall, &data, sm);
IncomingCallNo = -1;
}
- dp_Initialise(PtyRDFD, PtyWRFD);
+ dp_Initialise();
}
static void gn_atem_answer_phone(void)
{
/* For now we'll also initialise the datapump + rlp code again */
- dp_Initialise(PtyRDFD, PtyWRFD);
+ dp_Initialise();
data.call_notification = dp_CallPassup;
gn_sm_functions(GN_OP_SetCallNotification, &data, sm);
data.call_info->call_id = IncomingCallNo;
@@ -378,7 +376,7 @@
/* Dial Data :-) */
/* FIXME - should parse this better */
/* For now we'll also initialise the datapump + rlp code again */
- dp_Initialise(PtyRDFD, PtyWRFD);
+ dp_Initialise();
buf++;
if (toupper(*buf) == 'T' || toupper(*buf) == 'P') buf++;
while (*buf == ' ') buf++;
Modified: trunk/src/host/qemu-neo1973/gnokiigsm/at-emulator.h
===================================================================
--- trunk/src/host/qemu-neo1973/gnokiigsm/at-emulator.h 2007-05-18 20:22:05 UTC (rev 2024)
+++ trunk/src/host/qemu-neo1973/gnokiigsm/at-emulator.h 2007-05-18 20:48:49 UTC (rev 2025)
@@ -35,7 +35,7 @@
#include "gnokii.h"
/* Prototypes */
-bool gn_atem_initialise(int read_fd, int write_fd, struct gn_statemachine *sm);
+bool gn_atem_initialise(struct gn_statemachine *sm);
void gn_atem_incoming_data_handle(const char *buffer, int length);
void gn_atem_registers_init(void);
void gn_atem_string_out(char *buffer);
Modified: trunk/src/host/qemu-neo1973/gnokiigsm/compat.h
===================================================================
--- trunk/src/host/qemu-neo1973/gnokiigsm/compat.h 2007-05-18 20:22:05 UTC (rev 2024)
+++ trunk/src/host/qemu-neo1973/gnokiigsm/compat.h 2007-05-18 20:48:49 UTC (rev 2025)
@@ -61,11 +61,6 @@
#include "config-host.h"
#define VERSION "QEMU " QEMU_VERSION
-struct gsmmodem_info_s {
- void (*write)(void *opaque, const char *fmt, ...);
- void *opaque;
-};
-
#define GNOKII_API
#undef timerisset
Modified: trunk/src/host/qemu-neo1973/gnokiigsm/datapump.c
===================================================================
--- trunk/src/host/qemu-neo1973/gnokiigsm/datapump.c 2007-05-18 20:22:05 UTC (rev 2024)
+++ trunk/src/host/qemu-neo1973/gnokiigsm/datapump.c 2007-05-18 20:48:49 UTC (rev 2025)
@@ -62,15 +62,11 @@
extern bool CommandMode;
/* Local variables */
-static int PtyRDFD; /* File descriptor for reading and writing to/from */
-static int PtyWRFD; /* pty interface - only different in debug mode. */
u8 pluscount;
bool connected;
-bool dp_Initialise(int read_fd, int write_fd)
+bool dp_Initialise(void)
{
- PtyRDFD = read_fd;
- PtyWRFD = write_fd;
rlp_initialise(DP_SendRLPFrame, DP_CallBack);
rlp_user_request_set(Attach_Req, true);
pluscount = 0;
@@ -78,6 +74,8 @@
data.rlp_rx_callback = rlp_f96_frame_display;
gn_sm_functions(GN_OP_SetRLPRXCallback, &data, sm);
+ CommandMode = true;
+
return true;
}
@@ -88,7 +86,9 @@
switch(ind) {
case Data:
- if (CommandMode == false) write(PtyWRFD, buffer, length);
+ if (CommandMode == false)
+ sm->info->write(sm->info->opaque,
+ "%*s", length, buffer);
break;
case Conn_Ind:
if (CommandMode == false) gn_atem_modem_result(MR_CARRIER);
Modified: trunk/src/host/qemu-neo1973/gnokiigsm/datapump.h
===================================================================
--- trunk/src/host/qemu-neo1973/gnokiigsm/datapump.h 2007-05-18 20:22:05 UTC (rev 2024)
+++ trunk/src/host/qemu-neo1973/gnokiigsm/datapump.h 2007-05-18 20:48:49 UTC (rev 2025)
@@ -35,7 +35,7 @@
#include "gnokii.h"
/* Prototypes */
-bool dp_Initialise(int read_fd, int write_fd);
+bool dp_Initialise(void);
void dp_CallPassup(gn_call_status call_status, gn_call_info *call_info, struct gn_statemachine *state);
#endif /* _gnokii_data_datapump_h */
Modified: trunk/src/host/qemu-neo1973/gnokiigsm/statemachine.h
===================================================================
--- trunk/src/host/qemu-neo1973/gnokiigsm/statemachine.h 2007-05-18 20:22:05 UTC (rev 2024)
+++ trunk/src/host/qemu-neo1973/gnokiigsm/statemachine.h 2007-05-18 20:48:49 UTC (rev 2025)
@@ -98,6 +98,13 @@
struct gsmmodem_info_s *info;
};
+struct gsmmodem_info_s {
+ gn_error (*gn_sm_functions)(gn_operation op, gn_data *data,
+ struct gn_statemachine *sm);
+ void (*write)(void *opaque, const char *fmt, ...);
+ void *opaque;
+};
+
GNOKII_API gn_state gn_sm_loop(int timeout, struct gn_statemachine *state);
/* General way to call any driver function */
Modified: trunk/src/host/qemu-neo1973/gnokiigsm/virtmodem.c
===================================================================
--- trunk/src/host/qemu-neo1973/gnokiigsm/virtmodem.c 2007-05-18 20:22:05 UTC (rev 2024)
+++ trunk/src/host/qemu-neo1973/gnokiigsm/virtmodem.c 2007-05-18 20:48:49 UTC (rev 2025)
@@ -1,4 +1,8 @@
/*
+ * Copyright (c) 2007 OpenMoko, Inc.
+ * Modified for use in QEMU by Andrzej Zaborowski <andrew at openedhand.com>
+ */
+/*
$Id: virtmodem.c,v 1.49 2006/10/19 16:05:35 dforsi Exp $
@@ -58,6 +62,46 @@
#include "datapump.h"
#include "device.h"
+/* Functions from parts of GNOKII not included in QEMU */
+GNOKII_API void gn_data_clear(gn_data *data)
+{
+ memset(data, 0, sizeof(gn_data));
+}
+
+GNOKII_API gn_state gn_sm_loop(int timeout, struct gn_statemachine *state)
+{
+ return GN_SM_Initialised;
+}
+
+GNOKII_API gn_error gn_sm_functions(gn_operation op, gn_data *data,
+ struct gn_statemachine *sm)
+{
+ return sm->info->gn_sm_functions(op, data, sm);
+}
+
+GNOKII_API gn_error gn_sms_get(gn_data *data, struct gn_statemachine *state)
+{
+ return gn_sm_functions(GN_OP_GetSMS, data, state);
+}
+
+GNOKII_API gn_error gn_sms_send(gn_data *data, struct gn_statemachine *state)
+{
+ return gn_sm_functions(GN_OP_SendSMS, data, state);
+}
+
+bool GTerminateThread = false;
+
+GNOKII_API gn_error gn_cfg_phone_load(const char *iname,
+ struct gn_statemachine *state)
+{
+ return GN_ERR_NOTSUPPORTED;
+}
+
+GNOKII_API gn_error gn_gsm_initialise(struct gn_statemachine *sm)
+{
+ return GN_ERR_NOTSUPPORTED;
+}
+
/* Defines */
#ifndef AF_LOCAL
@@ -112,12 +156,12 @@
return (false);
}
- if (gn_atem_initialise(PtyRDFD, PtyWRFD, sm) != true) {
+ if (gn_atem_initialise(sm) != true) {
fprintf (stderr, _("gn_vm_initialise - gn_atem_initialise failed!\n"));
return (false);
}
- if (dp_Initialise(PtyRDFD, PtyWRFD) != true) {
+ if (dp_Initialise() != true) {
fprintf (stderr, _("gn_vm_Initialise - dp_Initialise failed!\n"));
return (false);
}
Modified: trunk/src/host/qemu-neo1973/hw/modem.c
===================================================================
--- trunk/src/host/qemu-neo1973/hw/modem.c 2007-05-18 20:22:05 UTC (rev 2024)
+++ trunk/src/host/qemu-neo1973/hw/modem.c 2007-05-18 20:48:49 UTC (rev 2025)
@@ -14,109 +14,82 @@
#include "at-emulator.h"
#include "datapump.h"
+struct modem_s {
+ int enable;
+ CharDriverState chr;
+#define FIFO_LEN 4096
+ int out_start;
+ int out_len;
+ char outfifo[FIFO_LEN];
+ QEMUTimer *out_tm;
+ int64_t baud_delay;
+
+ struct gn_statemachine state;
+ struct gsmmodem_info_s info;
+};
+
#define TICALYPSO_MANF "<manufacturer>"
#define TICALYPSO_MODEL "<model>"
#define TICALYPSO_REV "<revision>"
#define TICALYPSO_IMEI "<serial number>"
-bool GTerminateThread = false;
-
-GNOKII_API gn_error gn_cfg_phone_load(const char *iname,
- struct gn_statemachine *state)
+static gn_error modem_ops(gn_operation op, gn_data *data,
+ struct gn_statemachine *sm)
{
- return GN_ERR_NOTSUPPORTED;
-}
+ switch (op) {
+ case GN_OP_MakeCall:
+ fprintf(stderr, "%s: calling %s: busy.\n", __FUNCTION__,
+ data->call_info->number);
+ return GN_ERR_LINEBUSY;
-GNOKII_API gn_error gn_sm_functions(gn_operation op, gn_data *data,
- struct gn_statemachine *sm)
-{
- switch (op) {
- case GN_OP_MakeCall:
- fprintf(stderr, "%s: calling %s: busy.\n", __FUNCTION__,
- data->call_info->number);
- return GN_ERR_LINEBUSY;
+ case GN_OP_CancelCall:
+ fprintf(stderr, "%s: hangup.\n", __FUNCTION__);
+ break;
- case GN_OP_CancelCall:
- fprintf(stderr, "%s: hangup.\n", __FUNCTION__);
- break;
+ case GN_OP_GetSMS:
+ fprintf(stderr, "%s: SMS number %i requested\n",
+ __FUNCTION__, data->sms->number);
+ return GN_ERR_EMPTYLOCATION;
- case GN_OP_DeleteSMS:
- fprintf(stderr, "%s: deleting SMS number %i\n", __FUNCTION__,
- data->sms->number);
- return GN_ERR_EMPTYLOCATION;
+ case GN_OP_DeleteSMS:
+ fprintf(stderr, "%s: deleting SMS number %i\n", __FUNCTION__,
+ data->sms->number);
+ return GN_ERR_EMPTYLOCATION;
- case GN_OP_GetRFLevel:
- *data->rf_level = 32.0f; /* Some -50 dBm */
- break;
+ case GN_OP_SendSMS:
+ fprintf(stderr, "%s: SMS type 0x%02x sent\n",
+ __FUNCTION__, data->sms->type);
+ return GN_ERR_NOTSUPPORTED;
- case GN_OP_GetImei:
- strcpy(data->imei, TICALYPSO_IMEI);
- break;
+ case GN_OP_GetRFLevel:
+ *data->rf_level = 32.0f; /* Some -50 dBm */
+ break;
- case GN_OP_GetRevision:
- strcpy(data->revision, TICALYPSO_REV);
- break;
+ case GN_OP_GetImei:
+ strcpy(data->imei, TICALYPSO_IMEI);
+ break;
- case GN_OP_GetModel:
- strcpy(data->revision, TICALYPSO_MODEL);
- break;
+ case GN_OP_GetRevision:
+ strcpy(data->revision, TICALYPSO_REV);
+ break;
- case GN_OP_Identify:
- strcpy(data->model, TICALYPSO_MODEL);
- strcpy(data->revision, TICALYPSO_REV);
- strcpy(data->imei, TICALYPSO_IMEI);
- strcpy(data->manufacturer, TICALYPSO_MANF);
- break;
+ case GN_OP_GetModel:
+ strcpy(data->revision, TICALYPSO_MODEL);
+ break;
- default:
- return GN_ERR_NOTSUPPORTED;
- }
- return GN_ERR_NONE;
-}
+ case GN_OP_Identify:
+ strcpy(data->model, TICALYPSO_MODEL);
+ strcpy(data->revision, TICALYPSO_REV);
+ strcpy(data->imei, TICALYPSO_IMEI);
+ strcpy(data->manufacturer, TICALYPSO_MANF);
+ break;
-GNOKII_API gn_error gn_gsm_initialise(struct gn_statemachine *sm)
-{
- return GN_ERR_NOTSUPPORTED;
+ default:
+ return GN_ERR_NOTSUPPORTED;
+ }
+ return GN_ERR_NONE;
}
-GNOKII_API void gn_data_clear(gn_data *data)
-{
- memset(data, 0, sizeof(gn_data));
-}
-
-GNOKII_API gn_state gn_sm_loop(int timeout, struct gn_statemachine *state)
-{
- return GN_ERR_NOTSUPPORTED;
-}
-
-GNOKII_API gn_error gn_sms_get(gn_data *data, struct gn_statemachine *state)
-{
- fprintf(stderr, "%s: SMS number %i requested\n",
- __FUNCTION__, data->sms->number);
- return GN_ERR_EMPTYLOCATION;
-}
-
-GNOKII_API gn_error gn_sms_send(gn_data *data, struct gn_statemachine *state)
-{
- fprintf(stderr, "%s: SMS type 0x%02x sent\n",
- __FUNCTION__, data->sms->type);
- return GN_ERR_NOTSUPPORTED;
-}
-
-struct modem_s {
- int enable;
- CharDriverState chr;
-#define FIFO_LEN 4096
- int out_start;
- int out_len;
- char outfifo[FIFO_LEN];
- QEMUTimer *out_tm;
- int64_t baud_delay;
-
- struct gn_statemachine state;
- struct gsmmodem_info_s info;
-};
-
static void modem_reset(struct modem_s *s)
{
s->out_len = 0;
@@ -223,12 +196,13 @@
s->state.info = &s->info;
s->info.write = modem_resp;
+ s->info.gn_sm_functions = modem_ops;
s->info.opaque = s;
- if (!gn_atem_initialise(0, 1, &s->state))
+ if (!gn_atem_initialise(&s->state))
goto fail;
- if (!dp_Initialise(0, 1))
+ if (!dp_Initialise())
goto fail;
return &s->chr;
More information about the commitlog
mailing list