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