initial import
[ps3freebsd_ps3vuart.git] / ps3dm_msg.h
blob148b4d15f4f4cc27c477ac3fdfcdb2b4a1385d83
1 /*-
2 * Copyright (C) 2011, 2012 glevand <geoffrey.levand@mail.ru>
3 * All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer,
10 * without modification, immediately at the beginning of the file.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 * $FreeBSD$
29 #ifndef _PS3DM_MSG_H
30 #define _PS3DM_MSG_H
32 #define PS3DM_PID(fid, id) ((fid) | (id))
33 #define PS3DM_FID(pid) ((pid) & ~0xffful)
35 enum ps3dm_function_packet {
36 /* Virtual TRM */
38 PS3DM_FID_VTRM = 0x00002000,
39 PS3DM_PID_VTRM_INIT = PS3DM_PID(PS3DM_FID_VTRM, 1),
40 PS3DM_PID_VTRM_GET_STATUS = PS3DM_PID(PS3DM_FID_VTRM, 2),
42 /* Secure RTC */
44 PS3DM_FID_SRTC = 0x00003000,
45 PS3DM_PID_SRTC_GET_TIME = PS3DM_PID(PS3DM_FID_SRTC, 2),
46 PS3DM_PID_SRTC_SET_TIME = PS3DM_PID(PS3DM_FID_SRTC, 3),
48 /* Storage manager */
50 PS3DM_FID_SM = 0x00005000,
51 PS3DM_PID_SM_GET_RND = PS3DM_PID(PS3DM_FID_SM, 3),
54 struct ps3dm_header {
55 uint32_t tag;
56 uint32_t fid; /* enum ps3dm_function_packet */
57 uint32_t payload_length;
58 uint32_t reply_length;
61 #define PS3DM_HDR(_p) ((struct ps3dm_header *) (_p))
63 struct ps3dm_ss_header {
64 uint64_t pid; /* enum ps3dm_function_packet */
65 uint64_t fid; /* enum ps3dm_function_packet */
66 uint32_t status;
67 uint8_t res[4];
68 uint64_t laid;
69 uint64_t paid;
72 #define PS3DM_SS_HDR(_p) ((struct ps3dm_ss_header *) (_p))
74 struct ps3dm_sm_get_rnd {
75 struct ps3dm_header dm_hdr;
76 struct ps3dm_ss_header ss_hdr;
77 uint8_t rnd[24];
80 static inline void
81 ps3dm_init_header(struct ps3dm_header *hdr, uint32_t tag, uint32_t fid,
82 uint32_t payload_length, uint32_t reply_length)
84 hdr->tag = tag;
85 hdr->fid = fid;
86 hdr->payload_length = payload_length;
87 hdr->reply_length = reply_length;
90 static inline void
91 ps3dm_init_ss_header( struct ps3dm_ss_header *hdr, uint64_t pid,
92 uint64_t laid, uint64_t paid)
94 hdr->pid = pid;
95 hdr->fid = PS3DM_FID(pid);
96 hdr->laid = laid;
97 hdr->paid = paid;
100 #endif /* _PS3DM_MSG_H */