Merge pull request #330 from vDorst/SRAM-easy-changes

Sram easy changes
This commit is contained in:
René van Dorst
2026-08-29 18:33:29 +00:00
committed by GitHub
5 changed files with 22 additions and 20 deletions
+11 -9
View File
@@ -50,8 +50,8 @@ __xdata uint8_t config_upload;
__xdata uint8_t config_buf[CONFIG_UPLOAD_BUF]; __xdata uint8_t config_buf[CONFIG_UPLOAD_BUF];
__xdata uint16_t cfg_pos, cfg_hdr, cfg_body, cfg_end, cfg_last; __xdata uint16_t cfg_pos, cfg_hdr, cfg_body, cfg_end, cfg_last;
__xdata uint8_t cfg_bl; __xdata uint8_t cfg_bl;
__xdata uint8_t *content_type = 0; __xdata uint8_t * __xdata content_type = 0;
__xdata uint8_t *session = 0; __xdata uint8_t * __xdata session = 0;
// Global variables holding POST state // Global variables holding POST state
__xdata uint16_t bindex; // Current index into the boundary __xdata uint16_t bindex; // Current index into the boundary
@@ -63,7 +63,7 @@ __xdata char passwd[21];
__xdata char session_id[SESSION_ID_LENGTH + 1]; __xdata char session_id[SESSION_ID_LENGTH + 1];
__xdata uint8_t authenticated; __xdata uint8_t authenticated;
__xdata uint32_t now; __xdata uint32_t now;
__xdata uint8_t *timeptr; __xdata uint8_t * __xdata timeptr;
__xdata uint32_t last_session_use; __xdata uint32_t last_session_use;
#define TSTATE_NONE 0 #define TSTATE_NONE 0
@@ -175,7 +175,7 @@ bool is_url_word_x(__xdata uint8_t *uri_str_p, __xdata uint8_t *src_str_p)
} }
bool is_word_x(__xdata uint8_t *lhs_str_p, __xdata uint8_t *rhs_str_p) bool is_word_x(__xdata uint8_t * lhs_str_p, __xdata uint8_t * rhs_str_p)
{ {
uint8_t u, c; uint8_t u, c;
@@ -251,7 +251,7 @@ __xdata uint8_t *skip_boundary(__xdata uint8_t *p)
} }
__xdata uint8_t *scan_header(__xdata uint8_t *p) __xdata uint8_t *scan_header(__xdata uint8_t * __xdata p)
{ {
content_type = 0; content_type = 0;
session = 0; session = 0;
@@ -310,10 +310,12 @@ __xdata uint8_t *scan_header(__xdata uint8_t *p)
return p; return p;
} }
/*
void gen_random_bytes(__xdata uint8_t *b, uint8_t bytes) * Generate random HEX-chars at the buffer location.
*/
void gen_random_hex_chars(__xdata uint8_t * b, __xdata uint8_t bytes)
{ {
__xdata uint8_t i = 0; uint8_t i = 0;
while (bytes) { while (bytes) {
if (!i) if (!i)
get_random_32(); get_random_32();
@@ -549,7 +551,7 @@ void handle_post(void)
if (is_url_word_x(p, passwd)) { if (is_url_word_x(p, passwd)) {
dbg_string("Password accepted!\n"); dbg_string("Password accepted!\n");
read_reg_timer(&last_session_use); read_reg_timer(&last_session_use);
gen_random_bytes(session_id, SESSION_ID_LENGTH); gen_random_hex_chars(session_id, SESSION_ID_LENGTH);
session_id[SESSION_ID_LENGTH] = NUL; session_id[SESSION_ID_LENGTH] = NUL;
slen = strtox(outbuf, "HTTP/1.1 302 Found\r\nConnection: close\r\nLocation: index.html\r\n" \ slen = strtox(outbuf, "HTTP/1.1 302 Found\r\nConnection: close\r\nLocation: index.html\r\n" \
"Set-Cookie: session="); "Set-Cookie: session=");
+4 -4
View File
@@ -62,19 +62,19 @@ void syslog_callback(uint16_t lport) __banked
if ((state.readptr != state.writeptr) && state.line_available) if ((state.readptr != state.writeptr) && state.line_available)
{ {
int16_t log_size = state.writeptr - state.readptr; __xdata int16_t log_size = state.writeptr - state.readptr;
if (log_size < 0) if (log_size < 0)
log_size += LOGBUF_SIZE; log_size += LOGBUF_SIZE;
// Skipping linefeeds at the start of the log line // Skipping linefeeds at the start of the log line
uint16_t log_start = state.readptr; __xdata uint16_t log_start = state.readptr;
while (log_size > 0 && logbuf[log_start] == '\n') { while (log_size > 0 && logbuf[log_start] == '\n') {
log_start = (log_start + 1) & (LOGBUF_SIZE - 1); log_start = (log_start + 1) & (LOGBUF_SIZE - 1);
log_size--; log_size--;
} }
// Skipping linefeeds and whitespaces at the end of the log line // Skipping linefeeds and whitespaces at the end of the log line
uint16_t log_end = state.writeptr; __xdata uint16_t log_end = state.writeptr;
while ( (log_size > 0) && while ( (log_size > 0) &&
((logbuf[(log_end-1) & (LOGBUF_SIZE - 1)] == '\n') || ((logbuf[(log_end-1) & (LOGBUF_SIZE - 1)] == '\n') ||
(logbuf[(log_end-1) & (LOGBUF_SIZE - 1)] == ' '))) (logbuf[(log_end-1) & (LOGBUF_SIZE - 1)] == ' ')))
@@ -95,7 +95,7 @@ void syslog_callback(uint16_t lport) __banked
memcpy(SYSLOG_P + 4, logbuf + log_start, LOGBUF_SIZE - log_start); memcpy(SYSLOG_P + 4, logbuf + log_start, LOGBUF_SIZE - log_start);
memcpy(SYSLOG_P + 4 + LOGBUF_SIZE - log_start, logbuf, log_end); memcpy(SYSLOG_P + 4 + LOGBUF_SIZE - log_start, logbuf, log_end);
} else { } else {
memcpy(SYSLOG_P + 4, logbuf + log_start, log_end - log_start); memcpy(SYSLOG_P + 4, logbuf + log_start, log_end - log_start);
} }
uip_udp_send(log_size+4); uip_udp_send(log_size+4);
+3 -3
View File
@@ -157,7 +157,7 @@ __xdata u16_t uip_len, uip_slen;
__xdata u8_t uip_flags; /* The uip_flags variable is used for __xdata u8_t uip_flags; /* The uip_flags variable is used for
communication between the TCP/IP stack communication between the TCP/IP stack
and the application program. */ and the application program. */
__xdata struct uip_conn *uip_conn; /* uip_conn always points to the current __xdata struct uip_conn * __xdata uip_conn; /* uip_conn always points to the current
connection. */ connection. */
__xdata struct uip_conn uip_conns[UIP_CONNS]; __xdata struct uip_conn uip_conns[UIP_CONNS];
@@ -167,7 +167,7 @@ __xdata u16_t uip_listenports[UIP_LISTENPORTS];
/* The uip_listenports list all currently /* The uip_listenports list all currently
listning ports. */ listning ports. */
#if UIP_UDP #if UIP_UDP
__xdata struct uip_udp_conn *uip_udp_conn; __xdata struct uip_udp_conn * __xdata uip_udp_conn;
__xdata struct uip_udp_conn uip_udp_conns[UIP_UDP_CONNS]; __xdata struct uip_udp_conn uip_udp_conns[UIP_UDP_CONNS];
#endif /* UIP_UDP */ #endif /* UIP_UDP */
@@ -466,7 +466,7 @@ uip_connect(__xdata uip_ipaddr_t *ripaddr, __xdata u16_t rport) __banked
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
#if UIP_UDP #if UIP_UDP
__xdata struct uip_udp_conn * __xdata struct uip_udp_conn *
uip_udp_new(__xdata uip_ipaddr_t *ripaddr, __xdata u16_t rport) __banked uip_udp_new(__xdata uip_ipaddr_t * __xdata ripaddr, __xdata u16_t rport) __banked
{ {
__xdata struct uip_udp_conn *conn; __xdata struct uip_udp_conn *conn;
+3 -3
View File
@@ -763,7 +763,7 @@ void uip_send(__xdata const void *data, __xdata uint16_t len) __banked;
* \return The uip_udp_conn structure for the new connection or NULL * \return The uip_udp_conn structure for the new connection or NULL
* if no connection could be allocated. * if no connection could be allocated.
*/ */
__xdata struct uip_udp_conn *uip_udp_new(__xdata uip_ipaddr_t *ripaddr, __xdata u16_t rport) __banked; __xdata struct uip_udp_conn *uip_udp_new(__xdata uip_ipaddr_t * __xdata ripaddr, __xdata u16_t rport) __banked;
/** /**
* Removed a UDP connection. * Removed a UDP connection.
@@ -1193,7 +1193,7 @@ struct uip_conn {
* The uip_conn pointer can be used to access the current TCP * The uip_conn pointer can be used to access the current TCP
* connection. * connection.
*/ */
extern __xdata struct uip_conn *uip_conn; extern __xdata struct uip_conn * __xdata uip_conn;
/* The array containing all uIP connections. */ /* The array containing all uIP connections. */
extern __xdata struct uip_conn uip_conns[UIP_CONNS]; extern __xdata struct uip_conn uip_conns[UIP_CONNS];
/** /**
@@ -1226,7 +1226,7 @@ struct uip_udp_conn {
/** /**
* The current UDP connection. * The current UDP connection.
*/ */
extern __xdata struct uip_udp_conn *uip_udp_conn; extern __xdata struct uip_udp_conn * __xdata uip_udp_conn;
extern __xdata struct uip_udp_conn uip_udp_conns[UIP_UDP_CONNS]; extern __xdata struct uip_udp_conn uip_udp_conns[UIP_UDP_CONNS];
#endif /* UIP_UDP */ #endif /* UIP_UDP */
+1 -1
View File
@@ -175,7 +175,7 @@ uip_arp_timer(void) __banked
} }
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
static void static void
uip_arp_update(__xdata u16_t *ipaddr, __xdata struct uip_eth_addr *ethaddr) uip_arp_update(__xdata u16_t * __xdata ipaddr, __xdata struct uip_eth_addr * __xdata ethaddr)
{ {
uint8_t i; uint8_t i;
/* Walk through the ARP mapping table and try to find an entry to /* Walk through the ARP mapping table and try to find an entry to