Rebased on latest IP65. Needs latest CC65 to build.
This commit is contained in:
parent
d8d532fd72
commit
95615458aa
|
@ -89,7 +89,7 @@ struct datetime {
|
||||||
|
|
||||||
static char filename[80];
|
static char filename[80];
|
||||||
static char userentry[80];
|
static char userentry[80];
|
||||||
static char linebuf[LINEBUFSZ];
|
static uint8_t linebuf[LINEBUFSZ];
|
||||||
static FILE *fp;
|
static FILE *fp;
|
||||||
static struct emailhdrs *headers;
|
static struct emailhdrs *headers;
|
||||||
static uint16_t selection = 1;
|
static uint16_t selection = 1;
|
||||||
|
@ -1796,7 +1796,7 @@ char prompt_okay(char *msg) {
|
||||||
*/
|
*/
|
||||||
void get_email_body(struct emailhdrs *h, FILE *f, char mode) {
|
void get_email_body(struct emailhdrs *h, FILE *f, char mode) {
|
||||||
uint16_t chars;
|
uint16_t chars;
|
||||||
char c, *readp, *writep;
|
uint8_t c, *readp, *writep;
|
||||||
uint32_t pos = 0;
|
uint32_t pos = 0;
|
||||||
const int8_t *b = b64dec - 43;
|
const int8_t *b = b64dec - 43;
|
||||||
uint8_t mime = 0, mime_enc = ENC_7BIT, mime_binary, mime_hasfile;
|
uint8_t mime = 0, mime_enc = ENC_7BIT, mime_binary, mime_hasfile;
|
||||||
|
|
|
@ -42,7 +42,7 @@ void send(unsigned char flags, const char* str, ...)
|
||||||
}
|
}
|
||||||
|
|
||||||
va_start(args, str);
|
va_start(args, str);
|
||||||
send_size += vsnprintf(send_buffer + send_size, sizeof(send_buffer) - send_size, str, args);
|
send_size += vsnprintf((char*)send_buffer + send_size, sizeof(send_buffer) - send_size, str, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
if (flags & SEND_LAST || sizeof(send_buffer) - send_size < 1024 / 4)
|
if (flags & SEND_LAST || sizeof(send_buffer) - send_size < 1024 / 4)
|
||||||
|
@ -309,9 +309,9 @@ int main(void)
|
||||||
{
|
{
|
||||||
read(file, ð_init, 1);
|
read(file, ð_init, 1);
|
||||||
close(file);
|
close(file);
|
||||||
eth_init &= ~'0';
|
eth_init &= 7;
|
||||||
}
|
}
|
||||||
printf("- %d", eth_init);
|
printf("- %u", eth_init);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@ int ifttt_trigger(const char* key, const char* event,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
len = url_download(url, download, sizeof(download));
|
len = url_download(url, (uint8_t*)download, sizeof(download));
|
||||||
|
|
||||||
if (len < 12)
|
if (len < 12)
|
||||||
{
|
{
|
||||||
|
|
|
@ -78,15 +78,15 @@ struct linenoiseState {
|
||||||
int history_index; /* The history index we are currently editing. */
|
int history_index; /* The history index we are currently editing. */
|
||||||
};
|
};
|
||||||
|
|
||||||
enum KEY_ACTION{
|
enum KEY_ACTION {
|
||||||
CTRL_A = 1, /* Ctrl+a */
|
CTRL_A = 1, /* Ctrl+a */
|
||||||
CTRL_B = 2, /* Ctrl-b */
|
CTRL_B = 2, /* Ctrl-b */
|
||||||
CTRL_C = 3, /* Ctrl-c */
|
CTRL_C = 3, /* Ctrl-c */
|
||||||
CTRL_D = 4, /* Ctrl-d */
|
CTRL_D = 4, /* Ctrl-d */
|
||||||
CTRL_E = 5, /* Ctrl-e */
|
CTRL_E = 5, /* Ctrl-e */
|
||||||
CTRL_F = 6, /* Ctrl-f */
|
CTRL_F = 6, /* Ctrl-f */
|
||||||
CTRL_N = 14, /* Ctrl-n */
|
CTRL_N = 14, /* Ctrl-n */
|
||||||
CTRL_P = 16 /* Ctrl-p */
|
CTRL_P = 16 /* Ctrl-p */
|
||||||
};
|
};
|
||||||
|
|
||||||
static void refreshLine(struct linenoiseState *l);
|
static void refreshLine(struct linenoiseState *l);
|
||||||
|
@ -102,14 +102,16 @@ static int getColumns() {
|
||||||
return cols;
|
return cols;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __APPLE2__
|
|
||||||
#pragma code-name (push, "LC")
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Beep, used for completion when there is nothing to complete or when all
|
/* Beep, used for completion when there is nothing to complete or when all
|
||||||
* the choices were already shown. */
|
* the choices were already shown. */
|
||||||
static void linenoiseBeep(void) {
|
static void linenoiseBeep(void) {
|
||||||
|
#ifdef __APPLE2__
|
||||||
|
unsigned char x = wherex();
|
||||||
|
#endif
|
||||||
putchar('\a');
|
putchar('\a');
|
||||||
|
#ifdef __APPLE2__
|
||||||
|
gotox(x);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ============================== Completion ================================ */
|
/* ============================== Completion ================================ */
|
||||||
|
@ -123,6 +125,10 @@ static void freeCompletions(linenoiseCompletions *lc) {
|
||||||
free(lc->cvec);
|
free(lc->cvec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __APPLE2__
|
||||||
|
#pragma code-name (push, "LC")
|
||||||
|
#endif
|
||||||
|
|
||||||
/* This is an helper function for linenoiseEdit() and is called when the
|
/* This is an helper function for linenoiseEdit() and is called when the
|
||||||
* user types the <tab> key in order to complete the string currently in the
|
* user types the <tab> key in order to complete the string currently in the
|
||||||
* input.
|
* input.
|
||||||
|
|
|
@ -637,11 +637,12 @@ void main(int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy IP config from IP65 to W5100
|
// Copy IP config from IP65 to W5100
|
||||||
w5100_config(eth_init);
|
w5100_init(eth_init);
|
||||||
|
w5100_config();
|
||||||
|
|
||||||
printf("Ok\nConnecting to %s (%u) - ", cfg_server, nntp_port);
|
printf("Ok\nConnecting to %s (%u) - ", cfg_server, nntp_port);
|
||||||
|
|
||||||
if (!w5100_connect(parse_dotted_quad(cfg_server), nntp_port)) {
|
if (!w5100_connect_addr(parse_dotted_quad(cfg_server), nntp_port)) {
|
||||||
printf("Fail\n");
|
printf("Fail\n");
|
||||||
error_exit();
|
error_exit();
|
||||||
}
|
}
|
||||||
|
|
|
@ -548,7 +548,8 @@ void main(int argc, char *argv[]) {
|
||||||
printf("Ok\n");
|
printf("Ok\n");
|
||||||
|
|
||||||
// Copy IP config from IP65 to W5100
|
// Copy IP config from IP65 to W5100
|
||||||
w5100_config(eth_init);
|
w5100_init(eth_init);
|
||||||
|
w5100_config();
|
||||||
|
|
||||||
sprintf(filename, "%s/NEWS.OUTBOX", cfg_emaildir);
|
sprintf(filename, "%s/NEWS.OUTBOX", cfg_emaildir);
|
||||||
dp = opendir(filename);
|
dp = opendir(filename);
|
||||||
|
@ -632,7 +633,7 @@ sendmessage:
|
||||||
if (!connected) {
|
if (!connected) {
|
||||||
printf("\nConnecting to %s (%u) - ", cfg_server, nntp_port);
|
printf("\nConnecting to %s (%u) - ", cfg_server, nntp_port);
|
||||||
|
|
||||||
if (!w5100_connect(parse_dotted_quad(cfg_server), nntp_port)) {
|
if (!w5100_connect_addr(parse_dotted_quad(cfg_server), nntp_port)) {
|
||||||
printf("Fail\n");
|
printf("Fail\n");
|
||||||
error_exit();
|
error_exit();
|
||||||
}
|
}
|
||||||
|
|
|
@ -534,17 +534,19 @@ void main(int argc, char *argv[]) {
|
||||||
// Abort on Ctrl-C to be consistent with Linenoise
|
// Abort on Ctrl-C to be consistent with Linenoise
|
||||||
abort_key = 0x83;
|
abort_key = 0x83;
|
||||||
|
|
||||||
|
w5100_init(eth_init);
|
||||||
|
|
||||||
printf("Ok\nObtaining IP address - ");
|
printf("Ok\nObtaining IP address - ");
|
||||||
if (dhcp_init()) {
|
if (dhcp_init()) {
|
||||||
ip65_error_exit();
|
ip65_error_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy IP config from IP65 to W5100
|
// Copy IP config from IP65 to W5100
|
||||||
w5100_config(eth_init);
|
w5100_config();
|
||||||
|
|
||||||
printf("Ok\nConnecting to %s - ", cfg_server);
|
printf("Ok\nConnecting to %s - ", cfg_server);
|
||||||
|
|
||||||
if (!w5100_connect(parse_dotted_quad(cfg_server), pop_port)) {
|
if (!w5100_connect_addr(parse_dotted_quad(cfg_server), pop_port)) {
|
||||||
printf("Fail\n");
|
printf("Fail\n");
|
||||||
error_exit();
|
error_exit();
|
||||||
}
|
}
|
||||||
|
|
|
@ -280,7 +280,8 @@ void main(int argc, char *argv[]) {
|
||||||
printf("Ok\n");
|
printf("Ok\n");
|
||||||
|
|
||||||
// Copy IP config from IP65 to W5100
|
// Copy IP config from IP65 to W5100
|
||||||
w5100_config(eth_init);
|
w5100_init(eth_init);
|
||||||
|
w5100_config();
|
||||||
|
|
||||||
fp = fopen(filename, "rb");
|
fp = fopen(filename, "rb");
|
||||||
if (!fp) {
|
if (!fp) {
|
||||||
|
@ -291,7 +292,7 @@ void main(int argc, char *argv[]) {
|
||||||
if (!connected) {
|
if (!connected) {
|
||||||
printf("\nConnecting to %s:%d - ", cfg_server, jetdirect_port);
|
printf("\nConnecting to %s:%d - ", cfg_server, jetdirect_port);
|
||||||
|
|
||||||
if (!w5100_connect(parse_dotted_quad(cfg_server), jetdirect_port)) {
|
if (!w5100_connect_addr(parse_dotted_quad(cfg_server), jetdirect_port)) {
|
||||||
printf("Fail\n");
|
printf("Fail\n");
|
||||||
error_exit();
|
error_exit();
|
||||||
}
|
}
|
||||||
|
|
|
@ -547,7 +547,8 @@ void main(int argc, char *argv[]) {
|
||||||
printf("Ok\n");
|
printf("Ok\n");
|
||||||
|
|
||||||
// Copy IP config from IP65 to W5100
|
// Copy IP config from IP65 to W5100
|
||||||
w5100_config(eth_init);
|
w5100_init(eth_init);
|
||||||
|
w5100_config();
|
||||||
|
|
||||||
sprintf(filename, "%s/OUTBOX", cfg_emaildir);
|
sprintf(filename, "%s/OUTBOX", cfg_emaildir);
|
||||||
dp = opendir(filename);
|
dp = opendir(filename);
|
||||||
|
@ -644,7 +645,7 @@ sendmessage:
|
||||||
if (!connected) {
|
if (!connected) {
|
||||||
printf("\nConnecting to %s - ", cfg_smtp_server);
|
printf("\nConnecting to %s - ", cfg_smtp_server);
|
||||||
|
|
||||||
if (!w5100_connect(parse_dotted_quad(cfg_smtp_server), smtp_port)) {
|
if (!w5100_connect_addr(parse_dotted_quad(cfg_smtp_server), smtp_port)) {
|
||||||
printf("Fail\n");
|
printf("Fail\n");
|
||||||
error_exit();
|
error_exit();
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,9 +152,9 @@ int main(void)
|
||||||
{
|
{
|
||||||
read(file, ð_init, 1);
|
read(file, ð_init, 1);
|
||||||
close(file);
|
close(file);
|
||||||
eth_init &= ~'0';
|
eth_init &= 7;
|
||||||
}
|
}
|
||||||
printf("- %d\n", eth_init);
|
printf("- %u\n", eth_init);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
96
apps/w5100.c
96
apps/w5100.c
|
@ -65,12 +65,8 @@ static uint16_t addr_mask [2];
|
||||||
|
|
||||||
static void set_addr(uint16_t addr)
|
static void set_addr(uint16_t addr)
|
||||||
{
|
{
|
||||||
// The variables are necessary to have cc65 generate code
|
*w5100_addr_hi = addr >> 8;
|
||||||
// suitable to access the W5100 auto-increment registers.
|
*w5100_addr_lo = addr;
|
||||||
uint8_t addr_hi = addr >> 8;
|
|
||||||
uint8_t addr_lo = addr;
|
|
||||||
*w5100_addr_hi = addr_hi;
|
|
||||||
*w5100_addr_lo = addr_lo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t get_byte(uint16_t addr)
|
static uint8_t get_byte(uint16_t addr)
|
||||||
|
@ -91,54 +87,44 @@ static uint16_t get_word(uint16_t addr)
|
||||||
{
|
{
|
||||||
set_addr(addr);
|
set_addr(addr);
|
||||||
|
|
||||||
{
|
return *w5100_data << 8 | *w5100_data;
|
||||||
// The variables are necessary to have cc65 generate code
|
|
||||||
// suitable to access the W5100 auto-increment registers.
|
|
||||||
uint8_t data_hi = *w5100_data;
|
|
||||||
uint8_t data_lo = *w5100_data;
|
|
||||||
return data_hi << 8 | data_lo;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_word(uint16_t addr, uint16_t data)
|
static void set_word(uint16_t addr, uint16_t data)
|
||||||
{
|
{
|
||||||
set_addr(addr);
|
set_addr(addr);
|
||||||
|
|
||||||
{
|
*w5100_data = data >> 8;
|
||||||
// The variables are necessary to have cc65 generate code
|
*w5100_data = data;
|
||||||
// suitable to access the W5100 auto-increment registers.
|
|
||||||
uint8_t data_hi = data >> 8;
|
|
||||||
uint8_t data_lo = data;
|
|
||||||
*w5100_data = data_hi;
|
|
||||||
*w5100_data = data_lo;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_quad(uint16_t addr, uint32_t data)
|
static void set_quad(uint16_t addr, uint32_t data)
|
||||||
{
|
{
|
||||||
set_addr(addr);
|
set_addr(addr);
|
||||||
|
|
||||||
{
|
*w5100_data = data;
|
||||||
// The variables are necessary to have cc65 generate code
|
*w5100_data = data >> 8;
|
||||||
// suitable to access the W5100 auto-increment registers.
|
*w5100_data = data >> 16;
|
||||||
uint8_t data_1 = data;
|
*w5100_data = data >> 24;
|
||||||
uint8_t data_2 = data >> 8;
|
|
||||||
uint8_t data_3 = data >> 16;
|
|
||||||
uint8_t data_4 = data >> 24;
|
|
||||||
*w5100_data = data_1;
|
|
||||||
*w5100_data = data_2;
|
|
||||||
*w5100_data = data_3;
|
|
||||||
*w5100_data = data_4;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void w5100_config(uint8_t eth_init)
|
bool w5100_init(uint8_t eth_init)
|
||||||
{
|
{
|
||||||
w5100_mode = (uint8_t*)(eth_init << 4 | 0xC084);
|
w5100_mode = (uint8_t*)(eth_init << 4 | 0xC084);
|
||||||
w5100_addr_hi = w5100_mode + 1;
|
w5100_addr_hi = w5100_mode + 1;
|
||||||
w5100_addr_lo = w5100_mode + 2;
|
w5100_addr_lo = w5100_mode + 2;
|
||||||
w5100_data = w5100_mode + 3;
|
w5100_data = w5100_mode + 3;
|
||||||
|
|
||||||
|
// PPP Link Control Protocol Request Timer Register defaults to 0x28
|
||||||
|
// on a real W5100. However, AppleWin features a virtual W5100 that
|
||||||
|
// supports DNS offloading. On that virtual W5100, the (otherwise
|
||||||
|
// anyhow unused) register defaults to 0x00 as detection mechanism.
|
||||||
|
// https://github.com/a2retrosystems/uthernet2/wiki/Virtual-W5100-with-DNS
|
||||||
|
return get_byte(0x0028) == 0x00;
|
||||||
|
}
|
||||||
|
|
||||||
|
void w5100_config(void)
|
||||||
|
{
|
||||||
#ifdef SINGLE_SOCKET
|
#ifdef SINGLE_SOCKET
|
||||||
|
|
||||||
// IP65 is inhibited so disable the W5100 Ping Block Mode.
|
// IP65 is inhibited so disable the W5100 Ping Block Mode.
|
||||||
|
@ -193,14 +179,14 @@ void w5100_config(uint8_t eth_init)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool w5100_connect(uint32_t addr, uint16_t port)
|
static bool w5100_connect(uint16_t port)
|
||||||
{
|
{
|
||||||
// Socket x Mode Register: TCP
|
|
||||||
set_byte(SOCK_REG(0x00), 0x01);
|
|
||||||
|
|
||||||
// Socket x Source Port Register
|
// Socket x Source Port Register
|
||||||
set_word(SOCK_REG(0x04), ip65_random_word());
|
set_word(SOCK_REG(0x04), ip65_random_word());
|
||||||
|
|
||||||
|
// Socket x Destination Port Register
|
||||||
|
set_word(SOCK_REG(0x10), port);
|
||||||
|
|
||||||
// Socket x Command Register: OPEN
|
// Socket x Command Register: OPEN
|
||||||
set_byte(SOCK_REG(0x01), 0x01);
|
set_byte(SOCK_REG(0x01), 0x01);
|
||||||
|
|
||||||
|
@ -213,12 +199,6 @@ bool w5100_connect(uint32_t addr, uint16_t port)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Socket x Destination IP Address Register
|
|
||||||
set_quad(SOCK_REG(0x0C), addr);
|
|
||||||
|
|
||||||
// Socket x Destination Port Register
|
|
||||||
set_word(SOCK_REG(0x10), port);
|
|
||||||
|
|
||||||
// Socket x Command Register: CONNECT
|
// Socket x Command Register: CONNECT
|
||||||
set_byte(SOCK_REG(0x01), 0x04);
|
set_byte(SOCK_REG(0x01), 0x04);
|
||||||
|
|
||||||
|
@ -238,6 +218,34 @@ bool w5100_connect(uint32_t addr, uint16_t port)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool w5100_connect_addr(uint32_t addr, uint16_t port)
|
||||||
|
{
|
||||||
|
// Socket x Mode Register: TCP, Use No Delayed ACK
|
||||||
|
set_byte(SOCK_REG(0x00), 0x21);
|
||||||
|
|
||||||
|
// Socket x Destination IP Address Register
|
||||||
|
set_quad(SOCK_REG(0x0C), addr);
|
||||||
|
|
||||||
|
return w5100_connect(port);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool w5100_connect_name(const char* name, uint8_t length, uint16_t port)
|
||||||
|
{
|
||||||
|
// Socket x Mode Register: TCP, Use No Delayed ACK, Use DNS Offloading
|
||||||
|
set_byte(SOCK_REG(0x00), 0x29);
|
||||||
|
|
||||||
|
// Socket x DNS name length
|
||||||
|
set_byte(SOCK_REG(0x2A), length);
|
||||||
|
|
||||||
|
// Socket x DNS name chars
|
||||||
|
while (length--)
|
||||||
|
{
|
||||||
|
*w5100_data = *name++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return w5100_connect(port);
|
||||||
|
}
|
||||||
|
|
||||||
bool w5100_connected(void)
|
bool w5100_connected(void)
|
||||||
{
|
{
|
||||||
// Socket x Status Register: SOCK_ESTABLISHED ?
|
// Socket x Status Register: SOCK_ESTABLISHED ?
|
||||||
|
|
16
apps/w5100.h
16
apps/w5100.h
|
@ -46,13 +46,23 @@ void w5100_data_commit(bool do_send, uint16_t size);
|
||||||
// to be sent to the server.
|
// to be sent to the server.
|
||||||
extern volatile uint8_t* w5100_data;
|
extern volatile uint8_t* w5100_data;
|
||||||
|
|
||||||
|
// Initialize this module after the IP65 TCP/IP stack has been initialized.
|
||||||
|
// Return true if the (virtual) W5100 supports DNS Offloading.
|
||||||
|
// https://github.com/a2retrosystems/uthernet2/wiki/Virtual-W5100-with-DNS
|
||||||
|
bool w5100_init(uint8_t eth_init);
|
||||||
|
|
||||||
// Configure W5100 Ethernet controller with additional information from IP65
|
// Configure W5100 Ethernet controller with additional information from IP65
|
||||||
// after the IP65 TCP/IP stack has been configured.
|
// after the IP65 TCP/IP stack has been configured.
|
||||||
void w5100_config(uint8_t eth_init);
|
void w5100_config(void);
|
||||||
|
|
||||||
// Connect to server with IP address <server_addr> on TCP port <server_port>.
|
// Connect to server with IP address <addr> on TCP port <port>.
|
||||||
// Return true if the connection is established, return false otherwise.
|
// Return true if the connection is established, return false otherwise.
|
||||||
bool w5100_connect(uint32_t addr, uint16_t port);
|
bool w5100_connect_addr(uint32_t addr, uint16_t port);
|
||||||
|
|
||||||
|
// Connect to server with name <name>, <length> on TCP port <port> using
|
||||||
|
// DNS Offloading.
|
||||||
|
// Return true if the connection is established, return false otherwise.
|
||||||
|
bool w5100_connect_name(const char* name, uint8_t length, uint16_t port);
|
||||||
|
|
||||||
// Check if still connected to server.
|
// Check if still connected to server.
|
||||||
// Return true if the connection is established, return false otherwise.
|
// Return true if the connection is established, return false otherwise.
|
||||||
|
|
|
@ -39,16 +39,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#pragma optimize (on)
|
#pragma optimize (on)
|
||||||
#pragma static-locals (on)
|
#pragma static-locals (on)
|
||||||
|
|
||||||
bool w5100_http_open(uint32_t addr, uint16_t port, const char* selector,
|
static bool w5100_http_open(const char* selector, char* buffer, size_t length)
|
||||||
char* buffer, size_t length)
|
|
||||||
{
|
{
|
||||||
printf("Connecting to %s:%d ", dotted_quad(addr), port);
|
register volatile uint8_t *data = w5100_data;
|
||||||
|
|
||||||
if (!w5100_connect(addr, port))
|
|
||||||
{
|
|
||||||
printf("- Connect failed\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("- Ok\n\nSending request ");
|
printf("- Ok\n\nSending request ");
|
||||||
{
|
{
|
||||||
|
@ -82,15 +75,11 @@ bool w5100_http_open(uint32_t addr, uint16_t port, const char* selector,
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// One less to allow for faster pre-increment below
|
const char *dataptr = selector + pos;
|
||||||
const char *dataptr = selector + pos - 1;
|
|
||||||
uint16_t i;
|
uint16_t i;
|
||||||
for (i = 0; i < snd; ++i)
|
for (i = 0; i < snd; ++i)
|
||||||
{
|
{
|
||||||
// The variable is necessary to have cc65 generate code
|
*data = *dataptr++;
|
||||||
// suitable to access the W5100 auto-increment register.
|
|
||||||
char data = *++dataptr;
|
|
||||||
*w5100_data = data;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,17 +121,13 @@ bool w5100_http_open(uint32_t addr, uint16_t port, const char* selector,
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// One less to allow for faster pre-increment below
|
char *dataptr = buffer + len;
|
||||||
char *dataptr = buffer + len - 1;
|
|
||||||
uint16_t i;
|
uint16_t i;
|
||||||
for (i = 0; i < rcv; ++i)
|
for (i = 0; i < rcv; ++i)
|
||||||
{
|
{
|
||||||
// The variable is necessary to have cc65 generate code
|
*dataptr++ = *data;
|
||||||
// suitable to access the W5100 auto-increment register.
|
|
||||||
char data = *w5100_data;
|
|
||||||
*++dataptr = data;
|
|
||||||
|
|
||||||
if (!memcmp(dataptr - 3, "\r\n\r\n", 4))
|
if (!memcmp(dataptr - 4, "\r\n\r\n", 4))
|
||||||
{
|
{
|
||||||
rcv = i + 1;
|
rcv = i + 1;
|
||||||
body = true;
|
body = true;
|
||||||
|
@ -183,3 +168,31 @@ bool w5100_http_open(uint32_t addr, uint16_t port, const char* selector,
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool w5100_http_open_addr(uint32_t addr, uint16_t port, const char* selector,
|
||||||
|
char* buffer, size_t length)
|
||||||
|
{
|
||||||
|
printf("Connecting to %s:%d ", dotted_quad(addr), port);
|
||||||
|
|
||||||
|
if (!w5100_connect_addr(addr, port))
|
||||||
|
{
|
||||||
|
printf("- Connect failed\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return w5100_http_open(selector, buffer, length);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool w5100_http_open_name(const char* name, uint8_t name_length, uint16_t port,
|
||||||
|
const char* selector, char* buffer, size_t buffer_length)
|
||||||
|
{
|
||||||
|
printf("Connecting to port %d ", port);
|
||||||
|
|
||||||
|
if (!w5100_connect_name(name, name_length, port))
|
||||||
|
{
|
||||||
|
printf("- Connect failed\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return w5100_http_open(selector, buffer, buffer_length);
|
||||||
|
}
|
||||||
|
|
|
@ -37,12 +37,20 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
// Connect to server with IP address <server_addr> on TCP port <server_port>,
|
// Connect to server with IP address <addr> on TCP port <port>, then HTTP GET
|
||||||
// then HTTP GET <selector> and consume HTTP response header. Provide feedback
|
// <selector> and consume HTTP response header. Provide feedback on progress
|
||||||
// on progress to the user via STDOUT. After returning from w5100_http_open()
|
// to the user via STDOUT. After returning from w5100_http_open_addr(), the
|
||||||
// the connection is ready to consume the HTTP body.
|
// connection is ready to consume the HTTP body.
|
||||||
// Return true if the connection is established, return false otherwise.
|
// Return true if the connection is established, return false otherwise.
|
||||||
bool w5100_http_open(uint32_t addr, uint16_t port, const char* selector,
|
bool w5100_http_open_addr(uint32_t addr, uint16_t port, const char* selector,
|
||||||
char* buffer, size_t length);
|
char* buffer, size_t length);
|
||||||
|
|
||||||
|
// Connect to server with name <name>, <name_length> on TCP port <port> using
|
||||||
|
// DNS Offloading, then HTTP GET <selector> and consume HTTP response header.
|
||||||
|
// Provide feedback on progress to the user via STDOUT. After returning from
|
||||||
|
// w5100_http_open_name(), the connection is ready to consume the HTTP body.
|
||||||
|
// Return true if the connection is established, return false otherwise.
|
||||||
|
bool w5100_http_open_name(const char* name, uint8_t name_length, uint16_t port,
|
||||||
|
const char* selector, char* buffer, size_t buffer_length);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -241,6 +241,7 @@ void exit_on_key(void)
|
||||||
|
|
||||||
void write_file(const char *name)
|
void write_file(const char *name)
|
||||||
{
|
{
|
||||||
|
register volatile uint8_t *data = w5100_data;
|
||||||
uint16_t i;
|
uint16_t i;
|
||||||
int file;
|
int file;
|
||||||
uint16_t rcv;
|
uint16_t rcv;
|
||||||
|
@ -277,14 +278,10 @@ void write_file(const char *name)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// One less to allow for faster pre-increment below
|
char *dataptr = buffer + len;
|
||||||
char *dataptr = buffer + len - 1;
|
|
||||||
for (i = 0; i < rcv; ++i)
|
for (i = 0; i < rcv; ++i)
|
||||||
{
|
{
|
||||||
// The variable is necessary to have cc65 generate code
|
*dataptr++ = *data;
|
||||||
// suitable to access the W5100 auto-increment register.
|
|
||||||
char data = *w5100_data;
|
|
||||||
*++dataptr = data;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,6 +315,7 @@ void write_file(const char *name)
|
||||||
|
|
||||||
void write_device(char device)
|
void write_device(char device)
|
||||||
{
|
{
|
||||||
|
register volatile uint8_t *data = w5100_data;
|
||||||
uint16_t i;
|
uint16_t i;
|
||||||
dhandle_t dio;
|
dhandle_t dio;
|
||||||
uint16_t rcv;
|
uint16_t rcv;
|
||||||
|
@ -383,8 +381,7 @@ void write_device(char device)
|
||||||
rcv = sizeof(buffer) - len;
|
rcv = sizeof(buffer) - len;
|
||||||
}
|
}
|
||||||
|
|
||||||
// One less to allow for faster pre-increment below
|
dataptr = buffer + len;
|
||||||
dataptr = buffer + len - 1;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -394,16 +391,12 @@ void write_device(char device)
|
||||||
rcv = 0x100 - len % 0x100;
|
rcv = 0x100 - len % 0x100;
|
||||||
}
|
}
|
||||||
|
|
||||||
// One less to allow for faster pre-increment below
|
dataptr = buffer + (skew[len / 0x100] << 8 | len % 0x100);
|
||||||
dataptr = buffer + (skew[len / 0x100] << 8 | len % 0x100) - 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < rcv; ++i)
|
for (i = 0; i < rcv; ++i)
|
||||||
{
|
{
|
||||||
// The variable is necessary to have cc65 generate code
|
*dataptr++ = *data;
|
||||||
// suitable to access the W5100 auto-increment register.
|
|
||||||
char data = *w5100_data;
|
|
||||||
*++dataptr = data;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -442,6 +435,7 @@ int main(int, char *argv[])
|
||||||
uint16_t i;
|
uint16_t i;
|
||||||
char *arg;
|
char *arg;
|
||||||
char device;
|
char device;
|
||||||
|
bool Offload_DNS;
|
||||||
uint8_t eth_init = ETH_INIT_DEFAULT;
|
uint8_t eth_init = ETH_INIT_DEFAULT;
|
||||||
|
|
||||||
if (doesclrscrafterexit())
|
if (doesclrscrafterexit())
|
||||||
|
@ -475,11 +469,11 @@ int main(int, char *argv[])
|
||||||
{
|
{
|
||||||
read(file, ð_init, 1);
|
read(file, ð_init, 1);
|
||||||
close(file);
|
close(file);
|
||||||
eth_init &= ~'0';
|
eth_init &= 7;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("- %d\n\nInitializing %s ", eth_init, eth_name);
|
printf("- %u\n\nInitializing %s ", eth_init, eth_name);
|
||||||
if (ip65_init(eth_init))
|
if (ip65_init(eth_init))
|
||||||
{
|
{
|
||||||
ip65_error_exit();
|
ip65_error_exit();
|
||||||
|
@ -488,15 +482,20 @@ int main(int, char *argv[])
|
||||||
// Abort on Ctrl-C to be consistent with Linenoise
|
// Abort on Ctrl-C to be consistent with Linenoise
|
||||||
abort_key = 0x83;
|
abort_key = 0x83;
|
||||||
|
|
||||||
printf("- Ok\n\nObtaining IP address ");
|
Offload_DNS = w5100_init(eth_init);
|
||||||
if (dhcp_init())
|
|
||||||
|
if (!Offload_DNS)
|
||||||
{
|
{
|
||||||
ip65_error_exit();
|
printf("- Ok\n\nObtaining IP address ");
|
||||||
|
if (dhcp_init())
|
||||||
|
{
|
||||||
|
ip65_error_exit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
printf("- Ok\n\n");
|
printf("- Ok\n\n");
|
||||||
|
|
||||||
// Copy IP config from IP65 to W5100
|
// Copy IP config from IP65 to W5100
|
||||||
w5100_config(eth_init);
|
w5100_config();
|
||||||
|
|
||||||
load_argument("wget.urls");
|
load_argument("wget.urls");
|
||||||
while (true)
|
while (true)
|
||||||
|
@ -504,7 +503,7 @@ int main(int, char *argv[])
|
||||||
arg = get_argument(1, "URL", url_completion);
|
arg = get_argument(1, "URL", url_completion);
|
||||||
|
|
||||||
printf("\n\nProcessing URL ");
|
printf("\n\nProcessing URL ");
|
||||||
if (!url_parse(arg))
|
if (!url_parse(arg, !Offload_DNS))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -657,9 +656,21 @@ int main(int, char *argv[])
|
||||||
save_argument("wget.files");
|
save_argument("wget.files");
|
||||||
|
|
||||||
printf("\n\n");
|
printf("\n\n");
|
||||||
if (!w5100_http_open(url_ip, url_port, url_selector, buffer, sizeof(buffer)))
|
if (Offload_DNS)
|
||||||
{
|
{
|
||||||
return EXIT_FAILURE;
|
if (!w5100_http_open_name(url_host, strlen(url_host) - 4, url_port,
|
||||||
|
url_selector, buffer, sizeof(buffer)))
|
||||||
|
{
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!w5100_http_open_addr(url_ip, url_port,
|
||||||
|
url_selector, buffer, sizeof(buffer)))
|
||||||
|
{
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (device)
|
if (device)
|
||||||
|
|
|
@ -1,23 +1,21 @@
|
||||||
# For assembler programs
|
# For assembler programs
|
||||||
# ----------------------
|
# ----------------------
|
||||||
# c64rrnet.lib : C64 with RR-Net (or clone)
|
# c64rrnet.lib : C64 with RR-Net (or clone)
|
||||||
# c64eth64.lib : C64 with ETH64
|
# c64eth64.lib : C64 with ETH64
|
||||||
# c64combo.lib : C64 with RR-Net or ETH64
|
# c64combo.lib : C64 with RR-Net or ETH64
|
||||||
# a2uther.lib : Apple ][ with Uthernet (default slot: #3)
|
# a2uther.lib : Apple ][ with Uthernet (default slot: #3)
|
||||||
# a2lancegs.lib : Apple ][ with LANceGS (default slot: #3)
|
# a2uther2.lib : Apple ][ with Uthernet II (default slot: #3)
|
||||||
# a2uther2.lib : Apple ][ with Uthernet II (default slot: #3)
|
# a2lancegs.lib : Apple ][ with LANceGS (default slot: #3)
|
||||||
# a2combo.lib : Apple ][ with Uthernet or LANceGS or Uthernet II (default slot: #3)
|
# a2combo.lib : Apple ][ with Uthernet or Uthernet II or LANceGS (default slot: #3)
|
||||||
# atrdragon.lib : ATARI 8-bit with Dragon Cart
|
# atrdragon.lib : ATARI 8-bit with Dragon Cart
|
||||||
# atrdracarys.lib : ATARI 8-bit with Dracarys (default PBI device ID: #8)
|
# vic20rrnet.lib : VIC20 with RR-Net (or clone)
|
||||||
# atrcombo.lib : ATARI 8-bit with Dragon Cart or Dracarys (default PBI device ID: #8)
|
|
||||||
# vic20rrnet.lib : VIC20 with RR-Net (or clone)
|
|
||||||
|
|
||||||
# For C programs
|
# For C programs
|
||||||
# --------------
|
# --------------
|
||||||
# ip65_c64.lib : C64 with RR-Net or ETH64
|
# ip65_c64.lib : C64 with RR-Net or ETH64
|
||||||
# ip65_apple2.lib : Apple ][ with Uthernet or LANceGS or Uthernet II (default slot: #3)
|
# ip65_apple2.lib : Apple ][ with Uthernet or Uthernet II or LANceGS (default slot: #3)
|
||||||
# ip65_atari.lib : ATARI 8-bit with Dragon Cart or Dracarys (default PBI device ID: #8)
|
# ip65_atari.lib : ATARI 8-bit with Dragon Cart
|
||||||
# ip65_atarixl.lib : ATARI XL with Dragon Cart or Dracarys (default PBI device ID: #8)
|
# ip65_atarixl.lib : ATARI XL with Dragon Cart
|
||||||
|
|
||||||
DRIVERS=\
|
DRIVERS=\
|
||||||
c64rrnet.lib \
|
c64rrnet.lib \
|
||||||
|
@ -25,14 +23,12 @@ DRIVERS=\
|
||||||
c64combo.lib \
|
c64combo.lib \
|
||||||
ip65_c64.lib \
|
ip65_c64.lib \
|
||||||
a2uther.lib \
|
a2uther.lib \
|
||||||
a2lancegs.lib \
|
|
||||||
a2uther2.lib \
|
a2uther2.lib \
|
||||||
|
a2lancegs.lib \
|
||||||
a2combo.lib \
|
a2combo.lib \
|
||||||
ip65_apple2.lib \
|
ip65_apple2.lib \
|
||||||
ip65_apple2_uther2.lib \
|
ip65_apple2_uther2.lib \
|
||||||
atrdragon.lib \
|
atrdragon.lib \
|
||||||
atrdracarys.lib \
|
|
||||||
atrcombo.lib \
|
|
||||||
ip65_atari.lib \
|
ip65_atari.lib \
|
||||||
ip65_atarixl.lib \
|
ip65_atarixl.lib \
|
||||||
vic20rrnet.lib
|
vic20rrnet.lib
|
||||||
|
@ -118,9 +114,9 @@ rr-net.o uthernet.o dragoncart.o vic20-rr-net.o: cs8900a.s
|
||||||
|
|
||||||
eth64.o lancegs.o: lan91c96.s
|
eth64.o lancegs.o: lan91c96.s
|
||||||
|
|
||||||
uthernet2.o dracarys.o: w5100.s
|
uthernet2.o: w5100.s
|
||||||
|
|
||||||
c64combo.o a2combo.o atrcombo.o: ethernetcombo.s
|
c64combo.o a2combo.o: ethernetcombo.s
|
||||||
|
|
||||||
c64rrnet.lib: rr-net.o $(CS8900AOBJS) c64init.o $(C64OBJS)
|
c64rrnet.lib: rr-net.o $(CS8900AOBJS) c64init.o $(C64OBJS)
|
||||||
|
|
||||||
|
@ -132,10 +128,10 @@ ip65_c64.lib: rr-net.o eth64.o c64combo.o c64init.o $(C64_OBJS)
|
||||||
|
|
||||||
a2uther.lib: uthernet.o $(CS8900AOBJS) a2init.o $(A2OBJS)
|
a2uther.lib: uthernet.o $(CS8900AOBJS) a2init.o $(A2OBJS)
|
||||||
|
|
||||||
a2lancegs.lib: lancegs.o $(LAN91C96OBJS) a2init.o $(A2OBJS)
|
|
||||||
|
|
||||||
a2uther2.lib: uthernet2.o $(W5100OBJS) a2init.o $(A2OBJS)
|
a2uther2.lib: uthernet2.o $(W5100OBJS) a2init.o $(A2OBJS)
|
||||||
|
|
||||||
|
a2lancegs.lib: lancegs.o $(LAN91C96OBJS) a2init.o $(A2OBJS)
|
||||||
|
|
||||||
a2combo.lib: uthernet.o lancegs.o uthernet2.o a2combo.o a2init.o $(A2OBJS)
|
a2combo.lib: uthernet.o lancegs.o uthernet2.o a2combo.o a2init.o $(A2OBJS)
|
||||||
|
|
||||||
ip65_apple2.lib: uthernet.o lancegs.o uthernet2.o a2combo.o a2init.o $(A2_OBJS)
|
ip65_apple2.lib: uthernet.o lancegs.o uthernet2.o a2combo.o a2init.o $(A2_OBJS)
|
||||||
|
@ -144,13 +140,9 @@ ip65_apple2_uther2.lib: uthernet2.o $(W5100OBJS) a2init.o $(A2_OBJS)
|
||||||
|
|
||||||
atrdragon.lib: dragoncart.o $(CS8900AOBJS) atrinit.o $(ATROBJS)
|
atrdragon.lib: dragoncart.o $(CS8900AOBJS) atrinit.o $(ATROBJS)
|
||||||
|
|
||||||
atrdracarys.lib: dracarys.o $(W5100OBJS) atrinit.o $(ATROBJS)
|
ip65_atari.lib: dragoncart.o $(CS8900AOBJS) atrinit.o $(ATR_OBJS)
|
||||||
|
|
||||||
atrcombo.lib: dragoncart.o dracarys.o atrcombo.o atrinit.o $(ATROBJS)
|
ip65_atarixl.lib: dragoncart.o $(CS8900AOBJS) atrinit.o $(ATRXL_OBJS)
|
||||||
|
|
||||||
ip65_atari.lib: dragoncart.o dracarys.o atrcombo.o atrinit.o $(ATR_OBJS)
|
|
||||||
|
|
||||||
ip65_atarixl.lib: dragoncart.o dracarys.o atrcombo.o atrinit.o $(ATRXL_OBJS)
|
|
||||||
|
|
||||||
vic20rrnet.lib: vic20-rr-net.o $(CS8900AOBJS) vic20init.o $(VIC20OBJS)
|
vic20rrnet.lib: vic20-rr-net.o $(CS8900AOBJS) vic20init.o $(VIC20OBJS)
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
.exportzp eth_init_default = 5 ; Apple 2 default slot
|
.exportzp eth_init_default = 3 ; Apple 2 default slot
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
.exportzp eth_init_default = 8 ; PBI default device ID
|
.exportzp eth_init_default = 0
|
||||||
|
|
|
@ -132,7 +132,7 @@ set_name:
|
||||||
eth_init:
|
eth_init:
|
||||||
sta eth_init_value
|
sta eth_init_value
|
||||||
|
|
||||||
.if .defined (__APPLE2__) .or .defined (__ATARI__)
|
.if .defined (__APPLE2__)
|
||||||
ldax #_w5100
|
ldax #_w5100
|
||||||
jsr patch_wrapper
|
jsr patch_wrapper
|
||||||
ldax #_w5100_name
|
ldax #_w5100_name
|
||||||
|
|
|
@ -41,12 +41,7 @@
|
||||||
|
|
||||||
; Ethernet address
|
; Ethernet address
|
||||||
mac: .byte $00, $08, $DC ; OUI of WIZnet
|
mac: .byte $00, $08, $DC ; OUI of WIZnet
|
||||||
.ifdef __APPLE2__
|
|
||||||
.byte $A2, $A2, $A2
|
.byte $A2, $A2, $A2
|
||||||
.endif
|
|
||||||
.ifdef __ATARI__
|
|
||||||
.byte $A8, $A8, $A8
|
|
||||||
.endif
|
|
||||||
|
|
||||||
; Buffer attributes
|
; Buffer attributes
|
||||||
bufaddr:.res 2 ; Address
|
bufaddr:.res 2 ; Address
|
||||||
|
@ -91,8 +86,6 @@ tmp := tmp4 ; Temporary value
|
||||||
|
|
||||||
;=====================================================================
|
;=====================================================================
|
||||||
|
|
||||||
.ifdef __APPLE2__
|
|
||||||
|
|
||||||
.rodata
|
.rodata
|
||||||
|
|
||||||
fixup: .byte fixup02-fixup01, fixup03-fixup02, fixup04-fixup03
|
fixup: .byte fixup02-fixup01, fixup03-fixup02, fixup04-fixup03
|
||||||
|
@ -155,54 +148,6 @@ init:
|
||||||
bcs :- ; Always
|
bcs :- ; Always
|
||||||
:
|
:
|
||||||
|
|
||||||
.endif
|
|
||||||
|
|
||||||
;=====================================================================
|
|
||||||
|
|
||||||
.ifdef __ATARI__
|
|
||||||
|
|
||||||
.rodata
|
|
||||||
|
|
||||||
pdtab: .byte %00000001
|
|
||||||
.byte %00000010
|
|
||||||
.byte %00000100
|
|
||||||
.byte %00001000
|
|
||||||
.byte %00010000
|
|
||||||
.byte %00100000
|
|
||||||
.byte %01000000
|
|
||||||
.byte %10000000
|
|
||||||
|
|
||||||
;---------------------------------------------------------------------
|
|
||||||
|
|
||||||
.bss
|
|
||||||
|
|
||||||
pdbit: .res 1
|
|
||||||
|
|
||||||
;---------------------------------------------------------------------
|
|
||||||
|
|
||||||
mode := $D1F0
|
|
||||||
addr := $D1F1
|
|
||||||
data := $D1F3
|
|
||||||
|
|
||||||
pdvs := $D1FF ; parallel device select
|
|
||||||
shpdvs := $0248 ; shadow parallel device select
|
|
||||||
|
|
||||||
;---------------------------------------------------------------------
|
|
||||||
|
|
||||||
.code
|
|
||||||
|
|
||||||
init:
|
|
||||||
; Convert parallel device ID (1-8) to parallel device bit
|
|
||||||
tay
|
|
||||||
lda pdtab-1,y
|
|
||||||
sta pdbit
|
|
||||||
|
|
||||||
; Select parallel device
|
|
||||||
sta shpdvs
|
|
||||||
sta pdvs
|
|
||||||
|
|
||||||
.endif
|
|
||||||
|
|
||||||
;=====================================================================
|
;=====================================================================
|
||||||
|
|
||||||
; Indirect Bus I/F mode, Address Auto-Increment
|
; Indirect Bus I/F mode, Address Auto-Increment
|
||||||
|
@ -287,13 +232,6 @@ fixup14:sta data
|
||||||
;---------------------------------------------------------------------
|
;---------------------------------------------------------------------
|
||||||
|
|
||||||
poll:
|
poll:
|
||||||
.ifdef __ATARI__
|
|
||||||
; Select parallel device
|
|
||||||
lda pdbit
|
|
||||||
sta shpdvs
|
|
||||||
sta pdvs
|
|
||||||
.endif
|
|
||||||
|
|
||||||
; Check for completion of previous command
|
; Check for completion of previous command
|
||||||
; Socket 0 Command Register: = 0 ?
|
; Socket 0 Command Register: = 0 ?
|
||||||
jsr set_addrcmdreg0
|
jsr set_addrcmdreg0
|
||||||
|
@ -401,13 +339,6 @@ send:
|
||||||
sta adv
|
sta adv
|
||||||
stx adv+1
|
stx adv+1
|
||||||
|
|
||||||
.ifdef __ATARI__
|
|
||||||
; Select parallel device
|
|
||||||
lda pdbit
|
|
||||||
sta shpdvs
|
|
||||||
sta pdvs
|
|
||||||
.endif
|
|
||||||
|
|
||||||
; Set parameters for transmitting data
|
; Set parameters for transmitting data
|
||||||
lda #>$4000 ; Socket 0 TX Base Address
|
lda #>$4000 ; Socket 0 TX Base Address
|
||||||
ldx #$01 ; Write
|
ldx #$01 ; Write
|
||||||
|
|
14
inc/ip65.h
14
inc/ip65.h
|
@ -7,9 +7,7 @@
|
||||||
// Ethernet driver initialization parameter values
|
// Ethernet driver initialization parameter values
|
||||||
//
|
//
|
||||||
#if defined(__APPLE2__)
|
#if defined(__APPLE2__)
|
||||||
#define ETH_INIT_DEFAULT 5 // Apple II slot number
|
#define ETH_INIT_DEFAULT 3 // Apple II slot number
|
||||||
#elif defined(__ATARI__)
|
|
||||||
#define ETH_INIT_DEFAULT 8 // ATARI PBI device ID
|
|
||||||
#else
|
#else
|
||||||
#define ETH_INIT_DEFAULT 0 // Unused
|
#define ETH_INIT_DEFAULT 0 // Unused
|
||||||
#endif
|
#endif
|
||||||
|
@ -294,16 +292,18 @@ bool __fastcall__ tftp_upload_from_memory(uint32_t server, const char* name,
|
||||||
//
|
//
|
||||||
// On success the variables url_ip, url_port and url_selector (see below) are valid.
|
// On success the variables url_ip, url_port and url_selector (see below) are valid.
|
||||||
//
|
//
|
||||||
// Inputs: url: Zero (or ctrl char) terminated string containing the URL
|
// Inputs: url: Zero (or ctrl char) terminated string containing the URL
|
||||||
|
// resolve: Resolve host in URL
|
||||||
// Output: true if an error occured, false otherwise
|
// Output: true if an error occured, false otherwise
|
||||||
//
|
//
|
||||||
bool __fastcall__ url_parse(const char* url);
|
bool __fastcall__ url_parse(const char* url, bool resolve);
|
||||||
|
|
||||||
// Access to parsed HTTP URL
|
// Access to parsed HTTP URL
|
||||||
//
|
//
|
||||||
// Access to the three items below is only valid after url_parse returned false.
|
// Access to the four items below is only valid after url_parse returned false.
|
||||||
//
|
//
|
||||||
extern uint32_t url_ip; // IP address of host in URL
|
extern char* url_host; // Zero terminated string containing host in URL + "\r\n\r\n"
|
||||||
|
extern uint32_t url_ip; // IP address of host in URL (only if 'resolve' is true)
|
||||||
extern uint16_t url_port; // Port number of URL
|
extern uint16_t url_port; // Port number of URL
|
||||||
extern char* url_selector; // Zero terminated string containing selector part of URL
|
extern char* url_selector; // Zero terminated string containing selector part of URL
|
||||||
|
|
||||||
|
|
16
ip65/dhcp.s
16
ip65/dhcp.s
|
@ -85,6 +85,7 @@ dhcp_message_sent_count: .res 1
|
||||||
dhcp_timer: .res 1
|
dhcp_timer: .res 1
|
||||||
dhcp_loop_count: .res 1
|
dhcp_loop_count: .res 1
|
||||||
dhcp_break_polling_loop: .res 1
|
dhcp_break_polling_loop: .res 1
|
||||||
|
dhcp_ip: .res 4
|
||||||
|
|
||||||
; DHCP constants
|
; DHCP constants
|
||||||
BOOTREQUEST = 1
|
BOOTREQUEST = 1
|
||||||
|
@ -315,9 +316,9 @@ dhcp_in:
|
||||||
cmp dhcp_inp+dhcp_yiaddr ; is the first byte in the assigned address 0?
|
cmp dhcp_inp+dhcp_yiaddr ; is the first byte in the assigned address 0?
|
||||||
bne :+
|
bne :+
|
||||||
rts ; if so, it's a bogus response - ignore
|
rts ; if so, it's a bogus response - ignore
|
||||||
: ldx #4 ; copy the our new IP address
|
: ldx #3 ; copy the new IP address
|
||||||
: lda dhcp_inp+dhcp_yiaddr,x
|
: lda dhcp_inp+dhcp_yiaddr,x
|
||||||
sta cfg_ip,x
|
sta dhcp_ip,x
|
||||||
dex
|
dex
|
||||||
bpl :-
|
bpl :-
|
||||||
|
|
||||||
|
@ -423,7 +424,7 @@ send_dhcprequest:
|
||||||
ldx #4 ; option length is 4
|
ldx #4 ; option length is 4
|
||||||
stx output_buffer+dhcp_options+4
|
stx output_buffer+dhcp_options+4
|
||||||
dex
|
dex
|
||||||
: lda cfg_ip,x
|
: lda dhcp_ip,x
|
||||||
sta output_buffer+dhcp_options+5,x
|
sta output_buffer+dhcp_options+5,x
|
||||||
dex
|
dex
|
||||||
bpl :-
|
bpl :-
|
||||||
|
@ -449,9 +450,16 @@ send_dhcprequest:
|
||||||
|
|
||||||
ldax #output_buffer
|
ldax #output_buffer
|
||||||
jsr udp_send
|
jsr udp_send
|
||||||
bcs :+ ; if we didn't send the message we probably need to wait for an ARP reply to come back.
|
bcs :++ ; if we didn't send the message we probably need to wait for an ARP reply to come back.
|
||||||
|
|
||||||
lda #dhcp_bound ; technically, we should wait till we get a DHCPACK message. but we'll assume success
|
lda #dhcp_bound ; technically, we should wait till we get a DHCPACK message. but we'll assume success
|
||||||
sta dhcp_state
|
sta dhcp_state
|
||||||
|
ldx #3 ; set the new IP address
|
||||||
|
: lda dhcp_ip,x
|
||||||
|
sta cfg_ip,x
|
||||||
|
dex
|
||||||
|
bpl :-
|
||||||
|
|
||||||
: rts
|
: rts
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,7 @@ url_download:
|
||||||
sty url_selector
|
sty url_selector
|
||||||
ldy url_download_buffer+1
|
ldy url_download_buffer+1
|
||||||
sty url_selector+1
|
sty url_selector+1
|
||||||
|
ldy #1
|
||||||
jsr url_parse_buffer
|
jsr url_parse_buffer
|
||||||
bcc resource_download
|
bcc resource_download
|
||||||
rts
|
rts
|
||||||
|
|
|
@ -65,7 +65,7 @@ _udp_recv_src_port:
|
||||||
ldx udp_inp+udp_src_port
|
ldx udp_inp+udp_src_port
|
||||||
rts
|
rts
|
||||||
|
|
||||||
_udp_send:
|
_udp_send:
|
||||||
stax udp_send_src_port
|
stax udp_send_src_port
|
||||||
jsr popax
|
jsr popax
|
||||||
stax udp_send_dest_port
|
stax udp_send_dest_port
|
||||||
|
|
21
ip65/url.s
21
ip65/url.s
|
@ -13,6 +13,7 @@
|
||||||
.import parse_integer
|
.import parse_integer
|
||||||
.import dns_ip
|
.import dns_ip
|
||||||
|
|
||||||
|
.export url_host
|
||||||
.export url_ip
|
.export url_ip
|
||||||
.export url_port
|
.export url_port
|
||||||
.export url_selector
|
.export url_selector
|
||||||
|
@ -26,7 +27,8 @@ search_string = ptr1
|
||||||
.bss
|
.bss
|
||||||
|
|
||||||
url_string: .res 2
|
url_string: .res 2
|
||||||
url_ip: .res 4 ; will be set with ip address of host in url
|
url_host: .res 2 ; will be set with hostname + CRLFCRLF
|
||||||
|
url_ip: .res 4 ; will be set with ip address of host in url (if resolve)
|
||||||
url_port: .res 2 ; will be set with port number of url
|
url_port: .res 2 ; will be set with port number of url
|
||||||
url_selector: .res 2 ; will be set with address of selector part of URL
|
url_selector: .res 2 ; will be set with address of selector part of URL
|
||||||
url_type: .res 1
|
url_type: .res 1
|
||||||
|
@ -35,6 +37,7 @@ search_string = ptr1
|
||||||
url_type_gopher = 1
|
url_type_gopher = 1
|
||||||
url_type_http = 2
|
url_type_http = 2
|
||||||
|
|
||||||
|
resolve: .res 1
|
||||||
src_ptr: .res 1
|
src_ptr: .res 1
|
||||||
dest_ptr: .res 1
|
dest_ptr: .res 1
|
||||||
|
|
||||||
|
@ -46,28 +49,33 @@ search_string = ptr1
|
||||||
; inputs:
|
; inputs:
|
||||||
; AX = address of URL string
|
; AX = address of URL string
|
||||||
; any control character (i.e. <$20) is treated as 'end of string', e.g. a CR or LF, as well as $00
|
; any control character (i.e. <$20) is treated as 'end of string', e.g. a CR or LF, as well as $00
|
||||||
|
; Y = do resolve hostname
|
||||||
; outputs:
|
; outputs:
|
||||||
; sec if a malformed url, otherwise:
|
; sec if a malformed url, otherwise:
|
||||||
; url_ip = ip address of host in url
|
; url_ip = ip address of host in url
|
||||||
; url_port = port number of url
|
; url_port = port number of url
|
||||||
; url_selector = address of selector part of URL
|
; url_selector = address of selector part of URL
|
||||||
url_parse:
|
url_parse:
|
||||||
|
sty resolve
|
||||||
ldy #<output_buffer
|
ldy #<output_buffer
|
||||||
sty url_selector
|
sty url_selector
|
||||||
ldy #>output_buffer
|
ldy #>output_buffer
|
||||||
sty url_selector+1
|
sty url_selector+1
|
||||||
|
ldy resolve
|
||||||
|
|
||||||
; parses a URL into a form that makes it easy to retrieve the specified resource
|
; parses a URL into a form that makes it easy to retrieve the specified resource
|
||||||
; caution - the resulting selector part of URL must fit into the provided buffer !!!
|
; caution - the resulting selector part of URL must fit into the provided buffer !!!
|
||||||
; inputs:
|
; inputs:
|
||||||
; AX = address of URL string
|
; AX = address of URL string
|
||||||
; any control character (i.e. <$20) is treated as 'end of string', e.g. a CR or LF, as well as $00
|
; any control character (i.e. <$20) is treated as 'end of string', e.g. a CR or LF, as well as $00
|
||||||
|
; Y = do resolve hostname
|
||||||
; url_selector = points to a buffer that selector part of URL will be placed into
|
; url_selector = points to a buffer that selector part of URL will be placed into
|
||||||
; outputs:
|
; outputs:
|
||||||
; sec if a malformed url, otherwise:
|
; sec if a malformed url, otherwise:
|
||||||
; url_ip = ip address of host in url
|
; url_ip = ip address of host in url
|
||||||
; url_port = port number of url
|
; url_port = port number of url
|
||||||
url_parse_buffer:
|
url_parse_buffer:
|
||||||
|
sty resolve
|
||||||
stax url_string
|
stax url_string
|
||||||
ldy #url_type_http
|
ldy #url_type_http
|
||||||
sty url_type
|
sty url_type
|
||||||
|
@ -109,6 +117,8 @@ lda #url_type_gopher
|
||||||
; now pointing at hostname
|
; now pointing at hostname
|
||||||
bcs @exit_with_error
|
bcs @exit_with_error
|
||||||
@no_protocol_specifier:
|
@no_protocol_specifier:
|
||||||
|
ldy resolve
|
||||||
|
beq @no_resolve
|
||||||
jsr dns_set_hostname
|
jsr dns_set_hostname
|
||||||
bcs @exit_with_sec
|
bcs @exit_with_sec
|
||||||
jsr dns_resolve
|
jsr dns_resolve
|
||||||
|
@ -125,6 +135,7 @@ lda #url_type_gopher
|
||||||
|
|
||||||
jsr skip_to_hostname
|
jsr skip_to_hostname
|
||||||
|
|
||||||
|
@no_resolve:
|
||||||
; skip over next colon
|
; skip over next colon
|
||||||
ldax #colon
|
ldax #colon
|
||||||
jsr parser_skip_next
|
jsr parser_skip_next
|
||||||
|
@ -212,11 +223,17 @@ lda #url_type_gopher
|
||||||
jsr skip_to_hostname
|
jsr skip_to_hostname
|
||||||
; AX now pointing at hostname
|
; AX now pointing at hostname
|
||||||
stax ptr1
|
stax ptr1
|
||||||
|
|
||||||
|
clc
|
||||||
lda url_selector
|
lda url_selector
|
||||||
sta ptr2
|
sta ptr2
|
||||||
|
adc dest_ptr
|
||||||
|
sta url_host
|
||||||
pla
|
pla
|
||||||
sta ptr2+1
|
sta ptr2+1
|
||||||
|
adc #0
|
||||||
|
sta url_host+1
|
||||||
|
|
||||||
lda #0
|
lda #0
|
||||||
sta src_ptr
|
sta src_ptr
|
||||||
|
|
||||||
|
|
10
ip65/url_c.s
10
ip65/url_c.s
|
@ -1,22 +1,32 @@
|
||||||
.include "../inc/common.inc"
|
.include "../inc/common.inc"
|
||||||
|
|
||||||
.export _url_parse
|
.export _url_parse
|
||||||
|
.export _url_host
|
||||||
.export _url_ip
|
.export _url_ip
|
||||||
.export _url_port
|
.export _url_port
|
||||||
.export _url_selector
|
.export _url_selector
|
||||||
|
|
||||||
.import url_parse
|
.import url_parse
|
||||||
|
.import url_host
|
||||||
.import url_ip
|
.import url_ip
|
||||||
.import url_port
|
.import url_port
|
||||||
.import url_selector
|
.import url_selector
|
||||||
|
|
||||||
|
.import popax
|
||||||
|
.importzp tmp1
|
||||||
|
|
||||||
_url_parse:
|
_url_parse:
|
||||||
|
sta tmp1
|
||||||
|
jsr popax
|
||||||
|
ldy tmp1
|
||||||
jsr url_parse
|
jsr url_parse
|
||||||
ldx #$00
|
ldx #$00
|
||||||
txa
|
txa
|
||||||
rol
|
rol
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
_url_host := url_host
|
||||||
|
|
||||||
_url_ip := url_ip
|
_url_ip := url_ip
|
||||||
|
|
||||||
_url_port := url_port
|
_url_port := url_port
|
||||||
|
|
|
@ -17,15 +17,14 @@ else ifeq ($(eth),sm)
|
||||||
A2DRIVERLIB = ../drivers/a2lancegs.lib
|
A2DRIVERLIB = ../drivers/a2lancegs.lib
|
||||||
else ifeq ($(eth),wn)
|
else ifeq ($(eth),wn)
|
||||||
A2DRIVERLIB = ../drivers/a2uther2.lib
|
A2DRIVERLIB = ../drivers/a2uther2.lib
|
||||||
ATRDRIVERLIB = ../drivers/atrdracarys.lib
|
|
||||||
else
|
else
|
||||||
C64DRIVERLIB = ../drivers/c64combo.lib
|
C64DRIVERLIB = ../drivers/c64combo.lib
|
||||||
A2DRIVERLIB = ../drivers/a2combo.lib
|
A2DRIVERLIB = ../drivers/a2combo.lib
|
||||||
ATRDRIVERLIB = ../drivers/atrcombo.lib
|
ATRDRIVERLIB = ../drivers/atrdragon.lib
|
||||||
VICDRIVERLIB = ../drivers/vic20rrnet.lib
|
VICDRIVERLIB = ../drivers/vic20rrnet.lib
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# See http://vice-emu.sourceforge.net/
|
# See https://vice-emu.sourceforge.net/
|
||||||
C1541 ?= c1541
|
C1541 ?= c1541
|
||||||
|
|
||||||
# See https://applecommander.github.io/
|
# See https://applecommander.github.io/
|
||||||
|
@ -112,32 +111,28 @@ vt100.com: ATARI_CFG = ../apps/atrtelnet.cfg
|
||||||
%.o: %.c
|
%.o: %.c
|
||||||
|
|
||||||
%.prg: %.o ip65 drivers
|
%.prg: %.o ip65 drivers
|
||||||
ld65 -o $*.prg -C c64.cfg -m $*.c64.map -vm $< $(IP65LIB) $(C64DRIVERLIB) c64.lib
|
ld65 -o $*.prg -C c64.cfg -m $*.prg.map -vm $< $(IP65LIB) $(C64DRIVERLIB) c64.lib
|
||||||
|
|
||||||
%.bin: %.o ip65 drivers
|
%.bin: %.o ip65 drivers
|
||||||
ld65 -o $*.bin -C apple2.cfg -m $*.a2.map -vm $< $(IP65LIB) $(A2DRIVERLIB) apple2.lib
|
ld65 -o $*.bin -C apple2.cfg -m $*.bin.map -vm $< $(IP65LIB) $(A2DRIVERLIB) apple2.lib
|
||||||
|
|
||||||
%.com: %.o ip65 drivers
|
%.com: %.o ip65 drivers
|
||||||
ld65 -o $*.com -C $(ATARI_CFG) -m $*.atr.map -vm $< $(IP65LIB) $(ATRDRIVERLIB) atari.lib
|
ld65 -o $*.com -C $(ATARI_CFG) -m $*.com.map -vm $< $(IP65LIB) $(ATRDRIVERLIB) atari.lib
|
||||||
|
|
||||||
%.vicprg: %.o ip65 drivers
|
%.vicprg: %.o ip65 drivers
|
||||||
ld65 -o $*.vicprg -C vic20-32k.cfg -m $*.vic.map -vm $< $(IP65LIB) $(VICDRIVERLIB) vic20.lib
|
ld65 -o $*.vicprg -C vic20-32k.cfg -m $*.vicprg.map -vm $< $(IP65LIB) $(VICDRIVERLIB) vic20.lib
|
||||||
|
|
||||||
%.prg: %.c ip65 drivers
|
%.prg: %.c ip65 drivers
|
||||||
cl65 -o $*.prg -O -t c64 -m $*.c64.map -vm $< $(wildcard $**.s) $(IP65LIB) ../drivers/ip65_c64.lib
|
cl65 -o $*.prg -O -t c64 -m $*.prg.map -vm $< $(wildcard $**.s) $(IP65LIB) ../drivers/ip65_c64.lib
|
||||||
rm $*.o
|
|
||||||
|
|
||||||
%.bin: %.c ip65 drivers
|
%.bin: %.c ip65 drivers
|
||||||
cl65 -o $*.bin -O -t apple2 -m $*.a2.map -vm $< $(wildcard $**.s) $(IP65LIB) ../drivers/ip65_apple2.lib
|
cl65 -o $*.bin -O -t apple2 -m $*.bin.map -vm $< $(wildcard $**.s) $(IP65LIB) ../drivers/ip65_apple2.lib
|
||||||
rm $*.o
|
|
||||||
|
|
||||||
%.com: %.c ip65 drivers
|
%.com: %.c ip65 drivers
|
||||||
cl65 -o $*.com -O -t atari -m $*.atr.map -vm $< $(wildcard $**.s) $(IP65LIB) ../drivers/ip65_atari.lib
|
cl65 -o $*.com -O -t atari -m $*.com.map -vm $< $(wildcard $**.s) $(IP65LIB) ../drivers/ip65_atari.lib
|
||||||
rm $*.o
|
|
||||||
|
|
||||||
%.xl.com: %.c ip65 drivers
|
%.xl.com: %.c ip65 drivers
|
||||||
cl65 -o $*.xl.com -O -t atarixl -m $*.atrxl.map -vm $< $(wildcard $**.s) $(IP65LIB) ../drivers/ip65_atarixl.lib
|
cl65 -o $*.xl.com -O -t atarixl -m $*.xl.com.map -vm $< $(wildcard $**.s) $(IP65LIB) ../drivers/ip65_atarixl.lib
|
||||||
rm $*.o
|
|
||||||
|
|
||||||
ip65test.d64: prg
|
ip65test.d64: prg
|
||||||
$(C1541) -format ip65,00 d64 $@
|
$(C1541) -format ip65,00 d64 $@
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
.import url_port
|
.import url_port
|
||||||
.import url_selector
|
.import url_selector
|
||||||
.import url_resource_type
|
.import url_resource_type
|
||||||
.import url_parse
|
|
||||||
.import url_download
|
.import url_download
|
||||||
.import url_download_buffer
|
.import url_download_buffer
|
||||||
.import url_download_buffer_length
|
.import url_download_buffer_length
|
||||||
|
|
|
@ -100,6 +100,7 @@ test_url_parse:
|
||||||
jsr print
|
jsr print
|
||||||
jsr print_cr
|
jsr print_cr
|
||||||
ldax temp_url_ptr
|
ldax temp_url_ptr
|
||||||
|
ldy #1
|
||||||
jsr url_parse
|
jsr url_parse
|
||||||
bcc :+
|
bcc :+
|
||||||
jmp print_errorcode
|
jmp print_errorcode
|
||||||
|
|
Loading…
Reference in New Issue