Compare commits
3 Commits
4dd59ef79a
...
57b1d338ac
| Author | SHA1 | Date | |
|---|---|---|---|
| 57b1d338ac | |||
| fd8f59649e | |||
| 301b5b6e6c |
@@ -3,10 +3,10 @@
|
|||||||
#define __ZINNIA_UAPI_ARCHCTL_H
|
#define __ZINNIA_UAPI_ARCHCTL_H
|
||||||
|
|
||||||
#ifdef __x86_64__
|
#ifdef __x86_64__
|
||||||
#define __ARCHCTL_SET_FSBASE 1
|
#define __ARCHCTL_SET_FSBASE 0
|
||||||
#define __ARCHCTL_SET_GSBASE 2
|
#define __ARCHCTL_SET_GSBASE 1
|
||||||
#define __ARCHCTL_GET_FSBASE 3
|
#define __ARCHCTL_GET_FSBASE 2
|
||||||
#define __ARCHCTL_GET_GSBASE 4
|
#define __ARCHCTL_GET_GSBASE 3
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
/* SPDX-License-Identifier: Unlicense */
|
||||||
|
#ifndef __ZINNIA_UAPI_DIRENT_H
|
||||||
|
#define __ZINNIA_UAPI_DIRENT_H
|
||||||
|
|
||||||
|
#include <uapi/types.h>
|
||||||
|
|
||||||
|
#define __DT_UNKNOWN 0
|
||||||
|
#define __DT_FIFO 1
|
||||||
|
#define __DT_CHR 2
|
||||||
|
#define __DT_DIR 4
|
||||||
|
#define __DT_BLK 6
|
||||||
|
#define __DT_REG 8
|
||||||
|
#define __DT_LNK 10
|
||||||
|
#define __DT_SOCK 12
|
||||||
|
#define __DT_WHT 14
|
||||||
|
|
||||||
|
struct __dirent {
|
||||||
|
__ino_t d_ino;
|
||||||
|
__off_t d_off;
|
||||||
|
uint16_t d_reclen;
|
||||||
|
uint8_t d_type;
|
||||||
|
char d_name[256];
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
/* SPDX-License-Identifier: Unlicense */
|
||||||
|
#ifndef __ZINNIA_UAPI_LIMITS_H
|
||||||
|
#define __ZINNIA_UAPI_LIMITS_H
|
||||||
|
|
||||||
|
#define __PATH_MAX 4096
|
||||||
|
#define __NAME_MAX 255
|
||||||
|
#define __SYMLINK_MAX 4096
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
/* SPDX-License-Identifier: Unlicense */
|
||||||
|
#ifndef __ZINNIA_UAPI_STATVFS_H
|
||||||
|
#define __ZINNIA_UAPI_STATVFS_H
|
||||||
|
|
||||||
|
#include <uapi/types.h>
|
||||||
|
|
||||||
|
#define __ST_RDONLY 1
|
||||||
|
#define __ST_NOSUID 2
|
||||||
|
#define __ST_MANDLOCK 64
|
||||||
|
|
||||||
|
struct __statvfs {
|
||||||
|
uintptr_t f_bsize;
|
||||||
|
uintptr_t f_frsize;
|
||||||
|
__fsblkcnt_t f_blocks;
|
||||||
|
__fsblkcnt_t f_bfree;
|
||||||
|
__fsblkcnt_t f_bavail;
|
||||||
|
__fsfilcnt_t f_files;
|
||||||
|
__fsfilcnt_t f_ffree;
|
||||||
|
__fsfilcnt_t f_favail;
|
||||||
|
uintptr_t f_fsid;
|
||||||
|
uintptr_t f_flag;
|
||||||
|
uintptr_t f_namemax;
|
||||||
|
char f_basetype[80];
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
+3
-2
@@ -3,9 +3,10 @@
|
|||||||
#define __ZINNIA_UAPI_UIO_H
|
#define __ZINNIA_UAPI_UIO_H
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
struct iovec {
|
struct __iovec {
|
||||||
void* base;
|
uintptr_t base;
|
||||||
size_t len;
|
size_t len;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
#include <zinnia/utils.h>
|
#include <zinnia/utils.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#define _CMDLINE_OPTION(x, opt_name, opt_desc, opt_func, opt_limit) \
|
#define _CMDLINE_OPTION(x, opt_name, opt_desc, opt_func) \
|
||||||
static const struct cmdline_option x = { \
|
static const struct cmdline_option x = { \
|
||||||
.name = opt_name, \
|
.name = opt_name, \
|
||||||
.desc = opt_desc, \
|
.desc = opt_desc, \
|
||||||
@@ -16,23 +16,12 @@
|
|||||||
void (*)(uintptr_t): CMDLINE_UINTPTR \
|
void (*)(uintptr_t): CMDLINE_UINTPTR \
|
||||||
), \
|
), \
|
||||||
.func = (void*)(opt_func), \
|
.func = (void*)(opt_func), \
|
||||||
.limit = (void*)(opt_limit) \
|
|
||||||
}; \
|
}; \
|
||||||
static_assert(_Generic( \
|
|
||||||
(opt_limit), \
|
|
||||||
const char**: true, \
|
|
||||||
const struct cmdline_range_int*: true, \
|
|
||||||
const struct cmdline_range_uint*: true, \
|
|
||||||
void*: true \
|
|
||||||
)); \
|
|
||||||
[[__used, __section(".cmdline")]] \
|
[[__used, __section(".cmdline")]] \
|
||||||
static const struct cmdline_option* CONCAT(x, _ptr) = &x
|
static const struct cmdline_option* CONCAT(x, _ptr) = &x
|
||||||
|
|
||||||
#define CMDLINE_OPTION(opt_name, opt_desc, opt_func) \
|
#define CMDLINE_OPTION(opt_name, opt_desc, opt_func) \
|
||||||
_CMDLINE_OPTION(UNIQUE_IDENT(cmdline_option), opt_name, opt_desc, opt_func, (void*)nullptr)
|
_CMDLINE_OPTION(UNIQUE_IDENT(cmdline_option), opt_name, opt_desc, opt_func)
|
||||||
|
|
||||||
#define CMDLINE_OPTION_RANGE(opt_name, opt_desc, opt_func, opt_values) \
|
|
||||||
_CMDLINE_OPTION(UNIQUE_IDENT(cmdline_option), opt_name, opt_desc, opt_func, opt_values)
|
|
||||||
|
|
||||||
enum cmdline_type {
|
enum cmdline_type {
|
||||||
CMDLINE_STRING,
|
CMDLINE_STRING,
|
||||||
@@ -55,16 +44,6 @@ struct cmdline_option {
|
|||||||
void (*func_uintptr)(uintptr_t value);
|
void (*func_uintptr)(uintptr_t value);
|
||||||
void* func;
|
void* func;
|
||||||
};
|
};
|
||||||
union {
|
|
||||||
const char** str_limit;
|
|
||||||
struct cmdline_range_int {
|
|
||||||
intptr_t min, max;
|
|
||||||
}* intptr_limit;
|
|
||||||
struct cmdline_range_uint {
|
|
||||||
uintptr_t min, max;
|
|
||||||
}* uintptr_limit;
|
|
||||||
void* limit;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Parses the command line and invokes all options.
|
// Parses the command line and invokes all options.
|
||||||
|
|||||||
+1
-1
@@ -56,7 +56,7 @@ cfg.set_quoted('ZINNIA_VERSION', meson.project_version())
|
|||||||
cfg.set_quoted('ZINNIA_ARCH', target_machine.cpu_family())
|
cfg.set_quoted('ZINNIA_ARCH', target_machine.cpu_family())
|
||||||
cfg.set_quoted('ZINNIA_COMPILER_ID', c_compiler.get_id() + ' ' + c_compiler.version())
|
cfg.set_quoted('ZINNIA_COMPILER_ID', c_compiler.get_id() + ' ' + c_compiler.version())
|
||||||
cfg.set_quoted('ZINNIA_LINKER_ID', c_compiler.get_linker_id())
|
cfg.set_quoted('ZINNIA_LINKER_ID', c_compiler.get_linker_id())
|
||||||
#
|
|
||||||
# Parse kernel config
|
# Parse kernel config
|
||||||
kv = import('keyval')
|
kv = import('keyval')
|
||||||
kconfig = kv.load(get_option('config_path'))
|
kconfig = kv.load(get_option('config_path'))
|
||||||
|
|||||||
+1
-41
@@ -65,44 +65,4 @@ if __name__ == "__main__":
|
|||||||
case 3:
|
case 3:
|
||||||
kind_str = "unsigned integer"
|
kind_str = "unsigned integer"
|
||||||
|
|
||||||
# Skip function pointer
|
print(f"- {name}:\t{desc} ({kind_str})")
|
||||||
|
|
||||||
# Allowed values
|
|
||||||
limit = ""
|
|
||||||
limit_ptr = int.from_bytes(option[32:][:SIZEOF_PTR], byteorder=ENDIAN)
|
|
||||||
|
|
||||||
if limit_ptr != 0:
|
|
||||||
elffile.seek(next(file.address_offsets(start=limit_ptr)))
|
|
||||||
match kind:
|
|
||||||
case 0:
|
|
||||||
limit = []
|
|
||||||
i = 0
|
|
||||||
while True:
|
|
||||||
ptr = next(file.address_offsets(start=limit_ptr + i * SIZEOF_PTR))
|
|
||||||
elffile.seek(ptr)
|
|
||||||
str_ptr = int.from_bytes(elffile.read(SIZEOF_PTR), byteorder=ENDIAN)
|
|
||||||
if str_ptr == 0:
|
|
||||||
break
|
|
||||||
|
|
||||||
strstr_off = next(file.address_offsets(start=str_ptr))
|
|
||||||
val = ""
|
|
||||||
elffile.seek(strstr_off)
|
|
||||||
while True:
|
|
||||||
b = int.from_bytes(elffile.read(1))
|
|
||||||
if b == 0:
|
|
||||||
break
|
|
||||||
val += chr(b)
|
|
||||||
i += 1
|
|
||||||
limit.append(val)
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
min = int.from_bytes(elffile.read(SIZEOF_PTR), byteorder=ENDIAN, signed=True)
|
|
||||||
max = int.from_bytes(elffile.read(SIZEOF_PTR), byteorder=ENDIAN)
|
|
||||||
limit = f"[{min}, {max}]"
|
|
||||||
|
|
||||||
case 3:
|
|
||||||
min = int.from_bytes(elffile.read(SIZEOF_PTR), byteorder=ENDIAN)
|
|
||||||
max = int.from_bytes(elffile.read(SIZEOF_PTR), byteorder=ENDIAN)
|
|
||||||
limit = f"[{min}, {max}]"
|
|
||||||
|
|
||||||
print(f"- {name}:\t{desc} ({kind_str}) {limit if len(limit) != 0 else ""}")
|
|
||||||
|
|||||||
Reference in New Issue
Block a user