URL
https://opencores.org/ocsvn/amber/amber/trunk
Subversion Repositories amber
Compare Revisions
- This comparison shows the changes necessary to convert path
/amber
- from Rev 80 to Rev 81
- ↔ Reverse comparison
Rev 80 → Rev 81
/trunk/sw/boot-loader-serial/fpga-version.h
1,?rev1len? → ?rev2line?,?rev2len?
#define AMBER_FPGA_VERSION "20130506130110" |
#define AMBER_FPGA_VERSION "20130511142809" |
/trunk/sw/boot-loader-ethmac/telnet.h
42,10 → 42,38
#define MAX_TELNET_TX 1024 |
|
|
/* Telnet connection */ |
typedef struct { |
|
/* Telnet rx and tx line buffers */ |
line_buf_t* rxbuf; |
line_buf_t* txbuf; |
|
int sent_opening_message; |
int echo_mode; |
int connection_state; |
int options_sent; |
|
/* socket associated with this telnet connection */ |
//socket_t* socket; |
|
int id; |
|
/* pointers to the next telnet object in the chain and the first telnet object in the chain */ |
void* next; |
void* first; |
|
/* pointer to application (telnet) object */ |
app_t* app; |
} telnet_t; |
|
|
|
void parse_telnet_options (char *, socket_t*); |
void parse_telnet_payload (char *, socket_t*); |
void telnet_options (socket_t*); |
void telnet_tx (socket_t*, line_buf_t*); |
void process_telnet (socket_t*); |
int parse_command (socket_t*, char*); |
int parse_command (telnet_t*, char*); |
void telnet_disconnect (app_t *); |
|
/trunk/sw/boot-loader-ethmac/ethmac.c
156,11 → 156,14
} |
|
|
void tx_packet(int len) |
void ethmac_tx_packet(char* buf, int len) |
{ |
unsigned int status = 0; |
|
/* copy the packet into the tx buffer */ |
strncpy((char*)ETHMAC_TX_BUFFER, buf, len); |
|
|
/* Poll the ready bit. |
Wait until the ready bit is cleared by the ethmac hardware |
This holds everything up while the packet is being transmitted, but |
184,6 → 187,7
} |
|
|
|
/* returns 1 if link comes up */ |
int init_phy (void) |
{ |
/trunk/sw/boot-loader-ethmac/boot-loader-ethmac.c
16,7 → 16,7
// // |
////////////////////////////////////////////////////////////////// |
// // |
// Copyright (C) 2011 Authors and OPENCORES.ORG // |
// Copyright (C) 2011-2013 Authors and OPENCORES.ORG // |
// // |
// This source file may be used and distributed without // |
// restriction provided that this copyright statement is not // |
53,8 → 53,6
|
|
int main ( void ) { |
socket_t* socket; |
|
/* Enable the serial debug port */ |
init_serial(); |
print_serial("Amber debug port\n\r"); |
70,20 → 68,18
/* Create a timer to flash a led periodically */ |
init_led(); |
|
/* initialize the tftp stuff */ |
init_tftp(); |
|
|
/* create a tcp socket for listening */ |
first_socket_g = new_socket(NULL); |
socket = first_socket_g; |
|
/* initialize the PHY and MAC and listen for connections |
This is the last init because packets will be received from this point |
onwards. */ |
init_ethmac(); |
|
/* create a tcp socket for listening on port 23 */ |
listen_telnet(); |
|
/* initialize the tftp stuff */ |
init_tftp(); |
|
|
/* Process loop. Everything is timer, interrupt and queue driven from here on down */ |
while (1) { |
|
93,14 → 89,8
/* Check for received tftp files and reboot */ |
process_tftp(); |
|
/* handle tcp connections and process buffers */ |
/* Poll all sockets in turn for activity */ |
if (socket->next == NULL) |
socket = first_socket_g; |
else |
socket = socket->next; |
|
process_tcp(socket); |
/* Process all socket traffic */ |
process_sockets(); |
} |
} |
|
/trunk/sw/boot-loader-ethmac/ethmac.h
53,3 → 53,4
unsigned short mdio_ctrl (unsigned int addr, unsigned int dir, unsigned int reg, unsigned short data); |
|
void ethmac_interrupt (void); |
void ethmac_tx_packet (char*, int); |
/trunk/sw/boot-loader-ethmac/packet.c
63,22 → 63,23
{ |
/* receive packet buffer */ |
rx_packet_g = malloc(sizeof(packet_t)); |
rx_packet_g->tcp_window_scale = 0; |
} |
|
|
|
void ethernet_header(char *buf, mac_ip_t* target, unsigned short type) |
void ethernet_header(char *buf, mac_t* target_mac, unsigned short type) |
{ |
/* ethernet header */ |
/* DA */ |
buf[ 0] = target->mac[0]; |
buf[ 1] = target->mac[1]; |
buf[ 2] = target->mac[2]; |
buf[ 3] = target->mac[3]; |
buf[ 4] = target->mac[4]; |
buf[ 5] = target->mac[5]; |
strncpy(&buf[0], target_mac, 6); |
// print_serial("%s:L%d ethernet header target mac %x:%x:%x:%x:%x:%x\n\r", |
// __FILE__, __LINE__, |
// target_mac->mac[0], target_mac->mac[1], target_mac->mac[2], |
// target_mac->mac[3], target_mac->mac[4], target_mac->mac[5] |
// ); |
|
/* SA */ |
strncpy(&buf[6], &self_g.mac[0], 6); |
buf[ 6] = self_g.mac[0]; |
buf[ 7] = self_g.mac[1]; |
buf[ 8] = self_g.mac[2]; |
92,7 → 93,7
} |
|
|
void ip_header(char *buf, mac_ip_t* target, unsigned short ip_len, char ip_proto) |
void ip_header(char *buf, ip_t* target_ip, unsigned short ip_len, char ip_proto) |
{ |
unsigned short header_checksum; |
static unsigned short ip_id = 0; |
127,16 → 128,10
buf[11] = 0; |
|
/* Source IP */ |
buf[12] = self_g.ip[0]; |
buf[13] = self_g.ip[1]; |
buf[14] = self_g.ip[2]; |
buf[15] = self_g.ip[3]; |
strncpy(&buf[12], &self_g.ip[0], 4); |
|
/* Destination IP */ |
buf[16] = target->ip[0]; |
buf[17] = target->ip[1]; |
buf[18] = target->ip[2]; |
buf[19] = target->ip[3]; |
strncpy(&buf[16], target_ip, 4); |
|
/* header checksum */ |
header_checksum = header_checksum16(buf, 20, 0); |
145,11 → 140,12
} |
|
|
void arp_reply(char *buf, mac_ip_t* arp_sender) |
|
void arp_reply(mac_t* arp_sender_mac, ip_t* arp_sender_ip) |
{ |
char buf [44]; |
ethernet_header(buf, arp_sender_mac, 0x0806); |
|
ethernet_header(buf, arp_sender, 0x0806); |
|
/* Hardware Type */ |
buf[14] = 0x00; |
buf[15] = 0x01; |
180,19 → 176,19
buf[31] = self_g.ip[3]; |
|
/* Target MAC */ |
buf[32] = arp_sender->mac[0]; |
buf[33] = arp_sender->mac[1]; |
buf[34] = arp_sender->mac[2]; |
buf[35] = arp_sender->mac[3]; |
buf[36] = arp_sender->mac[4]; |
buf[37] = arp_sender->mac[5]; |
buf[32] = arp_sender_mac->mac[0]; |
buf[33] = arp_sender_mac->mac[1]; |
buf[34] = arp_sender_mac->mac[2]; |
buf[35] = arp_sender_mac->mac[3]; |
buf[36] = arp_sender_mac->mac[4]; |
buf[37] = arp_sender_mac->mac[5]; |
|
/* Target IP */ |
buf[38] = arp_sender->ip[0]; |
buf[39] = arp_sender->ip[1]; |
buf[40] = arp_sender->ip[2]; |
buf[41] = arp_sender->ip[3]; |
tx_packet(42); |
buf[38] = arp_sender_ip->ip[0]; |
buf[39] = arp_sender_ip->ip[1]; |
buf[40] = arp_sender_ip->ip[2]; |
buf[41] = arp_sender_ip->ip[3]; |
ethmac_tx_packet(buf, 42); |
} |
|
|
201,24 → 197,12
|
int i; |
unsigned short header_checksum; |
mac_ip_t target; |
char * buf = (char*)ETHMAC_TX_BUFFER; |
// mac_ip_t target; |
char buf [96]; // not sure how long this needs to be = (char*)ETHMAC_TX_BUFFER; |
|
target.mac[0] = rx_packet->src_mac[0]; |
target.mac[1] = rx_packet->src_mac[1]; |
target.mac[2] = rx_packet->src_mac[2]; |
target.mac[3] = rx_packet->src_mac[3]; |
target.mac[4] = rx_packet->src_mac[4]; |
target.mac[5] = rx_packet->src_mac[5]; |
ethernet_header(buf, (mac_t*) rx_packet->src_mac, 0x0800); /*bytes 0 to 13*/ |
ip_header(&buf[14], (ip_t*) rx_packet->src_ip, rx_packet->ip_len, 1); /* bytes 14 to 33, ip_proto = 1, ICMP*/ |
|
target.ip[0] = rx_packet->src_ip[0]; |
target.ip[1] = rx_packet->src_ip[1]; |
target.ip[2] = rx_packet->src_ip[2]; |
target.ip[3] = rx_packet->src_ip[3]; |
|
ethernet_header(buf, &target, 0x0800); /*bytes 0 to 13*/ |
ip_header(&buf[14], &target, rx_packet->ip_len, 1); /* bytes 14 to 33, ip_proto = 1, ICMP*/ |
|
/* ICMP */ |
/* Type = reply */ |
buf[34] = 0; |
245,7 → 229,7
header_checksum = header_checksum16(&buf[34], (rx_packet->ip_len)-20, 0); |
buf[36] = (header_checksum>>8)&0xff; |
buf[37] = header_checksum&0xff; |
tx_packet(rx_packet->ip_len+14); |
ethmac_tx_packet(buf, rx_packet->ip_len+14); |
} |
|
|
288,43 → 272,48
asking 'does this IP address belong to you?" |
*/ |
int arp_op; |
mac_ip_t arp_sender, arp_target; |
//mac_ip_t arp_sender, arp_target; |
mac_t arp_sender_mac; |
ip_t arp_sender_ip; |
|
arp_op = buf[6]<<8 | buf[7]; |
|
arp_sender.mac[0] = buf[8]; |
arp_sender.mac[1] = buf[9]; |
arp_sender.mac[2] = buf[10]; |
arp_sender.mac[3] = buf[11]; |
arp_sender.mac[4] = buf[12]; |
arp_sender.mac[5] = buf[13]; |
strncpy(&arp_sender_mac, &buf[8], 6); |
strncpy(&arp_sender_ip, &buf[14], 4); |
|
arp_sender.ip [0] = buf[14]; |
arp_sender.ip [1] = buf[15]; |
arp_sender.ip [2] = buf[16]; |
arp_sender.ip [3] = buf[17]; |
// arp_sender.mac[0] = buf[8]; |
// arp_sender.mac[1] = buf[9]; |
// arp_sender.mac[2] = buf[10]; |
// arp_sender.mac[3] = buf[11]; |
// arp_sender.mac[4] = buf[12]; |
// arp_sender.mac[5] = buf[13]; |
|
arp_target.mac[0] = buf[18]; |
arp_target.mac[1] = buf[19]; |
arp_target.mac[2] = buf[20]; |
arp_target.mac[3] = buf[21]; |
arp_target.mac[4] = buf[22]; |
arp_target.mac[5] = buf[23]; |
// arp_sender.ip [0] = buf[14]; |
// arp_sender.ip [1] = buf[15]; |
// arp_sender.ip [2] = buf[16]; |
// arp_sender.ip [3] = buf[17]; |
|
arp_target.ip [0] = buf[24]; |
arp_target.ip [1] = buf[25]; |
arp_target.ip [2] = buf[26]; |
arp_target.ip [3] = buf[27]; |
// arp_target.mac[0] = buf[18]; |
// arp_target.mac[1] = buf[19]; |
// arp_target.mac[2] = buf[20]; |
// arp_target.mac[3] = buf[21]; |
// arp_target.mac[4] = buf[22]; |
// arp_target.mac[5] = buf[23]; |
|
// arp_target.ip [0] = buf[24]; |
// arp_target.ip [1] = buf[25]; |
// arp_target.ip [2] = buf[26]; |
// arp_target.ip [3] = buf[27]; |
|
/* Send a reply ? */ |
if (arp_op==1 && |
arp_target.ip[0]==self_g.ip[0] && |
arp_target.ip[1]==self_g.ip[1] && |
arp_target.ip[2]==self_g.ip[2] && |
arp_target.ip[3]==self_g.ip[3]) { |
buf[24]==self_g.ip[0] && |
buf[25]==self_g.ip[1] && |
buf[26]==self_g.ip[2] && |
buf[27]==self_g.ip[3]) { |
|
// ARP reply |
arp_reply((char*)ETHMAC_TX_BUFFER, &arp_sender); |
arp_reply(&arp_sender_mac, &arp_sender_ip); |
} |
} |
|
336,7 → 325,7
|
ip_version = buf[0]>>4; |
if (ip_version != 4) { |
//printf("%s: IP version %d not supported\n", __func__, ip_version); |
print_serial("%s:L%d IP version %d not supported\n\r", __FILE__, __LINE__, ip_version); |
return; |
} |
|
/trunk/sw/boot-loader-ethmac/packet.h
118,7 → 118,19
} mac_ip_t; |
|
|
|
typedef struct { |
unsigned char ip[4]; |
} ip_t; |
|
|
typedef struct { |
unsigned char mac[6]; |
unsigned char stuffing[2]; /* word aligned */ |
} mac_t; |
|
|
typedef struct { |
unsigned int payload_valid; |
unsigned int starting_seq; |
unsigned int ending_seq; |
150,6 → 162,12
unsigned int tcp_ack; |
unsigned int tcp_flags; |
unsigned int tcp_window_size; |
|
/* the TCP that sent this option will right-shift its true |
receive-window values by 'shift.cnt' bits for transmission in |
SEG.WND. */ |
unsigned int tcp_window_scale; |
|
unsigned int tcp_len; |
unsigned int tcp_payload_len; |
unsigned int tcp_src_time_stamp; |
183,11 → 201,11
void init_packet (); |
unsigned short header_checksum16 (unsigned char *buf, unsigned short len, unsigned int sum); |
|
void arp_reply (char *buf, mac_ip_t*); |
void arp_reply (mac_t*, ip_t*); |
void ping_reply (packet_t* packet0, int ping_id, int ping_seq, char * rx_buf); |
|
void ethernet_header (char *buf, mac_ip_t* target, unsigned short type); |
void ip_header (char *buf, mac_ip_t* target, unsigned short ip_len, char ip_proto); |
void ethernet_header (char*, mac_t*, unsigned short); |
void ip_header (char*, ip_t*, unsigned short, char); |
|
void parse_rx_packet (char*, packet_t*); |
void parse_arp_packet (char*); |
/trunk/sw/boot-loader-ethmac/tftp.c
182,12 → 182,14
set_timer(reboot_timer_g, 1000); |
reboot_stage_g = 1; |
socket = first_socket_g; |
for(;;){ |
socket->tcp_disconnect = 1; |
if (socket->next!=NULL) |
socket=socket->next; |
else |
break; |
if (socket != NULL){ |
for(;;){ |
socket->tcp_disconnect = 1; |
if (socket->next!=NULL) |
socket=socket->next; |
else |
break; |
} |
} |
} |
else { |
/trunk/sw/boot-loader-ethmac/start.S
192,7 → 192,8
|
|
service_irq: |
@ As this is an interrupt, need tp save all registers to the stack |
@ As this is an interrupt, need to save all registers to the stack |
@ that will be used here |
stmfd sp!, {r0-r3, lr} |
|
@ is it a timer interrupt ? |
/trunk/sw/boot-loader-ethmac/serial.c
43,6 → 43,16
#include "amber_registers.h" |
|
|
#define DEBUG 1 |
|
#ifdef DEBUG |
#define trace(fmt, args...) print_serial("%s:%s:%d: "fmt"\n\r", __FILE__, __FUNCTION__, __LINE__, args) |
#else |
#define trace(fmt, args...) |
#endif |
|
|
|
void init_serial() |
{ |
/* Enable UART 0 */ |
50,6 → 60,7
} |
|
|
|
/* Add a line to the line buffer */ |
void print_serial(const char *fmt, ...) |
{ |
/trunk/sw/boot-loader-ethmac/serial.h
41,6 → 41,15
// // |
----------------------------------------------------------------*/ |
|
//#define DEBUG 1 |
|
#ifdef DEBUG |
#define trace(fmt, ...) print_serial("%s:%s:%d: "fmt"\n\r", __FILE__, __FUNCTION__, __LINE__, ##__VA_ARGS__) |
#else |
#define trace(fmt, ...) |
#endif |
|
|
/* Function prototypes */ |
void init_serial(); |
void print_serial(const char *fmt, ...); |
/trunk/sw/boot-loader-ethmac/tcp.c
50,13 → 50,14
#include "packet.h" |
#include "tcp.h" |
#include "telnet.h" |
#include "serial.h" |
|
|
/* Global variables */ |
int tcp_checksum_errors_g = 0; |
socket_t* first_socket_g; |
socket_t* socket1_g; |
socket_t* first_socket_g = NULL; |
|
|
/* input argument is a pointer to the previous socket, |
if this is the first socket object, then it is NULL */ |
socket_t* new_socket(socket_t* prev) |
80,27 → 81,19
socket->tcp_buf[i]->ack_received = 0; |
} |
|
socket->telnet_txbuf = init_line_buffer(0x80000); |
socket->telnet_rxbuf = init_line_buffer(0x1000); |
|
socket->packets_sent = 0; |
socket->packets_received = 0; |
socket->packets_resent = 0; |
|
socket->telnet_sent_opening_message = 0; |
socket->telnet_echo_mode = 0; |
socket->telnet_connection_state = TELNET_CLOSED; |
socket->telnet_options_sent = 0; |
|
socket->tcp_current_buf = 0; |
socket->tcp_reset = 0; |
socket->tcp_connection_state = TCP_CLOSED; |
socket->tcp_disconnect = 0; |
socket->tcp_seq = 0x100; /* should be random initial seq number for tcp */ |
socket->tcp_last_seq = socket->tcp_seq; |
socket->tcp_last_ack = 0; |
socket->tcp_tx_seq = 0x100; /* should be random initial seq number for tcp */ |
socket->tcp_rx_ack = 0; |
socket->tcp_bytes_received = 0; |
socket->tcp_bytes_acked = 0; |
|
|
/* Chain the socket objects together */ |
if (prev == NULL){ |
socket->first = socket; |
117,6 → 110,44
} |
|
|
|
/* returns the socket id */ |
int listen_socket (unsigned int listen_port, app_t* app) |
{ |
socket_t* socket; |
|
/* Add a new socket to the end of the list */ |
if (first_socket_g == NULL) { |
trace("first_socket_g == NULL"); |
first_socket_g = new_socket(NULL); |
socket = first_socket_g; |
} |
else { |
socket = first_socket_g; |
for(;;){ |
if (socket->next!=NULL) |
socket=socket->next; |
else |
break; |
} |
socket = new_socket(socket); |
} |
|
socket->listen_port = listen_port; |
socket->tcp_connection_state = TCP_LISTENING; |
|
/* Assign the telnet object */ |
socket->app = app; |
/* cross link, so can find the socket object when have pointer to the telnet object */ |
socket->app->socket = socket; |
|
trace("new socket %d listening", socket->id); |
|
return socket->id; |
} |
|
|
|
/* All received tcp packets with dset ip == me arrive here */ |
void parse_tcp_packet(char * buf, packet_t* rx_packet) |
{ |
149,11 → 180,9
rx_packet->tcp_flags = buf[13]; |
rx_packet->tcp_window_size = buf[14]<<8|buf[15]; |
|
// trace("client tcp rx window %d bytes", |
// (rx_packet->tcp_window_size)<<rx_packet->tcp_window_scale); |
|
/* only interested in telnet packet to dest port xx */ |
if (rx_packet->tcp_dst_port != 23) { |
return; |
} |
|
if (rx_packet->tcp_hdr_len > 20) { |
/* Get the source time stamp */ |
161,13 → 190,27
} |
|
|
/* only interested in telnet packet to dest port xx */ |
//if (rx_packet->tcp_dst_port != 23) { |
// return; |
//} |
|
|
/* -------------------------------------------------- |
Assign the received packet to a socket |
-------------------------------------------------- */ |
/* seach for an open socket that matches the tcp connection */ |
socket = first_socket_g; |
if (socket == NULL) { |
trace("first socket is null"); |
return; |
} |
|
|
/* Search for an already open socket */ |
for(;;){ |
if (socket->tcp_connection_state != TCP_CLOSED && |
if ((socket->tcp_connection_state == TCP_PENDING || |
socket->tcp_connection_state == TCP_OPEN) && |
socket->rx_packet->tcp_src_port == rx_packet->tcp_src_port) { |
found=1; |
break; |
179,13 → 222,17
} |
|
|
/* Search for an available closed soeckt to reuse */ |
/* Search for a listening socket */ |
if (!found){ |
socket = first_socket_g; |
trace("search for listening socket"); |
|
for(;;){ |
if (socket->tcp_connection_state == TCP_CLOSED) { |
found=1; |
break; |
if (socket->tcp_connection_state == TCP_LISTENING) { |
if (socket->listen_port == rx_packet->tcp_dst_port) { |
found=1; |
break; |
} |
} |
if (socket->next!=NULL) |
socket=socket->next; |
197,10 → 244,10
|
/* All available sockets being used. Add a new one to the end of the chain */ |
if (!found) { |
socket = new_socket(socket); |
} |
trace("not found"); |
return; |
} |
|
|
/* Copy the rx_packet structure into the socket */ |
memcpy(socket->rx_packet, rx_packet, sizeof(packet_t)); |
|
219,7 → 266,13
case 0: ptr=rx_packet->tcp_hdr_len; break; // end of options |
case 1: ptr++; break; |
case 2: ptr = ptr + buf[ptr+1]; break; // max segment size |
case 3: ptr = ptr + buf[ptr+1]; break; // Window Scale |
case 3: |
// Window Scale |
trace("%s:L%d window scale bytes %d, 0x%x", buf[ptr+1], buf[ptr+2]); |
rx_packet->tcp_window_scale = buf[ptr+2]; |
ptr = ptr + buf[ptr+1]; |
break; |
|
case 4: ptr = ptr + buf[ptr+1]; break; // SACK Permitted |
case 5: ptr = ptr + buf[ptr+1]; break; // SACK |
case 8: |
241,6 → 294,7
void tcp_response(char * buf, socket_t* socket) |
{ |
socket->packets_received++; |
trace("tcp_response"); |
|
/* Mark the ack in the tcp tx packet buffer so the tx packet does not get resent */ |
if (socket->rx_packet->tcp_flags & 0x10) // ack flag set ? |
254,9 → 308,10
} |
|
// open a connection |
else if (socket->tcp_connection_state == TCP_CLOSED) { |
else if (socket->tcp_connection_state == TCP_LISTENING) { |
|
if (socket->rx_packet->tcp_flags & 0x02) { // SYN |
trace("tcp_open"); |
// Open connection |
tcp_open(socket); |
socket->tcp_connection_state = TCP_PENDING; |
273,7 → 328,7
else if (socket->tcp_connection_state == TCP_PENDING) { |
/* Add 1 to the sequence number as a special case to open |
the connection */ |
socket->tcp_seq++; |
socket->tcp_tx_seq++; |
socket->tcp_connection_state = TCP_OPEN; |
} |
|
283,6 → 338,10
|
/* contains tcp payload */ |
if (socket->rx_packet->tcp_payload_len != 0) { |
|
socket->tcp_bytes_received += socket->rx_packet->tcp_payload_len; |
trace("socket %d received total %d bytes", socket->id, socket->tcp_bytes_received); |
|
/* Ack the packet only if the payload length is non-zero */ |
tcp_reply(socket, NULL, 0); |
|
297,14 → 356,20
|
void tcp_disconnect(socket_t * socket) |
{ |
telnet_t* telnet; |
|
if (socket->tcp_connection_state != TCP_CLOSED) { |
socket->tcp_connection_state = TCP_CLOSED; |
socket->telnet_connection_state = TELNET_CLOSED; |
socket->telnet_options_sent = 0; |
socket->telnet_sent_opening_message = 0; |
tcp_reply(socket, NULL, 0); |
|
/* app level disconnect function */ |
switch(socket->app->type) { |
case APP_TELNET: telnet_disconnect(socket->app); |
break; |
default: |
trace("Unknown app type"); |
} |
socket->tcp_disconnect = 0; |
socket->telnet_echo_mode = 0; // reset this setting |
} |
} |
|
331,43 → 396,32
|
int i, j; |
unsigned short header_checksum; |
mac_ip_t target; |
int ip_length; |
char * buf; |
|
|
buf = socket->tcp_buf[socket->tcp_current_buf]->buf; |
|
strncpy(&socket->dest_ip, socket->rx_packet->src_ip, 4); |
strncpy(&socket->dest_mac, socket->rx_packet->src_mac, 6); |
|
target.mac[0] = socket->rx_packet->src_mac[0]; |
target.mac[1] = socket->rx_packet->src_mac[1]; |
target.mac[2] = socket->rx_packet->src_mac[2]; |
target.mac[3] = socket->rx_packet->src_mac[3]; |
target.mac[4] = socket->rx_packet->src_mac[4]; |
target.mac[5] = socket->rx_packet->src_mac[5]; |
target.ip[0] = socket->rx_packet->src_ip[0]; |
target.ip[1] = socket->rx_packet->src_ip[1]; |
target.ip[2] = socket->rx_packet->src_ip[2]; |
target.ip[3] = socket->rx_packet->src_ip[3]; |
|
|
/* Include 20 bytes of tcp options */ |
ip_length = 20+20+20; /* 20 bytes ip header, 20 bytes tcp header, 20 bytes tcp options */ |
|
/* fill in the information about the packet about to be sent */ |
socket->tcp_buf[socket->tcp_current_buf]->payload_valid = 1; |
socket->tcp_buf[socket->tcp_current_buf]->ack_received = 0; |
socket->tcp_buf[socket->tcp_current_buf]->starting_seq = tcp_header(&buf[34], socket, 0, TCP_NEW); |
socket->tcp_buf[socket->tcp_current_buf]->ending_seq = socket->tcp_buf[socket->tcp_current_buf]->starting_seq + 1; |
socket->tcp_buf[socket->tcp_current_buf]->len_bytes = 14+ip_length; |
set_timer(&socket->tcp_buf[socket->tcp_current_buf]->resend_time, 500); |
|
ip_header(&buf[14], &target, ip_length, 6); /* 20 byes of tcp options, bytes 14 to 33, ip_proto = 6, TCP*/ |
ethernet_header(buf, &target, 0x0800); /* bytes 0 to 13*/ |
ip_header(&buf[14], &socket->dest_ip, ip_length, 6); /* 20 byes of tcp options, bytes 14 to 33, ip_proto = 6, TCP*/ |
ethernet_header(buf, &socket->dest_mac, 0x0800); /* bytes 0 to 13*/ |
|
socket->tcp_buf[socket->tcp_current_buf]->len_bytes = 14+ip_length; |
|
strncpy((char*)ETHMAC_TX_BUFFER, buf, socket->tcp_buf[socket->tcp_current_buf]->len_bytes); |
|
tx_packet(socket->tcp_buf[socket->tcp_current_buf]->len_bytes); // MAC header, IP header, TCP header, TCP options |
/* transmit an ethernet frame */ |
//trace("tx_packet buf 0x%d, len %d", |
// (unsigned int)buf, socket->tcp_buf[socket->tcp_current_buf]->len_bytes); |
ethmac_tx_packet(buf, socket->tcp_buf[socket->tcp_current_buf]->len_bytes); |
socket->packets_sent++; |
|
|
384,24 → 438,11
{ |
|
int i, j; |
mac_ip_t target; |
int ip_length; |
char * buf; |
|
|
buf = socket->tcp_buf[socket->tcp_current_buf]->buf; |
|
target.mac[0] = socket->rx_packet->src_mac[0]; |
target.mac[1] = socket->rx_packet->src_mac[1]; |
target.mac[2] = socket->rx_packet->src_mac[2]; |
target.mac[3] = socket->rx_packet->src_mac[3]; |
target.mac[4] = socket->rx_packet->src_mac[4]; |
target.mac[5] = socket->rx_packet->src_mac[5]; |
target.ip[0] = socket->rx_packet->src_ip[0]; |
target.ip[1] = socket->rx_packet->src_ip[1]; |
target.ip[2] = socket->rx_packet->src_ip[2]; |
target.ip[3] = socket->rx_packet->src_ip[3]; |
|
ip_length = 20+20 + telnet_payload_length; |
|
/* Copy the payload into the transmit buffer */ |
416,19 → 457,20
else |
socket->tcp_buf[socket->tcp_current_buf]->payload_valid = 0; |
|
/* fill in the information about the packet about to be sent */ |
socket->tcp_buf[socket->tcp_current_buf]->ack_received = 0; |
socket->tcp_buf[socket->tcp_current_buf]->starting_seq = tcp_header(&buf[34], socket, telnet_payload_length, TCP_NORMAL); |
socket->tcp_buf[socket->tcp_current_buf]->ending_seq = socket->tcp_buf[socket->tcp_current_buf]->starting_seq + telnet_payload_length; |
socket->tcp_buf[socket->tcp_current_buf]->len_bytes = 14+ip_length; |
set_timer(&socket->tcp_buf[socket->tcp_current_buf]->resend_time, 500); |
|
ip_header(&buf[14], &target, ip_length, 6); /* 20 byes of tcp options, bytes 14 to 33, ip_proto = 6, TCP*/ |
ethernet_header(buf, &target, 0x0800); /*bytes 0 to 13*/ |
/* Create the IP header */ |
/* 20 byes of tcp options, bytes 14 to 33, ip_proto = 6, TCP*/ |
ip_header(&buf[14], &socket->dest_ip, ip_length, 6); /* 20 byes of tcp options, bytes 14 to 33, ip_proto = 6, TCP*/ |
ethernet_header(buf, &socket->dest_mac, 0x0800); /* bytes 0 to 13*/ |
|
socket->tcp_buf[socket->tcp_current_buf]->len_bytes = 14+ip_length; |
|
strncpy((char*)ETHMAC_TX_BUFFER, buf, socket->tcp_buf[socket->tcp_current_buf]->len_bytes); |
|
tx_packet(socket->tcp_buf[socket->tcp_current_buf]->len_bytes); // MAC header, IP header, TCP header, TCP options |
/* transmit an ethernet frame */ |
ethmac_tx_packet(buf, socket->tcp_buf[socket->tcp_current_buf]->len_bytes); |
socket->packets_sent++; |
|
|
441,13 → 483,12
|
|
|
|
/* Find the packets lower than or equal to seq and mark them as acked */ |
void tcp_ack(socket_t* socket) |
{ |
int i, ack_valid; |
unsigned int ack = socket->rx_packet->tcp_ack; |
unsigned int last_ack = socket->tcp_last_ack; |
unsigned int last_ack = socket->tcp_rx_ack; |
|
for (i=0;i<TCP_TX_BUFFERS;i=i+1) { |
if (socket->tcp_buf[i]->payload_valid) { |
471,7 → 512,7
} |
} |
|
socket->tcp_last_ack = ack; |
socket->tcp_rx_ack = ack; |
} |
|
|
493,8 → 534,8
/* Disable ethmac_int interrupt */ |
*(unsigned int *) ( ADR_AMBER_IC_IRQ0_ENABLECLR ) = 0x100; |
|
strncpy((char*)ETHMAC_TX_BUFFER, socket->tcp_buf[i]->buf, socket->tcp_buf[i]->len_bytes); |
tx_packet(socket->tcp_buf[i]->len_bytes); // MAC header, IP header, TCP header, TCP options |
/* transmit an ethernet frame */ |
ethmac_tx_packet(socket->tcp_buf[i]->buf, socket->tcp_buf[i]->len_bytes); |
socket->packets_sent++; |
|
|
527,9 → 568,8
|
/* Sequence Number */ |
/* Increment the sequence number for the next packet */ |
starting_seq = socket->tcp_seq; |
socket->tcp_last_seq = socket->tcp_seq; |
socket->tcp_seq += payload_length; |
starting_seq = socket->tcp_tx_seq; |
socket->tcp_tx_seq += payload_length; |
|
|
buf[4] = starting_seq>>24; |
539,8 → 579,10
|
|
/* Ack Number */ |
if (options == TCP_NEW) |
if (options == TCP_NEW) { |
ack_num = socket->rx_packet->tcp_seq + 1; |
socket->tcp_rx_init_seq = socket->rx_packet->tcp_seq; |
} |
else if (socket->rx_packet->tcp_flags & 0x01) // FIN |
// +1 to the final ack |
ack_num = socket->rx_packet->tcp_seq + 1; |
547,6 → 589,11
else |
ack_num = socket->rx_packet->tcp_seq + socket->rx_packet->tcp_payload_len; |
|
socket->tcp_rx_seq= ack_num; |
//trace("socket %d received seq %d", |
// socket->id, socket->tcp_rx_seq - socket->tcp_rx_init_seq); |
|
|
buf[8] = ack_num>>24; |
buf[9] = (ack_num>>16)&0xff; |
buf[10] = (ack_num>>8)&0xff; |
667,11 → 714,15
Poll all sockets in turn for activity */ |
void process_tcp(socket_t* socket) |
{ |
telnet_t* telnet; |
|
/* Check if any tcp packets need to be re-transmitted */ |
tcp_retransmit(socket); |
|
/* Handle exit command */ |
if (socket->tcp_disconnect && socket->tcp_connection_state == TCP_OPEN) { |
trace("calling tcp disconnect %d", |
socket->tcp_rx_seq - socket->tcp_rx_init_seq); |
tcp_disconnect(socket); |
} |
|
678,8 → 729,11
/* Reset connection */ |
else if (socket->tcp_reset) { |
socket->tcp_connection_state = TCP_CLOSED; |
socket->telnet_connection_state = TELNET_CLOSED; |
socket->telnet_options_sent = 0; |
|
telnet = (telnet_t*) socket->app->telnet; |
telnet->connection_state = TELNET_CLOSED; |
telnet->options_sent = 0; |
|
tcp_reply(socket, NULL, 0); |
socket->tcp_reset = 0; |
} |
686,7 → 740,31
|
/* handle telnet messages */ |
else if (socket->tcp_connection_state == TCP_OPEN){ |
process_telnet(socket); |
|
/* app level process function */ |
switch(socket->app->type) { |
case APP_TELNET: process_telnet(socket); |
break; |
default: |
trace("Unknown app type"); |
} |
} |
} |
|
|
|
void process_sockets() |
{ |
socket_t* socket; |
|
/* handle tcp connections and process buffers */ |
/* Poll all sockets in turn for activity */ |
socket = first_socket_g; |
for(;;){ |
process_tcp(socket); |
if (socket->next!=NULL) |
socket=socket->next; |
else |
break; |
} |
} |
/trunk/sw/boot-loader-ethmac/udp.c
95,7 → 95,7
|
void udp_reply(packet_t* rx_packet, int udp_src_port, int udp_dst_port, int block, int reply_type) |
{ |
char* buf = (char*)ETHMAC_TX_BUFFER; |
char buf[96]; |
unsigned short checksum; |
unsigned short prot_udp=17; |
unsigned short udp_len; |
102,19 → 102,7
unsigned short word16; |
unsigned long sum = 0; |
int i; |
mac_ip_t target; |
|
target.mac[0] = rx_packet->src_mac[0]; |
target.mac[1] = rx_packet->src_mac[1]; |
target.mac[2] = rx_packet->src_mac[2]; |
target.mac[3] = rx_packet->src_mac[3]; |
target.mac[4] = rx_packet->src_mac[4]; |
target.mac[5] = rx_packet->src_mac[5]; |
target.ip[0] = rx_packet->src_ip[0]; |
target.ip[1] = rx_packet->src_ip[1]; |
target.ip[2] = rx_packet->src_ip[2]; |
target.ip[3] = rx_packet->src_ip[3]; |
|
/* udp header */ |
buf[34] = (udp_src_port & 0xff00)>>8; |
buf[35] = udp_src_port & 0xff; |
172,8 → 160,9
buf[40] = (checksum & 0xff00)>>8; // checksum |
buf[41] = checksum & 0xff; // checksum |
|
ip_header(&buf[14], &target, 20+udp_len, 17); /* 20 byes of tcp options, bytes 14 to 33, ip_proto = 17, UDP */ |
ethernet_header(buf, &target, 0x0800); /*bytes 0 to 13*/ |
tx_packet(34+udp_len); // packet length in bytes |
ip_header(&buf[14], (ip_t*) rx_packet->src_ip, 20+udp_len, 17); /* 20 byes of tcp options, bytes 14 to 33, ip_proto = 17, UDP */ |
ethernet_header(buf, (mac_t*) rx_packet->src_mac, 0x0800); /*bytes 0 to 13*/ |
|
ethmac_tx_packet(buf, 34+udp_len); // packet length in bytes |
} |
|
/trunk/sw/boot-loader-ethmac/tcp.h
41,8 → 41,9
|
enum tcp_state { |
TCP_CLOSED = 0, |
TCP_PENDING = 1, |
TCP_OPEN = 2 |
TCP_LISTENING = 1, |
TCP_PENDING = 2, |
TCP_OPEN = 3 |
}; |
|
|
53,41 → 54,63
}; |
|
|
enum app_type { |
APP_TELNET = 0, |
APP_HTTPD = 1, |
APP_FTPD = 2 |
}; |
|
|
typedef struct { |
/* socket associated with this application */ |
void* socket; |
void* telnet; |
int type; |
} app_t; |
|
packet_buffer_t** tcp_buf; |
int tcp_current_buf; |
|
/* Telnet rx and tx line buffers */ |
line_buf_t* telnet_rxbuf; |
line_buf_t* telnet_txbuf; |
|
int telnet_sent_opening_message; |
int telnet_echo_mode; |
int telnet_connection_state; |
int telnet_options_sent; |
typedef struct { |
|
int packets_sent; |
int packets_received; |
int packets_resent; |
packet_buffer_t** tcp_buf; |
int tcp_current_buf; |
|
int tcp_connection_state; |
int tcp_reset; |
int tcp_disconnect; |
int tcp_seq; /* should be random initial seq number for tcp */ |
int tcp_last_seq; |
unsigned int tcp_last_ack; |
int packets_sent; |
int packets_received; |
int packets_resent; |
|
int id; |
int tcp_connection_state; |
int tcp_reset; |
int tcp_disconnect; |
|
packet_t* rx_packet; /* Header info from last packet received */ |
/* byte sequence numbers */ |
unsigned int tcp_tx_seq; /* initial value should be random initial seq number for tcp */ |
|
unsigned int tcp_rx_init_seq; /* Initial byte sequence number received from client */ |
unsigned int tcp_rx_seq; /* is equivalent to tcp_tx_ack */ |
unsigned int tcp_rx_ack; |
|
unsigned int tcp_bytes_received; |
unsigned int tcp_bytes_acked; |
|
ip_t dest_ip; /* IP address of the far end */ |
mac_t dest_mac; /* MAC address of the far end */ |
unsigned int listen_port; /* Listen on this port for connection requests */ |
int id; |
|
packet_t* rx_packet; /* Header info from last packet received */ |
|
/* pointers to the next socket in the chain and the first socket in the chain */ |
void* next; |
void* first; |
void* next; |
void* first; |
|
/* pointer to generic application object */ |
app_t* app; |
} socket_t; |
|
|
|
|
/* Global Variables */ |
extern socket_t* first_socket_g; |
extern int tcp_checksum_errors_g; |
95,9 → 118,11
|
/* Function prototypes */ |
socket_t* new_socket (socket_t* prev); |
int listen_socket (unsigned int, app_t*); |
void process_sockets (); |
|
unsigned short tcp_checksum (unsigned char *, packet_t*, unsigned short); |
unsigned int tcp_header (char *, socket_t*, int, int); |
unsigned short tcp_checksum (unsigned char*, packet_t*, unsigned short); |
unsigned int tcp_header (char*, socket_t*, int, int); |
void tcp_reply (socket_t*, char*, int); |
void tcp_open (socket_t*); |
void tcp_retransmit (socket_t*); |
109,4 → 134,3
void parse_tcp_packet (char*, packet_t*); |
void process_tcp (socket_t*); |
|
|
/trunk/sw/boot-loader-ethmac/telnet.c
45,14 → 45,103
#include "timer.h" |
#include "line-buffer.h" |
#include "packet.h" |
#include "serial.h" |
#include "tcp.h" |
#include "telnet.h" |
#include "utilities.h" |
|
/* Global variables */ |
telnet_t* first_telnet_g = NULL; |
|
|
/* input argument is a pointer to the previous socket, |
if this is the first socket object, then it is NULL */ |
telnet_t* new_telnet(telnet_t* prev) |
{ |
telnet_t* telnet; |
app_t* app; |
|
telnet = (telnet_t*) malloc(sizeof(telnet_t)); |
app = (app_t*) malloc(sizeof(app_t)); |
|
/* cross reference between the two objects */ |
app->telnet = telnet; |
app->type = APP_TELNET; |
telnet->app = app; |
|
telnet->txbuf = init_line_buffer(0x80000); |
telnet->rxbuf = init_line_buffer(0x1000); |
|
telnet->sent_opening_message = 0; |
telnet->echo_mode = 0; |
telnet->connection_state = TELNET_CLOSED; |
telnet->options_sent = 0; |
|
/* Chain the socket objects together */ |
if (prev == NULL){ |
telnet->first = telnet; |
telnet->id = 0; |
} |
else { |
telnet->first = prev->first; |
telnet->id = prev->id + 1; |
prev->next = telnet; |
} |
telnet->next = NULL; |
|
return telnet; |
} |
|
|
|
void listen_telnet () |
{ |
telnet_t* telnet; |
int telnet_socket; |
|
/* Add a new socket to the end of the list */ |
if (first_telnet_g == NULL) { |
trace("first_telnet_g == NULL"); |
first_telnet_g = new_telnet(NULL); |
telnet = first_telnet_g; |
} |
else { |
telnet = first_telnet_g; |
for(;;){ |
if (telnet->next!=NULL) |
telnet=telnet->next; |
else |
break; |
} |
telnet = new_telnet(telnet); |
} |
|
/* Create a new socket and listen on it at port 23 */ |
telnet_socket = listen_socket(23, telnet->app); |
trace("telnet_socket = %d", telnet_socket); |
} |
|
|
|
void telnet_disconnect(app_t * app) |
{ |
telnet_t* telnet; |
trace("disconnect!"); |
telnet = (telnet_t*)(app->telnet); |
telnet->connection_state = TELNET_CLOSED; |
telnet->options_sent = 0; |
telnet->sent_opening_message = 0; |
telnet->echo_mode = 0; // reset this setting |
} |
|
|
|
void parse_telnet_options(char* buf, socket_t* socket) |
{ |
int i; |
int stage = 0; |
char stage1; |
telnet_t* telnet = (telnet_t*) socket->app->telnet; |
|
for (i=0;i<socket->rx_packet->tcp_payload_len;i++) { |
|
60,8 → 149,8
switch (buf[i]) { |
case 241: stage = 0; break; // NOP |
case 255: stage = 1; |
if (socket->telnet_connection_state == TELNET_CLOSED) { |
socket->telnet_connection_state = TELNET_OPEN; |
if (telnet->connection_state == TELNET_CLOSED) { |
telnet->connection_state = TELNET_OPEN; |
} |
break; // IAC |
|
87,10 → 176,10
case 1: // echo |
/* Client request that server echos stuff back to client */ |
if (stage1 == TELNET_DO) |
socket->telnet_echo_mode = 1; |
telnet->echo_mode = 1; |
/* Client request that server does not echo stuff back to client */ |
else if (stage1 == TELNET_DONT) |
socket->telnet_echo_mode = 0; |
telnet->echo_mode = 0; |
break; |
|
case 3: break; // suppress go ahead |
121,6 → 210,8
int i; |
int cr = 0; |
int windows = 0; |
telnet_t* telnet = (telnet_t*) socket->app->telnet; |
|
for (i=0;i<socket->rx_packet->telnet_payload_len;i++) { |
if (buf[i] == '\n') |
windows = 1; |
129,15 → 220,15
/* receive \r\n from Windows, \r from Linux */ |
if (buf[i] == '\r') { |
cr=1; |
put_byte(socket->telnet_rxbuf, buf[i], 1); /* last byte of line */ |
put_byte(telnet->rxbuf, buf[i], 1); /* last byte of line */ |
} |
else { |
put_byte(socket->telnet_rxbuf, buf[i], 0); /* not last byte of line */ |
put_byte(telnet->rxbuf, buf[i], 0); /* not last byte of line */ |
} |
} |
} |
|
if (socket->telnet_echo_mode) { |
if (telnet->echo_mode) { |
if (cr && !windows) { |
buf[socket->rx_packet->telnet_payload_len] = '\n'; |
socket->rx_packet->telnet_payload_len++; |
180,28 → 271,34
} |
|
|
|
/* Create a new telnet option, and a new socket to listen on */ |
|
void process_telnet(socket_t* socket) |
{ |
char* line; |
telnet_t* telnet = (telnet_t*) socket->app->telnet; |
|
if (!socket->telnet_options_sent){ |
if (!telnet->options_sent){ |
telnet_options(socket); |
socket->telnet_options_sent = 1; |
telnet->options_sent = 1; |
} |
|
else { |
/* Send telnet greeting */ |
if (!socket->telnet_sent_opening_message){ |
put_line (socket->telnet_txbuf, "Amber Processor Boot Loader\r\n> "); |
socket->telnet_sent_opening_message = 1; |
if (!telnet->sent_opening_message){ |
put_line (telnet->txbuf, "Amber Processor Boot Loader\r\n> "); |
telnet->sent_opening_message = 1; |
trace("telnet listen on new socket"); |
listen_telnet(); |
} |
|
/* Parse telnet rx buffer */ |
if (get_line(socket->telnet_rxbuf, &line)) |
parse_command (socket, line); |
if (get_line(telnet->rxbuf, &line)) |
parse_command (telnet, line); |
|
/* Transmit text from telnet tx buffer */ |
telnet_tx(socket, socket->telnet_txbuf); |
telnet_tx(socket, telnet->txbuf); |
} |
} |
|
209,7 → 306,7
|
/* Parse a command line passed from main and execute the command */ |
/* returns the length of the reply string */ |
int parse_command (socket_t* socket, char* line) |
int parse_command (telnet_t* telnet, char* line) |
{ |
unsigned int start_addr; |
unsigned int address; |
216,6 → 313,8
unsigned int range; |
int len, error = 0; |
|
socket_t* socket = (socket_t*) telnet->app->socket; |
|
/* All commands are just a single character. |
Just ignore anything else */ |
switch (line[0]) { |
223,6 → 322,7
case 'e': |
case 'x': |
case 'q': |
trace("set disconnect flag on socket"); |
socket->tcp_disconnect = 1; |
return 0; |
|
231,12 → 331,12
if (len = get_hex (&line[2], &start_addr)) { |
if (len = get_hex (&line[3+len], &range)) { |
for (address=start_addr; address<start_addr+range; address+=4) { |
put_line (socket->telnet_txbuf, "0x%08x 0x%08x\r\n", |
put_line (telnet->txbuf, "0x%08x 0x%08x\r\n", |
address, *(unsigned int *)address); |
} |
} |
else { |
put_line (socket->telnet_txbuf, "0x%08x 0x%08x\r\n", |
put_line (telnet->txbuf, "0x%08x 0x%08x\r\n", |
start_addr, *(unsigned int *)start_addr); |
} |
} |
247,32 → 347,33
|
|
case 'h': {/* Help */ |
put_line (socket->telnet_txbuf, "You need help alright\r\n"); |
put_line (telnet->txbuf, "You need help alright\r\n"); |
break; |
} |
|
|
case 's': {/* Status */ |
put_line (socket->telnet_txbuf, "Socket ID %d\r\n", socket->id); |
put_line (socket->telnet_txbuf, "Packets received %d\r\n", socket->packets_received); |
put_line (socket->telnet_txbuf, "Packets transmitted %d\r\n", socket->packets_sent); |
put_line (socket->telnet_txbuf, "Packets resent %d\r\n", socket->packets_resent); |
put_line (socket->telnet_txbuf, "TCP checksum errors %d\r\n", tcp_checksum_errors_g); |
put_line (telnet->txbuf, "Socket ID %d\r\n", socket->id); |
put_line (telnet->txbuf, "Packets received %d\r\n", socket->packets_received); |
put_line (telnet->txbuf, "Packets transmitted %d\r\n", socket->packets_sent); |
put_line (telnet->txbuf, "Packets resent %d\r\n", socket->packets_resent); |
put_line (telnet->txbuf, "TCP checksum errors %d\r\n", tcp_checksum_errors_g); |
|
put_line (socket->telnet_txbuf, "Counterparty IP %d.%d.%d.%d\r\n", |
put_line (telnet->txbuf, "Counterparty IP %d.%d.%d.%d\r\n", |
socket->rx_packet->src_ip[0], |
socket->rx_packet->src_ip[1], |
socket->rx_packet->src_ip[2], |
socket->rx_packet->src_ip[3]); |
|
put_line (socket->telnet_txbuf, "Counterparty Port %d\r\n", |
put_line (telnet->txbuf, "Counterparty Port %d\r\n", |
socket->rx_packet->tcp_src_port); |
|
put_line (socket->telnet_txbuf, "Malloc pointer 0x%08x\r\n", |
put_line (telnet->txbuf, "Malloc pointer 0x%08x\r\n", |
*(unsigned int *)(ADR_MALLOC_POINTER)); |
put_line (socket->telnet_txbuf, "Malloc count %d\r\n", |
put_line (telnet->txbuf, "Malloc count %d\r\n", |
*(unsigned int *)(ADR_MALLOC_COUNT)); |
put_line (socket->telnet_txbuf, "Uptime %d seconds\r\n", current_time_g->seconds); |
put_line (telnet->txbuf, "Uptime %d seconds\r\n", |
current_time_g->seconds); |
break; |
} |
|
284,9 → 385,10
|
|
if (error) |
put_line (socket->telnet_txbuf, "You're not making any sense\r\n", |
put_line (telnet->txbuf, "You're not making any sense\r\n", |
line[0], line[1], line[2]); |
|
put_line (socket->telnet_txbuf, "> "); |
put_line (telnet->txbuf, "> "); |
return 0; |
} |
|
/trunk/hw/fpga/bin/Makefile
75,25 → 75,25
# Build Configuration |
# ---------------------------------------------------- |
|
# AMBER_CLK_DIVIDER |
# Sets the system clock frequency |
# For Spartan-6 divide 800MHz by this number to get the frequency |
# e.g. AMBER_CLK_DIVIDER=24 |
# 800 MHz / 24 = 33.33 MHz |
# For Virtex-6 divide 1200MHz by this number to get the frequency |
|
# Select either the A23 or A25 core |
ifdef A25 |
AMBER_CORE = AMBER_A25_CORE |
AMBER_CORE_NAME = a25 |
else |
AMBER_CORE = AMBER_A23_CORE |
AMBER_CORE_NAME = a23 |
endif |
|
|
# AMBER_CLK_DIVIDER |
# Sets the system clock frequency |
# Divide 800MHz by this number to get the frequency |
# e.g. AMBER_CLK_DIVIDER=24 |
# 800 MHz / 24 = 33.33 MHz |
|
# The spartan6 device used on SP605 Development board |
XILINX_FPGA = xc6slx45tfgg484-3 |
XST_DEFINES = XILINX_FPGA XILINX_SPARTAN6_FPGA $(AMBER_CORE) AMBER_CLK_DIVIDER=21 $(BOOT_LOADER_DEF) |
XST_DEFINES = XILINX_FPGA XILINX_SPARTAN6_FPGA $(AMBER_CORE) AMBER_CLK_DIVIDER=18 $(BOOT_LOADER_DEF) |
# Xilinx placement and timing constraints |
XST_CONST_FILE = xs6_constraints.ucf |
# List of verilog source files for Xilinx Spartan-6 device |
214,8 → 214,8
\ |
cd $(WORK_FOLDER); \ |
bitgen -intstyle xflow -f $(BIN_FOLDER)/bitfile_config.ut $(RTL_TOP).ncd |
cp $(WORK_FOLDER)/$(RTL_TOP).bit $(BITFILE_FOLDER)/$(RTL_TOP).$(RUN_ID).bit |
mv $(WORK_FOLDER)/$(RTL_TOP).bgn $(LOG_FOLDER)/$(RTL_TOP).bit.$(RUN_ID).bgn |
cp $(WORK_FOLDER)/$(RTL_TOP).bit $(BITFILE_FOLDER)/$(RTL_TOP).$(AMBER_CORE_NAME).$(RUN_ID).bit |
mv $(WORK_FOLDER)/$(RTL_TOP).bgn $(LOG_FOLDER)/$(RTL_TOP).$(AMBER_CORE_NAME).$(RUN_ID).bgn |
|
|
# ---------------------------------------------------- |