1 /* 2 * Copyright 2005-2007, Ingo Weinhold <bonefish@cs.tu-berlin.de>. 3 * All rights reserved. Distributed under the terms of the MIT License. 4 */ 5 #ifndef _BOOT_REMOTE_DISK_DEFS_H 6 #define _BOOT_REMOTE_DISK_DEFS_H 7 8 9 #include <inttypes.h> 10 11 12 enum { 13 REMOTE_DISK_SERVER_PORT = 8765, 14 REMOTE_DISK_BLOCK_SIZE = 1024, 15 }; 16 17 enum { 18 // requests 19 20 REMOTE_DISK_HELLO_REQUEST = 0, 21 // port: client port 22 23 REMOTE_DISK_READ_REQUEST = 1, 24 // port: client port 25 // offset: byte offset of data to read 26 // size: number of bytes to read (server might serve more, though) 27 28 REMOTE_DISK_WRITE_REQUEST = 2, 29 // port: client port 30 // offset: byte offset of data to write 31 // size: number of bytes to write 32 // data: the data 33 34 // replies 35 36 REMOTE_DISK_HELLO_REPLY = 3, 37 // offset: disk size 38 39 REMOTE_DISK_READ_REPLY = 4, // port unused 40 // offset: byte offset of read data 41 // size: number of bytes of data read; < 0 => error 42 // data: read data 43 44 REMOTE_DISK_WRITE_REPLY = 5, // port, data unused 45 // offset: byte offset of data written 46 // size: number of bytes of data written; < 0 => error 47 }; 48 49 // errors 50 enum { 51 REMOTE_DISK_IO_ERROR = -1, 52 REMOTE_DISK_BAD_REQUEST = -2, 53 }; 54 55 struct remote_disk_header { 56 uint64_t offset; 57 uint64_t request_id; 58 int16_t size; 59 uint16_t port; 60 uint8_t command; 61 uint8_t data[0]; 62 } __attribute__ ((__packed__)); 63 64 #endif // _BOOT_REMOTE_DISK_DEFS_H 65