cake
/
libp7
Archived
1
0
Fork 1

Added commands to the server.

This commit is contained in:
Thomas Touhey 2017-01-25 14:13:07 +01:00
parent db113e624b
commit 4d6541a474
3 changed files with 74 additions and 1 deletions

View File

@ -1,5 +1,5 @@
# libp7 authors
(C) 2016-2017 Thomas "Cakeisalie5" Touhey <<thomas@touhey.fr>>
Copyright (C) 2016-2017 Thomas "Cakeisalie5" Touhey <<thomas@touhey.fr>>
The documentation mainly comes from Simon Lothar's documentation.
The packet shifting was accidentally discovered by Nessotrin while making

View File

@ -41,6 +41,10 @@ typedef struct {
int os_wiped;
p7_version_t os_version;
p7uint_t os_offset, os_size;
/* addresses - for serving */
const unsigned char *flash_rom, *ram;
const unsigned char *casiowin_entry, *bootcode;
} p7_server_t;
/* Functions */

View File

@ -87,6 +87,29 @@ int p7_serve(p7_handle_t *handle, p7_server_t *info,
case 0x01: /* get server info */
err = p7_send_eack(handle, info);
break;
case 0x2F: /* request a RAM image transfer */
/* check that we have the RAM */
if (!info->ram) {
err = p7_send_err(handle, p7_err_other);
break;
}
/* accept and roleswap */
err = p7_send_ack(handle, 1);
if (err) break;
if (resp->type != p7_pt_roleswp) {
err = p7_send_err(handle, p7_err_other);
break;
}
/* send the thing */
err = p7_send_databuf(handle, info->ram, info->ram_capacity,
0, NULL);
if (err) break;
/* re-roleswp */
err = p7_send_roleswp(handle);
break;
case 0x40: /* create directory */
gather_fs()
gather_sdir()
@ -140,6 +163,52 @@ int p7_serve(p7_handle_t *handle, p7_server_t *info,
p7_send_ack(handle, 1);
}
break;
case 0x52: /* request a CASIOWIN entry transfer */
/* check if the CASIOWIN entry is available */
if (!info->casiowin_entry) {
err = p7_send_err(handle, p7_err_other);
break;
}
/* accept and roleswap */
err = p7_send_ack(handle, 1);
if (err) break;
if (resp->type != p7_pt_roleswp) {
err = p7_send_err(handle, p7_err_other);
break;
}
/* send the thing */
err = p7_send_databuf(handle, info->casiowin_entry, 0x80,
0, NULL);
if (err) break;
/* roleswp and wait for other command */
err = p7_send_roleswp(handle);
break;
case 0x54: /* request a bootcode transfer */
/* check if the bootcode is available */
if (!info->bootcode) {
err = p7_send_err(handle, p7_err_other);
break;
}
/* accept and roleswap */
err = p7_send_ack(handle, 1);
if (err) break;
if (resp->type != p7_pt_roleswp) {
err = p7_send_err(handle, p7_err_other);
break;
}
/* send the thing */
err = p7_send_databuf(handle, info->bootcode, info->bootcode_size,
0, NULL);
if (err) break;
/* roleswap and wait for next command */
err = p7_send_roleswp(handle);
break;
default: /* unknown command! */
err = p7_send_err(handle, p7_err_other);
}