• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2021 The Pigweed Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not
4 // use this file except in compliance with the License. You may obtain a copy of
5 // the License at
6 //
7 //     https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 // License for the specific language governing permissions and limitations under
13 // the License.
14 #pragma once
15 
16 #include <cstdint>
17 
18 // PW_SYSTEM_LOG_BUFFER_SIZE is the log buffer size which determines how many
19 // log entries can be buffered prior to streaming them.
20 //
21 // Defaults to 4KiB.
22 #ifndef PW_SYSTEM_LOG_BUFFER_SIZE
23 #define PW_SYSTEM_LOG_BUFFER_SIZE 4096
24 #endif  // PW_SYSTEM_LOG_BUFFER_SIZE
25 
26 // PW_SYSTEM_MAX_LOG_ENTRY_SIZE limits the proto-encoded log entry size. This
27 // value might depend on a target interface's MTU.
28 //
29 // Defaults to 256B.
30 #ifndef PW_SYSTEM_MAX_LOG_ENTRY_SIZE
31 #define PW_SYSTEM_MAX_LOG_ENTRY_SIZE 256
32 #endif  // PW_SYSTEM_MAX_LOG_ENTRY_SIZE
33 
34 // PW_SYSTEM_MAX_TRANSMISSION_UNIT target's MTU.
35 //
36 // Defaults to 1055 bytes, which is enough to fit 512-byte payloads when using
37 // HDLC framing.
38 #ifndef PW_SYSTEM_MAX_TRANSMISSION_UNIT
39 #define PW_SYSTEM_MAX_TRANSMISSION_UNIT 1055
40 #endif  // PW_SYSTEM_MAX_TRANSMISSION_UNIT
41 
42 // PW_SYSTEM_DEFAULT_CHANNEL_ID RPC channel ID to host.
43 //
44 // Defaults to 1.
45 #ifndef PW_SYSTEM_DEFAULT_CHANNEL_ID
46 #define PW_SYSTEM_DEFAULT_CHANNEL_ID 1
47 #endif  // PW_SYSTEM_DEFAULT_CHANNEL_ID
48 
49 // PW_SYSTEM_LOGGING_CHANNEL_ID logging RPC channel ID to host. If this is
50 // different from PW_SYSTEM_DEFAULT_CHANNEL_ID, then
51 // PW_SYSTEM_LOGGING_RPC_HDLC_ADDRESS must also be different from
52 // PW_SYSTEM_DEFAULT_RPC_HDLC_ADDRESS.
53 //
54 // Defaults to PW_SYSTEM_DEFAULT_CHANNEL_ID.
55 #ifndef PW_SYSTEM_LOGGING_CHANNEL_ID
56 #define PW_SYSTEM_LOGGING_CHANNEL_ID PW_SYSTEM_DEFAULT_CHANNEL_ID
57 #endif  // PW_SYSTEM_LOGGING_CHANNEL_ID
58 
59 // PW_SYSTEM_DEFAULT_RPC_HDLC_ADDRESS RPC HDLC default address.
60 //
61 // Defaults to 82.
62 #ifndef PW_SYSTEM_DEFAULT_RPC_HDLC_ADDRESS
63 #define PW_SYSTEM_DEFAULT_RPC_HDLC_ADDRESS 82
64 #endif  // PW_SYSTEM_DEFAULT_RPC_HDLC_ADDRESS
65 
66 // PW_SYSTEM_LOGGING_RPC_HDLC_ADDRESS RPC HDLC logging address.
67 //
68 // Defaults to PW_SYSTEM_DEFAULT_RPC_HDLC_ADDRESS.
69 #ifndef PW_SYSTEM_LOGGING_RPC_HDLC_ADDRESS
70 #define PW_SYSTEM_LOGGING_RPC_HDLC_ADDRESS PW_SYSTEM_DEFAULT_RPC_HDLC_ADDRESS
71 #endif  // PW_SYSTEM_LOGGING_RPC_HDLC_ADDRESS
72 
73 // PW_SYSTEM_EXTRA_LOGGING_CHANNEL_ID extra logging channel ID.
74 // If this is different from PW_SYSTEM_LOGGING_CHANNEL_ID, then
75 // an additional sink will be created to forward logs to
76 // this channel.
77 //
78 // Defaults to PW_SYSTEM_LOGGING_CHANNEL_ID
79 #ifndef PW_SYSTEM_EXTRA_LOGGING_CHANNEL_ID
80 #define PW_SYSTEM_EXTRA_LOGGING_CHANNEL_ID PW_SYSTEM_LOGGING_CHANNEL_ID
81 #endif  // PW_SYSTEM_EXTRA_LOGGING_CHANNEL_ID
82 
83 // PW_SYSTEM_ENABLE_TRACE_SERVICE specifies if the trace RPC service is enabled.
84 //
85 // Defaults to 1.
86 #ifndef PW_SYSTEM_ENABLE_TRACE_SERVICE
87 #define PW_SYSTEM_ENABLE_TRACE_SERVICE 1
88 #endif  // PW_SYSTEM_ENABLE_TRACE_SERVICE
89 
90 // PW_SYSTEM_ENABLE_TRANSFER_SERVICE specifies if the transfer RPC service is
91 // enabled.
92 //
93 // Defaults to 1.
94 #ifndef PW_SYSTEM_ENABLE_TRANSFER_SERVICE
95 #define PW_SYSTEM_ENABLE_TRANSFER_SERVICE 1
96 #endif  // PW_SYSTEM_ENABLE_TRANSFER_SERVICE
97 
98 // PW_SYSTEM_ENABLE_THREAD_SNAPSHOT_SERVICE specifies if the thread snapshot
99 // RPC service is enabled.
100 //
101 // Defaults to 1.
102 #ifndef PW_SYSTEM_ENABLE_THREAD_SNAPSHOT_SERVICE
103 #define PW_SYSTEM_ENABLE_THREAD_SNAPSHOT_SERVICE 1
104 #endif  // PW_SYSTEM_ENABLE_THREAD_SNAPSHOT_SERVICE
105 
106 // PW_SYSTEM_WORK_QUEUE_MAX_ENTRIES specifies the maximum number of work queue
107 // entries that may be staged at once.
108 //
109 // Defaults to 32.
110 #ifndef PW_SYSTEM_WORK_QUEUE_MAX_ENTRIES
111 #define PW_SYSTEM_WORK_QUEUE_MAX_ENTRIES 32
112 #endif  // PW_SYSTEM_WORK_QUEUE_MAX_ENTRIES
113 
114 // PW_SYSTEM_SOCKET_IO_PORT specifies the port number to use for the socket
115 // stream implementation of pw_system's I/O interface.
116 //
117 // Defaults to 33000.
118 #ifndef PW_SYSTEM_SOCKET_IO_PORT
119 #define PW_SYSTEM_SOCKET_IO_PORT 33000
120 #endif  // PW_SYSTEM_SOCKET_IO_PORT
121 
122 namespace pw::system {
123 
124 // This is the default channel used by the pw_system RPC server. Some other
125 // parts of pw_system use this channel ID as the default destination for
126 // unrequested data streams.
127 inline constexpr uint32_t kDefaultRpcChannelId = PW_SYSTEM_DEFAULT_CHANNEL_ID;
128 
129 // This is the channel ID used for logging.
130 inline constexpr uint32_t kLoggingRpcChannelId = PW_SYSTEM_LOGGING_CHANNEL_ID;
131 #if PW_SYSTEM_EXTRA_LOGGING_CHANNEL_ID != PW_SYSTEM_LOGGING_CHANNEL_ID
132 inline constexpr uint32_t kExtraLoggingRpcChannelId =
133     PW_SYSTEM_EXTRA_LOGGING_CHANNEL_ID;
134 #endif  // PW_SYSTEM_EXTRA_LOGGING_CHANNEL_ID != PW_SYSTEM_LOGGING_CHANNEL_ID
135 
136 }  // namespace pw::system
137