#include <sys/socket.h>
#include <sys/un.h>
-#include <osmocore/msgb.h>
-#include <osmocore/select.h>
-#include <osmocore/timer.h>
-#include <osmocore/crc16.h>
+#include <osmocom/core/msgb.h>
+#include <osmocom/core/select.h>
+#include <osmocom/core/timer.h>
+#include <osmocom/core/crc16.h>
#include <loader/protocol.h>
#define DEFAULT_SOCKET "/tmp/osmocom_loader"
-static struct bsc_fd connection;
+static struct osmo_fd connection;
enum {
STATE_INIT,
uint8_t command;
/* general timeout */
- struct timer_list timeout;
+ struct osmo_timer_list timeout;
/* binary i/o for firmware images */
FILE *binfile;
exit(2);
}
-static void hexdump(const uint8_t *data, unsigned int len)
+static void osmoload_osmo_hexdump(const uint8_t *data, unsigned int len)
{
const uint8_t *bufptr = data;
const uint8_t const *endptr = bufptr + len;
if(osmoload.print_requests) {
printf("Sending %d bytes:\n", msg->len);
- hexdump(msg->data, msg->len);
+ osmoload_osmo_hexdump(msg->data, msg->len);
}
rc = write(connection.fd, &len, sizeof(len));
loader_handle_reply(struct msgb *msg) {
if(osmoload.print_replies) {
printf("Received %d bytes:\n", msg->len);
- hexdump(msg->data, msg->len);
+ osmoload_osmo_hexdump(msg->data, msg->len);
}
uint8_t cmd = msgb_get_u8(msg);
break;
default:
printf("Received unknown reply %d:\n", cmd);
- hexdump(msg->data, msg->len);
+ osmoload_osmo_hexdump(msg->data, msg->len);
osmoload.quit = 1;
return;
}
break;
case LOADER_MEM_READ:
printf("Received memory dump of %d bytes at 0x%x:\n", length, address);
- hexdump(data, length);
+ osmoload_osmo_hexdump(data, length);
break;
case LOADER_MEM_WRITE:
printf("Confirmed memory write of %d bytes at 0x%x.\n", length, address);
}
static int
-loader_read_cb(struct bsc_fd *fd, unsigned int flags) {
+loader_read_cb(struct osmo_fd *fd, unsigned int flags) {
struct msgb *msg;
u_int16_t len;
int rc;
loader_connect(const char *socket_path) {
int rc;
struct sockaddr_un local;
- struct bsc_fd *conn = &connection;
+ struct osmo_fd *conn = &connection;
local.sun_family = AF_UNIX;
strncpy(local.sun_path, socket_path, sizeof(local.sun_path));
conn->cb = loader_read_cb;
conn->data = NULL;
- if (bsc_register_fd(conn) != 0) {
+ if (osmo_fd_register(conn) != 0) {
fprintf(stderr, "Failed to register fd.\n");
exit(1);
}
return;
}
- bsc_schedule_timer(&osmoload.timeout, 0, 500000);
+ osmo_timer_schedule(&osmoload.timeout, 0, 500000);
uint8_t reqbytes = (rembytes < MEM_MSG_MAX) ? rembytes : MEM_MSG_MAX;
- osmoload.memcrc = crc16(0, osmoload.binbuf + osmoload.memoff, reqbytes);
+ osmoload.memcrc = crc16(0, (uint8_t *) osmoload.binbuf + osmoload.memoff, reqbytes);
osmoload.memreq = reqbytes;
struct msgb *msg = msgb_alloc(MSGB_MAX, "loader");
return;
}
- bsc_schedule_timer(&osmoload.timeout, 0, 10000000);
+ osmo_timer_schedule(&osmoload.timeout, 0, 10000000);
uint8_t reqbytes = (rembytes < MEM_MSG_MAX) ? rembytes : MEM_MSG_MAX;
- osmoload.memcrc = crc16(0, osmoload.binbuf + osmoload.memoff, reqbytes);
+ osmoload.memcrc = crc16(0, (uint8_t *) osmoload.binbuf + osmoload.memoff, reqbytes);
osmoload.memreq = reqbytes;
struct msgb *msg = msgb_alloc(MSGB_MAX, "loader");
if(osmoload.state == STATE_QUERY_PENDING) {
osmoload.timeout.cb = &query_timeout;
- bsc_schedule_timer(&osmoload.timeout, 0, 5000000);
+ osmo_timer_schedule(&osmoload.timeout, 0, 5000000);
}
if(osmoload.state == STATE_LOAD_IN_PROGRESS) {
osmoload.timeout.cb = &memop_timeout;
loader_command(argv[0], argc - optind, argv + optind);
while(!osmoload.quit) {
- bsc_select_main(0);
+ osmo_select_main(0);
}
if(osmoload.binfile) {