src: use namespace prefix osmo_* for utils
[osmocom-bb.git] / src / host / osmocon / osmoload.c
index 7ed7563..5848e56 100644 (file)
 #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>
 
@@ -48,7 +48,7 @@
 
 #define DEFAULT_SOCKET "/tmp/osmocom_loader"
 
-static struct bsc_fd connection;
+static struct osmo_fd connection;
 
 enum {
        STATE_INIT,
@@ -84,7 +84,7 @@ static struct {
        uint8_t command;
 
        /* general timeout */
-       struct timer_list timeout;
+       struct osmo_timer_list timeout;
 
        /* binary i/o for firmware images */
        FILE *binfile;
@@ -146,7 +146,7 @@ static int version(const char *name)
        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;
@@ -190,7 +190,7 @@ loader_send_request(struct msgb *msg) {
 
        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));
@@ -277,7 +277,7 @@ static void
 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);
@@ -338,7 +338,7 @@ loader_handle_reply(struct msgb *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;
        }
@@ -364,7 +364,7 @@ loader_handle_reply(struct msgb *msg) {
                        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);
@@ -451,7 +451,7 @@ loader_handle_reply(struct msgb *msg) {
 }
 
 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;
@@ -494,7 +494,7 @@ static void
 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));
@@ -517,7 +517,7 @@ loader_connect(const char *socket_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);
        }
@@ -661,11 +661,11 @@ loader_do_memload() {
                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");
@@ -701,11 +701,11 @@ loader_do_fprogram() {
                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");
@@ -1143,7 +1143,7 @@ loader_command(char *name, int cmdc, char **cmdv) {
 
        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;
@@ -1205,7 +1205,7 @@ main(int argc, char **argv) {
        loader_command(argv[0], argc - optind, argv + optind);
 
        while(!osmoload.quit) {
-               bsc_select_main(0);
+               osmo_select_main(0);
        }
 
        if(osmoload.binfile) {