2 * Copyright (c) 2015 Apple Inc. All rights reserved.
4 * @APPLE_APACHE_LICENSE_HEADER_START@
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 * @APPLE_APACHE_LICENSE_HEADER_END@
21 #ifndef __FIREHOSE_SERVER_INTERNAL__
22 #define __FIREHOSE_SERVER_INTERNAL__
24 OS_OBJECT_CLASS_DECL(firehose_client
, object
);
25 #define FIREHOSE_CLIENT_CLASS OS_OBJECT_VTABLE(firehose_client)
27 typedef struct firehose_snapshot_s
*firehose_snapshot_t
;
28 struct firehose_snapshot_s
{
29 firehose_snapshot_handler_t handler
;
30 dispatch_group_t fs_group
;
33 struct firehose_client_s
{
35 _OS_OBJECT_HEADER(void *os_obj_isa
, os_obj_ref_cnt
, os_obj_xref_cnt
);
36 struct _os_object_s fc_as_os_object
;
38 TAILQ_ENTRY(firehose_client_s
) fc_entry
;
39 struct firehose_client_s
*volatile fc_next
[2];
41 firehose_buffer_t fc_buffer
;
42 uint64_t volatile fc_mem_sent_flushed_pos
;
43 uint64_t volatile fc_mem_flushed_pos
;
44 uint64_t volatile fc_io_sent_flushed_pos
;
45 uint64_t volatile fc_io_flushed_pos
;
47 #define FC_STATE_ENQUEUED(for_io) (0x0001u << (for_io))
48 #define FC_STATE_MEM_ENQUEUED 0x0001
49 #define FC_STATE_IO_ENQUEUED 0x0002
51 #define FC_STATE_CANCELING(for_io) (0x0010u << (for_io))
52 #define FC_STATE_MEM_CANCELING 0x0010
53 #define FC_STATE_IO_CANCELING 0x0020
55 #define FC_STATE_CANCELED(for_io) (0x0100u << (for_io))
56 #define FC_STATE_MEM_CANCELED 0x0100
57 #define FC_STATE_IO_CANCELED 0x0200
58 #define FC_STATE_CANCELED_MASK 0x0300
60 uintptr_t volatile fc_state
;
62 void *volatile fc_ctxt
;
65 dispatch_mach_t fc_mach_channel
;
66 dispatch_source_t fc_kernel_source
;
70 os_unfair_lock fc_lock
;
75 bool fc_memory_corrupted
;
76 bool fc_needs_io_snapshot
;
77 bool fc_needs_mem_snapshot
;
82 _firehose_client_xref_dispose(struct firehose_client_s
*fc
);
84 _firehose_client_dispose(struct firehose_client_s
*fc
);
86 extern unsigned char __libfirehose_serverVersionString
[];
87 extern double __libfirehose_serverVersionNumber
;
89 #endif // __FIREHOSE_SERVER_INTERNAL__