mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-19 19:40:56 +00:00
Enable FPU
This commit is contained in:
1 parent
13fffbc5b6
commit
8596e1bef7
4 files changed
+28
-9
No files matched your search
@@ -27,6 +27,7 @@ static void sfn(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
|
|||||||
uint64_t t = *(uint64_t *) ev_data;
|
uint64_t t = *(uint64_t *) ev_data;
|
||||||
MG_INFO(("%lu SNTP: %lld ms from epoch", c->id, t));
|
MG_INFO(("%lu SNTP: %lld ms from epoch", c->id, t));
|
||||||
s_boot_timestamp = (time_t) ((t - mg_millis()) / 1000);
|
s_boot_timestamp = (time_t) ((t - mg_millis()) / 1000);
|
||||||
|
c->is_closing = 1;
|
||||||
} else if (ev == MG_EV_CLOSE) {
|
} else if (ev == MG_EV_CLOSE) {
|
||||||
s_sntp_conn = NULL;
|
s_sntp_conn = NULL;
|
||||||
}
|
}
|
||||||
@@ -35,12 +36,14 @@ static void sfn(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
|
|||||||
|
|
||||||
static void sntp_cb(void *param) { // SNTP timer function. Sync up time
|
static void sntp_cb(void *param) { // SNTP timer function. Sync up time
|
||||||
struct mg_mgr *mgr = (struct mg_mgr *) param;
|
struct mg_mgr *mgr = (struct mg_mgr *) param;
|
||||||
if (s_sntp_conn == NULL) s_sntp_conn = mg_sntp_connect(mgr, NULL, sfn, NULL);
|
return; // TODO(cpq): re-enable!
|
||||||
if (s_boot_timestamp < 9999) mg_sntp_request(s_sntp_conn);
|
if (s_sntp_conn == NULL && s_boot_timestamp == 0) {
|
||||||
|
s_sntp_conn = mg_sntp_connect(mgr, NULL, sfn, NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void blink_cb(void *arg) { // Blink periodically
|
static void blink_cb(void *arg) { // Blink periodically
|
||||||
// MG_INFO(("ticks: %u", (unsigned) s_ticks));
|
MG_INFO(("ticks: %u", (unsigned) s_ticks));
|
||||||
gpio_toggle(LED2);
|
gpio_toggle(LED2);
|
||||||
(void) arg;
|
(void) arg;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,6 +65,17 @@ struct flash {
|
|||||||
};
|
};
|
||||||
#define FLASH ((struct flash *) 0x40023c00)
|
#define FLASH ((struct flash *) 0x40023c00)
|
||||||
|
|
||||||
|
struct scb {
|
||||||
|
volatile uint32_t CPUID, ICSR, VTOR, AIRCR, SCR, CCR, SHPR[3], SHCSR, CFSR,
|
||||||
|
HFSR, DFSR, MMFAR, BFAR, AFSR, ID_PFR[2], ID_DFR, ID_AFR, ID_MFR[4],
|
||||||
|
ID_ISAR[5], RESERVED0[1], CLIDR, CTR, CCSIDR, CSSELR, CPACR,
|
||||||
|
RESERVED3[93], STIR, RESERVED4[15], MVFR0, MVFR1, MVFR2, RESERVED5[1],
|
||||||
|
ICIALLU, RESERVED6[1], ICIMVAU, DCIMVAC, DCISW, DCCMVAU, DCCMVAC, DCCSW,
|
||||||
|
DCCIMVAC, DCCISW, RESERVED7[6], ITCMCR, DTCMCR, AHBPCR, CACR, AHBSCR,
|
||||||
|
RESERVED8[1], ABFSR;
|
||||||
|
};
|
||||||
|
#define SCB ((struct scb *) 0xe000e000)
|
||||||
|
|
||||||
enum { GPIO_MODE_INPUT, GPIO_MODE_OUTPUT, GPIO_MODE_AF, GPIO_MODE_ANALOG };
|
enum { GPIO_MODE_INPUT, GPIO_MODE_OUTPUT, GPIO_MODE_AF, GPIO_MODE_ANALOG };
|
||||||
enum { GPIO_OTYPE_PUSH_PULL, GPIO_OTYPE_OPEN_DRAIN };
|
enum { GPIO_OTYPE_PUSH_PULL, GPIO_OTYPE_OPEN_DRAIN };
|
||||||
enum { GPIO_SPEED_LOW, GPIO_SPEED_MEDIUM, GPIO_SPEED_HIGH, GPIO_SPEED_INSANE };
|
enum { GPIO_SPEED_LOW, GPIO_SPEED_MEDIUM, GPIO_SPEED_HIGH, GPIO_SPEED_INSANE };
|
||||||
@@ -182,6 +193,7 @@ static inline void clock_init(void) { // Set clock to 216Mhz
|
|||||||
while ((PWR->CSR1 & BIT(16)) == 0) spin(1); // Wait until done
|
while ((PWR->CSR1 & BIT(16)) == 0) spin(1); // Wait until done
|
||||||
PWR->CR1 |= BIT(17); // Enable overdrive switching
|
PWR->CR1 |= BIT(17); // Enable overdrive switching
|
||||||
while ((PWR->CSR1 & BIT(17)) == 0) spin(1); // Wait until done
|
while ((PWR->CSR1 & BIT(17)) == 0) spin(1); // Wait until done
|
||||||
|
SCB->CPACR |= ((3UL << 10 * 2) | (3UL << 11 * 2)); // Enable FPU
|
||||||
#endif
|
#endif
|
||||||
FLASH->ACR |= 7 | BIT(8) | BIT(9); // Flash latency 7, prefetch
|
FLASH->ACR |= 7 | BIT(8) | BIT(9); // Flash latency 7, prefetch
|
||||||
RCC->PLLCFGR &= ~((BIT(15) - 1)); // PLL = HSI * N / M / P
|
RCC->PLLCFGR &= ~((BIT(15) - 1)); // PLL = HSI * N / M / P
|
||||||
|
|||||||
@@ -264,8 +264,8 @@ static void arp_cache_add(struct mip_if *ifp, uint32_t ip, uint8_t mac[6]) {
|
|||||||
memcpy(p + p[0] + 2, &ip, sizeof(ip)); // Replace last entry: IP address
|
memcpy(p + p[0] + 2, &ip, sizeof(ip)); // Replace last entry: IP address
|
||||||
memcpy(p + p[0] + 6, mac, 6); // And MAC address
|
memcpy(p + p[0] + 6, mac, 6); // And MAC address
|
||||||
p[1] = p[0], p[0] = p[p[1]]; // Point list head to us
|
p[1] = p[0], p[0] = p[p[1]]; // Point list head to us
|
||||||
// MG_DEBUG(("ARP cache: added %#lx @ %x:%x:%x:%x:%x:%x\n", (long) ip, mac[0],
|
MG_DEBUG(("ARP cache: added %#lx @ %x:%x:%x:%x:%x:%x", (long) NET32(ip),
|
||||||
// mac[1], mac[2], mac[3], mac[4], mac[5]));
|
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void arp_ask(struct mip_if *ifp, uint32_t ip) {
|
static void arp_ask(struct mip_if *ifp, uint32_t ip) {
|
||||||
@@ -321,6 +321,7 @@ static void tx_udp(struct mip_if *ifp, uint32_t ip_src, uint16_t sport,
|
|||||||
size_t len) {
|
size_t len) {
|
||||||
struct ip *ip = tx_ip(ifp, 17, ip_src, ip_dst, len + sizeof(struct udp));
|
struct ip *ip = tx_ip(ifp, 17, ip_src, ip_dst, len + sizeof(struct udp));
|
||||||
struct udp *udp = (struct udp *) (ip + 1);
|
struct udp *udp = (struct udp *) (ip + 1);
|
||||||
|
// MG_DEBUG(("UDP XX LEN %d %d", (int) len, (int) ifp->tx.len));
|
||||||
udp->sport = sport;
|
udp->sport = sport;
|
||||||
udp->dport = dport;
|
udp->dport = dport;
|
||||||
udp->len = NET16((uint16_t) (sizeof(*udp) + len));
|
udp->len = NET16((uint16_t) (sizeof(*udp) + len));
|
||||||
@@ -375,11 +376,11 @@ static void tx_dhcp_discover(struct mip_if *ifp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void rx_arp(struct mip_if *ifp, struct pkt *pkt) {
|
static void rx_arp(struct mip_if *ifp, struct pkt *pkt) {
|
||||||
// MG_DEBUG(("ARP op %d %#x %#x\n", NET16(arp->op), arp->spa, arp->tpa));
|
|
||||||
if (pkt->arp->op == NET16(1) && pkt->arp->tpa == ifp->ip) {
|
if (pkt->arp->op == NET16(1) && pkt->arp->tpa == ifp->ip) {
|
||||||
// ARP request. Make a response, then send
|
// ARP request. Make a response, then send
|
||||||
struct eth *eth = (struct eth *) ifp->tx.buf;
|
struct eth *eth = (struct eth *) ifp->tx.buf;
|
||||||
struct arp *arp = (struct arp *) (eth + 1);
|
struct arp *arp = (struct arp *) (eth + 1);
|
||||||
|
MG_DEBUG(("ARP op %d %#x %#x\n", NET16(arp->op), arp->spa, arp->tpa));
|
||||||
memcpy(eth->dst, pkt->eth->src, sizeof(eth->dst));
|
memcpy(eth->dst, pkt->eth->src, sizeof(eth->dst));
|
||||||
memcpy(eth->src, ifp->mac, sizeof(eth->src));
|
memcpy(eth->src, ifp->mac, sizeof(eth->src));
|
||||||
eth->type = NET16(0x806);
|
eth->type = NET16(0x806);
|
||||||
@@ -731,6 +732,7 @@ int mg_mkpipe(struct mg_mgr *m, mg_event_handler_t fn, void *d, bool udp) {
|
|||||||
|
|
||||||
void mg_connect_resolved(struct mg_connection *c) {
|
void mg_connect_resolved(struct mg_connection *c) {
|
||||||
struct mip_if *ifp = (struct mip_if *) c->mgr->priv;
|
struct mip_if *ifp = (struct mip_if *) c->mgr->priv;
|
||||||
|
c->is_resolving = 0;
|
||||||
if (ifp->eport < MIP_ETHEMERAL_PORT) ifp->eport = MIP_ETHEMERAL_PORT;
|
if (ifp->eport < MIP_ETHEMERAL_PORT) ifp->eport = MIP_ETHEMERAL_PORT;
|
||||||
if (c->is_udp) {
|
if (c->is_udp) {
|
||||||
c->loc.ip = ifp->ip;
|
c->loc.ip = ifp->ip;
|
||||||
|
|||||||
+5
-3
@@ -6358,8 +6358,8 @@ static void arp_cache_add(struct mip_if *ifp, uint32_t ip, uint8_t mac[6]) {
|
|||||||
memcpy(p + p[0] + 2, &ip, sizeof(ip)); // Replace last entry: IP address
|
memcpy(p + p[0] + 2, &ip, sizeof(ip)); // Replace last entry: IP address
|
||||||
memcpy(p + p[0] + 6, mac, 6); // And MAC address
|
memcpy(p + p[0] + 6, mac, 6); // And MAC address
|
||||||
p[1] = p[0], p[0] = p[p[1]]; // Point list head to us
|
p[1] = p[0], p[0] = p[p[1]]; // Point list head to us
|
||||||
// MG_DEBUG(("ARP cache: added %#lx @ %x:%x:%x:%x:%x:%x\n", (long) ip, mac[0],
|
MG_DEBUG(("ARP cache: added %#lx @ %x:%x:%x:%x:%x:%x", (long) NET32(ip),
|
||||||
// mac[1], mac[2], mac[3], mac[4], mac[5]));
|
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void arp_ask(struct mip_if *ifp, uint32_t ip) {
|
static void arp_ask(struct mip_if *ifp, uint32_t ip) {
|
||||||
@@ -6415,6 +6415,7 @@ static void tx_udp(struct mip_if *ifp, uint32_t ip_src, uint16_t sport,
|
|||||||
size_t len) {
|
size_t len) {
|
||||||
struct ip *ip = tx_ip(ifp, 17, ip_src, ip_dst, len + sizeof(struct udp));
|
struct ip *ip = tx_ip(ifp, 17, ip_src, ip_dst, len + sizeof(struct udp));
|
||||||
struct udp *udp = (struct udp *) (ip + 1);
|
struct udp *udp = (struct udp *) (ip + 1);
|
||||||
|
// MG_DEBUG(("UDP XX LEN %d %d", (int) len, (int) ifp->tx.len));
|
||||||
udp->sport = sport;
|
udp->sport = sport;
|
||||||
udp->dport = dport;
|
udp->dport = dport;
|
||||||
udp->len = NET16((uint16_t) (sizeof(*udp) + len));
|
udp->len = NET16((uint16_t) (sizeof(*udp) + len));
|
||||||
@@ -6469,11 +6470,11 @@ static void tx_dhcp_discover(struct mip_if *ifp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void rx_arp(struct mip_if *ifp, struct pkt *pkt) {
|
static void rx_arp(struct mip_if *ifp, struct pkt *pkt) {
|
||||||
// MG_DEBUG(("ARP op %d %#x %#x\n", NET16(arp->op), arp->spa, arp->tpa));
|
|
||||||
if (pkt->arp->op == NET16(1) && pkt->arp->tpa == ifp->ip) {
|
if (pkt->arp->op == NET16(1) && pkt->arp->tpa == ifp->ip) {
|
||||||
// ARP request. Make a response, then send
|
// ARP request. Make a response, then send
|
||||||
struct eth *eth = (struct eth *) ifp->tx.buf;
|
struct eth *eth = (struct eth *) ifp->tx.buf;
|
||||||
struct arp *arp = (struct arp *) (eth + 1);
|
struct arp *arp = (struct arp *) (eth + 1);
|
||||||
|
MG_DEBUG(("ARP op %d %#x %#x\n", NET16(arp->op), arp->spa, arp->tpa));
|
||||||
memcpy(eth->dst, pkt->eth->src, sizeof(eth->dst));
|
memcpy(eth->dst, pkt->eth->src, sizeof(eth->dst));
|
||||||
memcpy(eth->src, ifp->mac, sizeof(eth->src));
|
memcpy(eth->src, ifp->mac, sizeof(eth->src));
|
||||||
eth->type = NET16(0x806);
|
eth->type = NET16(0x806);
|
||||||
@@ -6825,6 +6826,7 @@ int mg_mkpipe(struct mg_mgr *m, mg_event_handler_t fn, void *d, bool udp) {
|
|||||||
|
|
||||||
void mg_connect_resolved(struct mg_connection *c) {
|
void mg_connect_resolved(struct mg_connection *c) {
|
||||||
struct mip_if *ifp = (struct mip_if *) c->mgr->priv;
|
struct mip_if *ifp = (struct mip_if *) c->mgr->priv;
|
||||||
|
c->is_resolving = 0;
|
||||||
if (ifp->eport < MIP_ETHEMERAL_PORT) ifp->eport = MIP_ETHEMERAL_PORT;
|
if (ifp->eport < MIP_ETHEMERAL_PORT) ifp->eport = MIP_ETHEMERAL_PORT;
|
||||||
if (c->is_udp) {
|
if (c->is_udp) {
|
||||||
c->loc.ip = ifp->ip;
|
c->loc.ip = ifp->ip;
|
||||||
|
|||||||
Reference in new issue
Block a user