Beispiel #1
0
void platform_init(void)
{
    uart_init();

    /* detect any virtio devices */
    const uint virtio_irqs[] = { VIRTIO0_INT, VIRTIO1_INT, VIRTIO2_INT, VIRTIO3_INT };
    virtio_mmio_detect((void *)VIRTIO_BASE, 4, virtio_irqs);

#if WITH_LIB_MINIP
    if (virtio_net_found() > 0) {
        uint8_t mac_addr[6];

        virtio_net_get_mac_addr(mac_addr);

        TRACEF("found virtio networking interface\n");

        /* start minip */
        minip_set_macaddr(mac_addr);

        __UNUSED uint32_t ip_addr = IPV4(192, 168, 0, 99);
        __UNUSED uint32_t ip_mask = IPV4(255, 255, 255, 0);
        __UNUSED uint32_t ip_gateway = IPV4_NONE;

        //minip_init(virtio_net_send_minip_pkt, NULL, ip_addr, ip_mask, ip_gateway);
        minip_init_dhcp(virtio_net_send_minip_pkt, NULL);

        virtio_net_start();
    }
#endif
}
Beispiel #2
0
void platform_init(void)
{
    uart_init();

    /* detect any virtio devices */
    uint virtio_irqs[NUM_VIRTIO_TRANSPORTS];
    for (int i = 0; i < NUM_VIRTIO_TRANSPORTS; i++) {
        virtio_irqs[i] = VIRTIO0_INT + i;
    }

    virtio_mmio_detect((void *)VIRTIO_BASE, NUM_VIRTIO_TRANSPORTS, virtio_irqs);

#if WITH_LIB_MINIP
    if (virtio_net_found() > 0) {
        uint8_t mac_addr[6];

        virtio_net_get_mac_addr(mac_addr);

        TRACEF("found virtio networking interface\n");

        /* start minip */
        minip_set_macaddr(mac_addr);

        __UNUSED uint32_t ip_addr = IPV4(192, 168, 0, 99);
        __UNUSED uint32_t ip_mask = IPV4(255, 255, 255, 0);
        __UNUSED uint32_t ip_gateway = IPV4_NONE;

        //minip_init(virtio_net_send_minip_pkt, NULL, ip_addr, ip_mask, ip_gateway);
        minip_init_dhcp(virtio_net_send_minip_pkt, NULL);

        virtio_net_start();
    }
#endif
}
Beispiel #3
0
Datei: init.c Projekt: skabet/lk
void target_init(void)
{
    uint8_t* mac_addr = gen_mac_address();
    stm32_debug_init();

    eth_init(mac_addr, PHY_LAN8742A);
#if WITH_LIB_MINIP
    minip_set_macaddr(mac_addr);

    uint32_t ip_addr = IPV4(192, 168, 0, 98);
    uint32_t ip_mask = IPV4(255, 255, 255, 0);
    uint32_t ip_gateway = IPV4_NONE;
    minip_init(stm32_eth_send_minip_pkt, NULL, ip_addr, ip_mask, ip_gateway);
#endif
}
Beispiel #4
0
void target_init(void)
{
    stm32_debug_init();

    qspi_flash_init(N25Q128A_FLASH_SIZE);

#if ENABLE_LCD
    memory_lcd_init();
#endif

#if WITH_LIB_MINIP
    uint8_t mac_addr[6];
    gen_random_mac_address(mac_addr);
    eth_init(mac_addr, PHY_KSZ8721);

    /* start minip */
    minip_set_macaddr(mac_addr);

    uint32_t ip_addr = IPV4(192, 168, 0, 98);
    uint32_t ip_mask = IPV4(255, 255, 255, 0);
    uint32_t ip_gateway = IPV4_NONE;

    minip_init(stm32_eth_send_minip_pkt, NULL, ip_addr, ip_mask, ip_gateway);
#endif

#if WITH_LIB_FS_SPIFS
    status_t mount_success = fs_mount(DEAULT_SPIFS_MOUNT_POINT,
                                      DEAULT_SPIFS_NAME, SPIFS_TARGET_DEVICE);
    if (mount_success != NO_ERROR) {
        printf("failed to mount '%s' at path '%s' on '%s'."
               " Make sure that device is formatted\n",
               DEAULT_SPIFS_NAME, DEAULT_SPIFS_MOUNT_POINT,
               SPIFS_TARGET_DEVICE);
    }

#endif

    // start usb
    target_usb_setup();

#if ENABLE_SENSORBUS
    sensor_bus_init();
#endif
}
Beispiel #5
0
int tst(void)
{
  unsigned int ips[8];
  unsigned int cidr = -1;
  size_t num_len = -1;
  unsigned int err = -1;
  int ret = -1;

  VSTR_SUB_CSTR_BUF(s1, 1, s1->len, "::/64");

  TST_IP(VSTR_FLAG_PARSE_IPV6_DEF,
         0, 0, 0, 0, 0, 0, 0, 0, 128, strlen("::"), 0);
  TST_IP(VSTR_FLAG_PARSE_IPV6_CIDR,
         0, 0, 0, 0, 0, 0, 0, 0,  64, strlen("::/64"), 0);

  VSTR_SUB_CSTR_BUF(s1, 1, s1->len, "::1/64");

  TST_IP(VSTR_FLAG_PARSE_IPV6_DEF,
         0, 0, 0, 0, 0, 0, 0, 1, 128, strlen("::1"), 0);
  TST_IP(VSTR_FLAG_PARSE_IPV6_CIDR,
         0, 0, 0, 0, 0, 0, 0, 1,  64, strlen("::1/64"), 0);
  TST_IP(VSTR_FLAG02(PARSE_IPV6, CIDR, CIDR_FULL),
         0, 0, 0, 0, 0, 0, 0, 1,  64, strlen("::1/64"), 0);

  VSTR_SUB_CSTR_BUF(s1, 1, s1->len, "0:FFF::/24");

  TST_IP(VSTR_FLAG_PARSE_IPV6_DEF,
         0, 0xFFF, 0, 0, 0, 0, 0, 0, 128, strlen("0:FFF::"), 0);
  TST_IP(VSTR_FLAG_PARSE_IPV6_CIDR,
         0, 0xFFF, 0, 0, 0, 0, 0, 0,  24, strlen("0:FFF::/24"), 0);
  TST_IP(VSTR_FLAG02(PARSE_IPV6, CIDR, CIDR_FULL),
         0, 0xFFF, 0, 0, 0, 0, 0, 0,  24, strlen("0:FFF::/24"), 0);

  VSTR_SUB_CSTR_BUF(s1, 1, s1->len, "FFF::1/8");

  TST_IP(VSTR_FLAG_PARSE_IPV6_DEF,
         0xFFF, 0, 0, 0, 0, 0, 0, 1, 128, strlen("FFF::1"), 0);
  TST_IP(VSTR_FLAG_PARSE_IPV6_CIDR,
         0xFFF, 0, 0, 0, 0, 0, 0, 1,   8, strlen("FFF::1/8"), 0);
  vstr_sc_reduce(s1, 1, s1->len, 1);
  TST_IP(VSTR_FLAG_PARSE_IPV6_CIDR,
         0xFFF, 0, 0, 0, 0, 0, 0, 1, 128, strlen("FFF::1/"), 0);

  VSTR_SUB_CSTR_BUF(s1, 1, s1->len, "FFF::1/138");

  TST_IP(VSTR_FLAG_PARSE_IPV6_CIDR,
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, VSTR_TYPE_PARSE_IPV6_ERR_CIDR_OOB);


  VSTR_SUB_CSTR_BUF(s1, 1,s1->len,  "FFFFF::1");

  TST_IP(VSTR_FLAG_PARSE_IPV6_DEF,
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, VSTR_TYPE_PARSE_IPV6_ERR_IPV6_OOB);

  VSTR_SUB_CSTR_BUF(s1, 1,s1->len,  "F:1:E:2:D:3:c:4");

  TST_IP(VSTR_FLAG_PARSE_IPV6_DEF,
         0xF, 1, 0xE, 2, 0xD, 3, 0xC, 4, 128, s1->len, 0);

    /* Ipv4 end format testing... */
#define IPV4(n1, n2) (((n1) << 8) | (n2))

  VSTR_SUB_CSTR_BUF(s1, 1,s1->len,  "0:1::0:2:254.255.255.0");
  TST_IP(VSTR_FLAG_PARSE_IPV6_DEF,
         0, 1, 0, 0, 0, 2, IPV4(254U, 255), IPV4(255U, 0),    128, s1->len, 0);
  VSTR_SUB_CSTR_BUF(s1, 1,s1->len,  "0:1::0:2:255.255.1.1");
  TST_IP(VSTR_FLAG_PARSE_IPV6_DEF,
         0, 1, 0, 0, 0, 2, IPV4(255U, 255), IPV4(1U, 1),      128, s1->len, 0);


  /* from rfc2372 */
  VSTR_SUB_CSTR_BUF(s1, 1,s1->len,  "1080:0:0:0:8:800:200C:417A");
  TST_IP(VSTR_FLAG_PARSE_IPV6_DEF,
         0x1080, 0, 0, 0, 0x8, 0x800, 0x200C, 0x417A, 128, s1->len, 0);
  VSTR_SUB_CSTR_BUF(s1, 1,s1->len,  "1080::8:800:200C:417A");
  TST_IP(VSTR_FLAG_PARSE_IPV6_DEF,
         0x1080, 0, 0, 0, 0x8, 0x800, 0x200C, 0x417A, 128, s1->len, 0);

  VSTR_SUB_CSTR_BUF(s1, 1,s1->len,  "FF01:0:0:0:0:0:0:101");
  TST_IP(VSTR_FLAG_PARSE_IPV6_DEF,
         0xFF01, 0, 0, 0, 0, 0, 0, 0x101, 128, s1->len, 0);
  VSTR_SUB_CSTR_BUF(s1, 1,s1->len,  "FF01::101");
  TST_IP(VSTR_FLAG_PARSE_IPV6_DEF,
         0xFF01, 0, 0, 0, 0, 0, 0, 0x101, 128, s1->len, 0);

  VSTR_SUB_CSTR_BUF(s1, 1,s1->len,  "0:0:0:0:0:0:13.1.68.3");
  TST_IP(VSTR_FLAG_PARSE_IPV6_DEF,
         0, 0, 0, 0, 0, 0, IPV4(13U, 1), IPV4(68U, 3), 128, s1->len, 0);
  VSTR_SUB_CSTR_BUF(s1, 1,s1->len,  "::13.1.68.3");
  TST_IP(VSTR_FLAG_PARSE_IPV6_DEF,
         0, 0, 0, 0, 0, 0, IPV4(13U, 1), IPV4(68U, 3), 128, s1->len, 0);

  VSTR_SUB_CSTR_BUF(s1, 1,s1->len,  "0:0:0:0:0:FFFF:129.144.52.38");
  TST_IP(VSTR_FLAG_PARSE_IPV6_LOCAL,
         0, 0, 0, 0, 0, 0xFFFF, IPV4(129U, 144), IPV4(52U, 38),
         128, s1->len, 0);
  VSTR_SUB_CSTR_BUF(s1, 1,s1->len,  "::FFFF:129.144.52.38");
  TST_IP(VSTR_FLAG_PARSE_IPV6_DEF,
         0, 0, 0, 0, 0, 0xFFFF, IPV4(129U, 144), IPV4(52U, 38),
         128, s1->len, 0);

  VSTR_SUB_CSTR_BUF(s1, 1,s1->len,"12AB:0000:0000:CD30:0000:0000:0000:0000/60");
  TST_IP(VSTR_FLAG_PARSE_IPV6_CIDR,
         0x12AB, 0, 0, 0xCD30, 0, 0, 0, 0, 60, s1->len, 0);
  VSTR_SUB_CSTR_BUF(s1, 1,s1->len,"12AB::CD30:0:0:0:0/60");
  TST_IP(VSTR_FLAG_PARSE_IPV6_CIDR,
         0x12AB, 0, 0, 0xCD30, 0, 0, 0, 0, 60, s1->len, 0);
  TST_IP(VSTR_FLAG_PARSE_IPV6_ONLY,
         0x12AB, 0, 0, 0xCD30, 0, 0, 0, 0, 128, s1->len - 3,
         VSTR_TYPE_PARSE_IPV6_ERR_ONLY);

  VSTR_SUB_CSTR_BUF(s1, 1, s1->len, "1::1::3");
  TST_IP(VSTR_FLAG_PARSE_IPV6_LOCAL,
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, VSTR_TYPE_PARSE_IPV6_ERR_IPV6_NULL);

  VSTR_SUB_CSTR_BUF(s1, 1, s1->len, "1/8");
  TST_IP(VSTR_FLAG_PARSE_IPV6_DEF,
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, VSTR_TYPE_PARSE_IPV6_ERR_IPV6_FULL);

  VSTR_SUB_CSTR_BUF(s1, 1, s1->len, "1");
  TST_IP(VSTR_FLAG_PARSE_IPV6_DEF,
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, VSTR_TYPE_PARSE_IPV6_ERR_IPV6_FULL);

  VSTR_SUB_CSTR_BUF(s1, 1, s1->len, "1:2:3:4:5:6:7:8/");
  TST_IP(VSTR_FLAG_PARSE_IPV6_CIDR | VSTR_FLAG_PARSE_IPV6_CIDR_FULL,
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, VSTR_TYPE_PARSE_IPV6_ERR_CIDR_FULL);

  return (0);
}