summaryrefslogtreecommitdiffstats
path: root/qemu/roms/SLOF/lib/libvirtio/p9.h
blob: 3a35e80eda2fd5e14fc77e778e99d95588cb66ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/******************************************************************************
 * Copyright (c) 2011 IBM Corporation
 * All rights reserved.
 * This program and the accompanying materials
 * are made available under the terms of the BSD License
 * which accompanies this distribution, and is available at
 * http://www.opensource.org/licenses/bsd-license.php
 *
 * Contributors:
 *     IBM Corporation - initial implementation
 *****************************************************************************/

#ifndef P9_H
#define P9_H

#include <stdint.h>


#define P9_ERROR			-1
#define P9_UNKNOWN_VERSION		-2
#define P9_R_ERROR			-3
#define P9_MSG_TOO_LONG			-4
#define P9_UNEXPECTED_MSG		-5
#define P9_UNEXPECTED_TAG		-6
#define P9_TRANSPORT_ERROR		-7
#define P9_NO_TRANSPORT			-8
#define P9_NULL_PATH			-9
#define P9_PATH_ELEMENT_TOO_LONG	-10
#define P9_READ_UNEXPECTED_DATA		-11
#define P9_NO_BUFFER			-12
#define P9_MSG_SIZE_TOO_BIG		-13

#define P9_PARTIAL_WALK			1

typedef int (*p9_transact_t)(void *opaque, uint8_t *tx, int tx_size,
		uint8_t *rx, uint32_t *rx_size);

typedef struct {
	uint32_t message_size;
	char *uname; 		/* User name. */
	char *aname; 		/* Tree/mount name/path. */
	uint32_t fid;		/* Represents mount point. */
} p9_connection_t;

typedef struct {
	uint32_t fid;		/* Identifies the file to P9 server. */
	uint32_t iounit;	/* Maximum read size in bytes. */
	uint8_t type;		/* Type of file. */
	uint64_t length;	/* Length of file. */
	p9_connection_t *connection;
} p9_file_t;


void reset_buffers(void);
void p9_reg_transport(p9_transact_t transact_func, void *opaque,
		      uint8_t *tx_buffer, uint8_t *rx_buffer);
int p9_transaction(p9_connection_t *connection);
int p9_version(p9_connection_t *connection);
int p9_attach(p9_connection_t *connection);
int p9_clunk(p9_connection_t *connection, uint32_t fid);
int p9_walk(p9_connection_t *connection, uint32_t fid, uint32_t new_fid,
		uint8_t **pos);
int p9_open(p9_file_t *file, uint8_t mode);
int p9_read(p9_file_t *file, uint8_t *buffer,
		uint32_t count, uint64_t offset);
int p9_stat(p9_file_t *file);

#endif