Soe we're finally back at reducing the memory footprint be avoiding to pull in large C-library enitities.
This commit is contained in:
parent
c7a24bf6cf
commit
8644822a34
|
@ -30,19 +30,34 @@
|
||||||
*
|
*
|
||||||
* Author: Oliver Schmidt <ol.sc@web.de>
|
* Author: Oliver Schmidt <ol.sc@web.de>
|
||||||
*
|
*
|
||||||
* $Id: config.c,v 1.2 2007/12/08 21:48:49 oliverschmidt Exp $
|
* $Id: config.c,v 1.3 2007/12/16 13:10:14 oliverschmidt Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "contiki-net.h"
|
#include "contiki-net.h"
|
||||||
|
#include "sys/log.h"
|
||||||
#include "lib/error.h"
|
#include "lib/error.h"
|
||||||
#include "net/ethernet-drv.h"
|
#include "net/ethernet-drv.h"
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
static char *
|
||||||
|
ipaddrtoa(uip_ipaddr_t *ipaddr, char *buffer)
|
||||||
|
{
|
||||||
|
char *ptr = buffer;
|
||||||
|
u8_t i;
|
||||||
|
|
||||||
|
for(i = 0; i < 4; ++i) {
|
||||||
|
*ptr = '.';
|
||||||
|
utoa(ipaddr->u8[i], ++ptr, 10);
|
||||||
|
ptr += strlen(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
return buffer + 1;
|
||||||
|
}
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
struct ethernet_config *
|
struct ethernet_config *
|
||||||
config_read(char *filename)
|
config_read(char *filename)
|
||||||
|
@ -58,25 +73,25 @@ config_read(char *filename)
|
||||||
|
|
||||||
file = open(filename, O_RDONLY);
|
file = open(filename, O_RDONLY);
|
||||||
if(file < 0) {
|
if(file < 0) {
|
||||||
fprintf(stderr, "%s: %s\n", filename, strerror(errno));
|
log_message(filename, ": File not found");
|
||||||
error_exit();
|
error_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(read(file, &config, sizeof(config)) < sizeof(config)
|
if(read(file, &config, sizeof(config)) < sizeof(config)
|
||||||
- sizeof(config.ethernetcfg.name)) {
|
- sizeof(config.ethernetcfg.name)) {
|
||||||
fprintf(stderr, "%s: %s\n", filename, "No Config File");
|
log_message(filename, ": No config file");
|
||||||
error_exit();
|
error_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
close(file);
|
close(file);
|
||||||
|
|
||||||
fprintf(stderr, "IP Address: %d.%d.%d.%d\n", uip_ipaddr_to_quad(&config.hostaddr));
|
log_message("IP Address: ", ipaddrtoa(&config.hostaddr, uip_buf));
|
||||||
fprintf(stderr, "Subnet Mask: %d.%d.%d.%d\n", uip_ipaddr_to_quad(&config.netmask));
|
log_message("Subnet Mask: ", ipaddrtoa(&config.netmask, uip_buf));
|
||||||
fprintf(stderr, "Def. Router: %d.%d.%d.%d\n", uip_ipaddr_to_quad(&config.draddr));
|
log_message("Def. Router: ", ipaddrtoa(&config.draddr, uip_buf));
|
||||||
//fprintf(stderr, "DNS Server: %d.%d.%d.%d\n", uip_ipaddr_to_quad(&config.resolvaddr));
|
//log_message("DNS Server: ", ipaddrtoa(&config.resolvaddr, uip_buf));
|
||||||
|
|
||||||
fprintf(stderr, "Eth. Driver: %s at $%X\n", config.ethernetcfg.name,
|
log_message("Eth. Driver: ", config.ethernetcfg.name);
|
||||||
config.ethernetcfg.addr);
|
log_message("Driver Port: $", utoa(config.ethernetcfg.addr, uip_buf, 16));
|
||||||
|
|
||||||
uip_sethostaddr(&config.hostaddr);
|
uip_sethostaddr(&config.hostaddr);
|
||||||
uip_setnetmask(&config.netmask);
|
uip_setnetmask(&config.netmask);
|
||||||
|
|
|
@ -30,10 +30,11 @@
|
||||||
*
|
*
|
||||||
* Author: Oliver Schmidt <ol.sc@web.de>
|
* Author: Oliver Schmidt <ol.sc@web.de>
|
||||||
*
|
*
|
||||||
* $Id: log.c,v 1.3 2007/12/08 22:34:59 oliverschmidt Exp $
|
* $Id: log.c,v 1.4 2007/12/16 13:11:01 oliverschmidt Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <unistd.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "net/uip.h"
|
#include "net/uip.h"
|
||||||
#include "sys/log.h"
|
#include "sys/log.h"
|
||||||
|
@ -43,7 +44,8 @@
|
||||||
void
|
void
|
||||||
uip_log(char *message)
|
uip_log(char *message)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s\n", message);
|
write(STDERR_FILENO, message, strlen(message));
|
||||||
|
write(STDERR_FILENO, "\n", 1);
|
||||||
}
|
}
|
||||||
#endif /* UIP_LOGGING */
|
#endif /* UIP_LOGGING */
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
@ -51,7 +53,9 @@ uip_log(char *message)
|
||||||
void
|
void
|
||||||
log_message(const char *part1, const char *part2)
|
log_message(const char *part1, const char *part2)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s%s\n", part1, part2);
|
write(STDERR_FILENO, part1, strlen(part1));
|
||||||
|
write(STDERR_FILENO, part2, strlen(part2));
|
||||||
|
write(STDERR_FILENO, "\n", 1);
|
||||||
}
|
}
|
||||||
#endif /* LOG_CONF_ENABLED */
|
#endif /* LOG_CONF_ENABLED */
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
|
|
@ -30,12 +30,11 @@
|
||||||
*
|
*
|
||||||
* Author: Oliver Schmidt <ol.sc@web.de>
|
* Author: Oliver Schmidt <ol.sc@web.de>
|
||||||
*
|
*
|
||||||
* $Id: contiki-main.c,v 1.11 2007/11/27 21:50:19 oliverschmidt Exp $
|
* $Id: contiki-main.c,v 1.12 2007/12/16 13:08:09 oliverschmidt Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include "contiki-net.h"
|
#include "contiki-net.h"
|
||||||
|
#include "sys/log.h"
|
||||||
#include "lib/config.h"
|
#include "lib/config.h"
|
||||||
#include "net/ethernet-drv.h"
|
#include "net/ethernet-drv.h"
|
||||||
|
|
||||||
|
@ -72,29 +71,24 @@ main(void)
|
||||||
uip_ipaddr_t addr;
|
uip_ipaddr_t addr;
|
||||||
|
|
||||||
uip_ipaddr(&addr, 192,168,0,128);
|
uip_ipaddr(&addr, 192,168,0,128);
|
||||||
fprintf(stderr, "IP Address: %d.%d.%d.%d\n", uip_ipaddr_to_quad(&addr));
|
|
||||||
uip_sethostaddr(&addr);
|
uip_sethostaddr(&addr);
|
||||||
|
|
||||||
uip_ipaddr(&addr, 255,255,255,0);
|
uip_ipaddr(&addr, 255,255,255,0);
|
||||||
fprintf(stderr, "Subnet Mask: %d.%d.%d.%d\n", uip_ipaddr_to_quad(&addr));
|
|
||||||
uip_setnetmask(&addr);
|
uip_setnetmask(&addr);
|
||||||
|
|
||||||
uip_ipaddr(&addr, 192,168,0,1);
|
uip_ipaddr(&addr, 192,168,0,1);
|
||||||
fprintf(stderr, "Def. Router: %d.%d.%d.%d\n", uip_ipaddr_to_quad(&addr));
|
|
||||||
uip_setdraddr(&addr);
|
uip_setdraddr(&addr);
|
||||||
|
|
||||||
uip_ipaddr(&addr, 192,168,0,1);
|
uip_ipaddr(&addr, 192,168,0,1);
|
||||||
fprintf(stderr, "DNS Server: %d.%d.%d.%d\n", uip_ipaddr_to_quad(&addr));
|
|
||||||
resolv_conf(&addr);
|
resolv_conf(&addr);
|
||||||
|
|
||||||
fprintf(stderr, "Eth. Driver: %s at $%X\n", config.name, config.addr);
|
|
||||||
ethernet_config = &config;
|
ethernet_config = &config;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
process_start((struct process *)ðernet_process, (char *)ethernet_config);
|
process_start((struct process *)ðernet_process, (char *)ethernet_config);
|
||||||
|
|
||||||
fprintf(stderr, "Contiki up and running ...\n");
|
log_message("Contiki up and running ...", "");
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
|
|
||||||
|
|
|
@ -30,21 +30,21 @@
|
||||||
*
|
*
|
||||||
* Author: Oliver Schmidt <ol.sc@web.de>
|
* Author: Oliver Schmidt <ol.sc@web.de>
|
||||||
*
|
*
|
||||||
* $Id: error.c,v 1.1 2007/12/08 22:16:57 oliverschmidt Exp $
|
* $Id: error.c,v 1.2 2007/12/16 13:12:49 oliverschmidt Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <conio.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "sys/log.h"
|
||||||
|
|
||||||
#include "lib/error.h"
|
#include "lib/error.h"
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
error_exit(void)
|
error_exit(void)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Press any key to continue ...\n");
|
log_message("Press any key to continue ...", "");
|
||||||
cgetc();
|
ctk_arch_getkey();
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
|
|
@ -30,13 +30,13 @@
|
||||||
*
|
*
|
||||||
* Author: Oliver Schmidt <ol.sc@web.de>
|
* Author: Oliver Schmidt <ol.sc@web.de>
|
||||||
*
|
*
|
||||||
* $Id: clock.c,v 1.1 2007/12/15 11:04:11 oliverschmidt Exp $
|
* $Id: clock.c,v 1.2 2007/12/16 13:11:46 oliverschmidt Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <apple2.h>
|
#include <apple2.h>
|
||||||
|
|
||||||
#include "contiki.h"
|
#include "contiki.h"
|
||||||
|
#include "sys/log.h"
|
||||||
|
|
||||||
/* The enhanced Apple//e doesn't have a hardware clock whatsoever. Therefore the
|
/* The enhanced Apple//e doesn't have a hardware clock whatsoever. Therefore the
|
||||||
* cc65 C-library for this target doesn't include an implementation of clock().
|
* cc65 C-library for this target doesn't include an implementation of clock().
|
||||||
|
@ -53,7 +53,7 @@ clock_init(void)
|
||||||
if(*(signed char *)0xC036 < 0) {
|
if(*(signed char *)0xC036 < 0) {
|
||||||
/* 5 / 14 = 1.0MHz / 2.8MHz */
|
/* 5 / 14 = 1.0MHz / 2.8MHz */
|
||||||
tick = 5;
|
tick = 5;
|
||||||
fprintf(stderr, "Assuming 2.8 MHz ...\n");
|
log_message("Assuming 2.8 MHz ...", "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue