blob: 85aea149ce3fdf56afd41c8745a9fd25dfbf02d0 [file] [log] [blame]
// Copyright 2020 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
library fuchsia.boot;
const MAX_ARGS_NAME_LENGTH uint8 = 64;
const MAX_ARGS_VALUE_LENGTH uint8 = 128;
// MAX_ARGS_NAME_LENGTH + MAX_ARGS_VALUE_LENGTH + 1 (for '=')
const MAX_ARGS_COLLECT_LENGTH uint8 = 193;
const MAX_ARGS_VECTOR_LENGTH uint8 = 255;
type BoolPair = struct {
key string:MAX_ARGS_NAME_LENGTH;
defaultval bool;
};
/// Protocol for retrieving boot arguments.
@discoverable
closed protocol Arguments {
/// Get the value of a boot argument `key`.
strict GetString(struct {
key string:MAX_ARGS_NAME_LENGTH;
}) -> (struct {
value string:<MAX_ARGS_VALUE_LENGTH, optional>;
});
/// Get the values of a list of arguments specified in `keys`.
strict GetStrings(struct {
keys vector<string:MAX_ARGS_NAME_LENGTH>:MAX_ARGS_VECTOR_LENGTH;
}) -> (struct {
values vector<string:<MAX_ARGS_VALUE_LENGTH, optional>>:MAX_ARGS_VECTOR_LENGTH;
});
/// Get the boolean value of a boot argument `keys`,
/// or return `defaultval` if the argument is not present.
/// A key is considered to be false if its string value is exactly
/// "off", "0", or "false". Any other value (including empty) is returned
/// as true.
strict GetBool(struct {
key string:MAX_ARGS_NAME_LENGTH;
defaultval bool;
}) -> (struct {
value bool;
});
/// Get the boolean values of a list of boot arguments `keys.key`,
/// or return `keys.defaultval` for each if not present.
strict GetBools(struct {
keys vector<BoolPair>:MAX_ARGS_VECTOR_LENGTH;
}) -> (struct {
values vector<bool>:MAX_ARGS_VECTOR_LENGTH;
});
/// Get all boot arguments with keys starting with
/// `prefix`. Returns a vector with strings of the form 'key=value'.
/// TODO(https://fxbug.dev/42108659) - remove Collect once boot arguments have been componentised.
strict Collect(struct {
prefix string:MAX_ARGS_NAME_LENGTH;
}) -> (struct {
results vector<string:MAX_ARGS_COLLECT_LENGTH>:MAX_ARGS_VECTOR_LENGTH;
});
};