Line 39... |
Line 39... |
// Public License along with this source; if not, download it //
|
// Public License along with this source; if not, download it //
|
// from http://www.opencores.org/lgpl.shtml //
|
// from http://www.opencores.org/lgpl.shtml //
|
// //
|
// //
|
----------------------------------------------------------------*/
|
----------------------------------------------------------------*/
|
|
|
// TODO list
|
|
// tcp.c clean up
|
|
// Cleanup self_g structure and usage
|
|
// tcp window - what is it, whats it set to? Add it to status stuff
|
|
// Get A25 version working
|
|
// test with booting linux
|
|
|
|
#include "amber_registers.h"
|
#include "amber_registers.h"
|
#include "address_map.h"
|
#include "address_map.h"
|
#include "line-buffer.h"
|
#include "line-buffer.h"
|
#include "timer.h"
|
#include "timer.h"
|
#include "utilities.h"
|
#include "utilities.h"
|
|
|
#include "ethmac.h"
|
#include "ethmac.h"
|
#include "packet.h"
|
#include "packet.h"
|
#include "tcp.h"
|
#include "tcp.h"
|
#include "udp.h"
|
#include "udp.h"
|
#include "telnet.h"
|
#include "telnet.h"
|
|
#include "serial.h"
|
|
|
#include "elfsplitter.h"
|
#include "elfsplitter.h"
|
#include "boot-loader-ethmac.h"
|
#include "boot-loader-ethmac.h"
|
|
|
|
|
|
|
int main ( void ) {
|
int main ( void ) {
|
char* line;
|
char* line;
|
time_t* led_flash_timer;
|
time_t* led_flash_timer;
|
time_t* reboot_timer;
|
time_t* reboot_timer;
|
socket_t* socket = socket0_g;
|
socket_t* socket = socket0_g;
|
int reboot_stage = 0;
|
int reboot_stage = 0;
|
|
|
/* Turn off all LEDs as a starting point */
|
|
|
/* Enable the serial debug port */
|
|
init_serial();
|
|
print_serial("Amber debug port\n\r");
|
|
|
|
|
|
/* Turn off all LEDs */
|
led_clear();
|
led_clear();
|
|
|
/* this must be first, because all the other init functions call malloc */
|
|
|
/* initialize the memory allocation system */
|
init_malloc();
|
init_malloc();
|
|
|
|
|
/* Initialize current time and some timers */
|
/* Initialize current time and some timers */
|
init_current_time();
|
init_current_time();
|
led_flash_timer = init_timer();
|
led_flash_timer = init_timer();
|
set_timer(led_flash_timer, 500);
|
set_timer(led_flash_timer, 500);
|
reboot_timer = init_timer();
|
reboot_timer = init_timer();
|
|
|
|
|
/* receive packet buffer */
|
/* receive packet buffer */
|
rx_packet_g = malloc(sizeof(packet_t));
|
rx_packet_g = malloc(sizeof(packet_t));
|
|
|
/* socket init */
|
|
|
/* initialize two tcp sockets */
|
socket0_g = init_socket(0);
|
socket0_g = init_socket(0);
|
socket1_g = init_socket(1);
|
socket1_g = init_socket(1);
|
|
|
|
|
/* open ethernet port and wait for connection requests
|
/* open ethernet port and wait for connection requests
|
keep trying forever */
|
keep trying forever */
|
while (!open_link());
|
while (!open_link());
|
|
|
|
|
/* infinite loop. Everything is timer, interrupt and queue driven from here on down */
|
/* infinite loop. Everything is timer, interrupt and queue driven from here on down */
|
while (1) {
|
while (1) {
|
|
|
/* Flash a heartbeat LED */
|
/* Flash a heartbeat LED */
|
if (timer_expired(led_flash_timer)) {
|
if (timer_expired(led_flash_timer)) {
|
Line 109... |
Line 114... |
/* Has a file been uploaded via tftp ? */
|
/* Has a file been uploaded via tftp ? */
|
if (udp_file_g != NULL) {
|
if (udp_file_g != NULL) {
|
/* Notify telnet clients that file has been received */
|
/* Notify telnet clients that file has been received */
|
if (udp_file_g->ready) {
|
if (udp_file_g->ready) {
|
udp_file_g->ready = 0;
|
udp_file_g->ready = 0;
|
telnet_broadcast("Received file %s, %d bytes, linux %d\r\n",
|
|
udp_file_g->filename, udp_file_g->total_bytes, udp_file_g->linux_boot);
|
print_serial("Received file %s, %d bytes",
|
if (process_file(socket0_g) == 0)
|
udp_file_g->filename, udp_file_g->total_bytes);
|
|
if (udp_file_g->linux_boot)
|
|
print_serial(", linux image detected\r\n");
|
|
else
|
|
print_serial("\r\n");
|
|
|
|
if (process_file(socket0_g) == 0) {
|
/* Disconnect in 1 second */
|
/* Disconnect in 1 second */
|
set_timer(reboot_timer, 1000);
|
set_timer(reboot_timer, 1000);
|
|
}
|
else
|
else
|
telnet_broadcast("Not an elf file\r\n");
|
print_serial("Not an elf file\r\n");
|
}
|
}
|
}
|
}
|
|
|
|
|
/* reboot timer expired */
|
/* reboot timer expired */
|
Line 321... |
Line 333... |
|
|
for(i=0;i<MEM_BUF_ENTRIES;i++)
|
for(i=0;i<MEM_BUF_ENTRIES;i++)
|
if (elf_mem0_g->entry[i].valid)
|
if (elf_mem0_g->entry[i].valid)
|
*(char *)(i) = elf_mem0_g->entry[i].data;
|
*(char *)(i) = elf_mem0_g->entry[i].data;
|
|
|
if (udp_file_g->linux_boot)
|
if (udp_file_g->linux_boot) {
|
|
print_serial("linux reboot\n\r");
|
_jump_to_program(LINUX_JUMP_ADR);
|
_jump_to_program(LINUX_JUMP_ADR);
|
else
|
}
|
|
else {
|
|
print_serial("normal reboot\n\r");
|
_restart();
|
_restart();
|
}
|
}
|
|
}
|
|
|
|
|
No newline at end of file
|
No newline at end of file
|