From 5fd83771641d15c418f747bd343ba6738d3875f7 Mon Sep 17 00:00:00 2001 From: Cameron Katri Date: Sun, 9 May 2021 14:20:58 -0400 Subject: Import macOS userland adv_cmds-176 basic_cmds-55 bootstrap_cmds-116.100.1 developer_cmds-66 diskdev_cmds-667.40.1 doc_cmds-53.60.1 file_cmds-321.40.3 mail_cmds-35 misc_cmds-34 network_cmds-606.40.1 patch_cmds-17 remote_cmds-63 shell_cmds-216.60.1 system_cmds-880.60.2 text_cmds-106 --- system_cmds/gcore.tproj/loader_additions.h | 103 +++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 system_cmds/gcore.tproj/loader_additions.h (limited to 'system_cmds/gcore.tproj/loader_additions.h') diff --git a/system_cmds/gcore.tproj/loader_additions.h b/system_cmds/gcore.tproj/loader_additions.h new file mode 100644 index 0000000..16cf5b5 --- /dev/null +++ b/system_cmds/gcore.tproj/loader_additions.h @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2015 Apple Inc. All rights reserved. + */ + +#include + +#ifndef _LOADER_ADDITIONS_H +#define _LOADER_ADDITIONS_H + +/* + * Something like this should end up in + */ + +#define proto_LC_COREINFO 0x140 /* unofficial value!! */ + +#define proto_CORETYPE_KERNEL 1 +#define proto_CORETYPE_USER 2 +#define proto_CORETYPE_IBOOT 3 + +struct proto_coreinfo_command { + uint32_t cmd; /* LC_COREINFO */ + uint32_t cmdsize; /* total size of this command */ + uint32_t version; /* currently 1 */ + uint16_t type; /* CORETYPE_KERNEL, CORETYPE_USER etc. */ + uint16_t pageshift; /* log2 host pagesize */ + /* content & interpretation depends on 'type' field */ + uint64_t address; /* load address of "main binary" */ + uint8_t uuid[16]; /* uuid of "main binary" */ + uint64_t dyninfo; /* dynamic modules info */ +}; + +#define proto_LC_FILEREF 0x141 /* unofficial value! */ + +#define FREF_ID_SHIFT 0 +#define FREF_ID_MASK 0x7 /* up to 8 flavors */ + +typedef enum { + kFREF_ID_NONE = 0, /* file has no available verifying ID */ + kFREF_ID_UUID = 1, /* file has an associated UUID */ + kFREF_ID_MTIMESPEC_LE = 2, /* file has a specific mtime */ + /* one day: file has a computed hash? */ +} fref_type_t; + +#define FREF_ID_TYPE(f) ((fref_type_t)(((f) >> FREF_ID_SHIFT) & FREF_ID_MASK)) +#define FREF_MAKE_FLAGS(t) (((t) & FREF_ID_MASK) << FREF_ID_SHIFT) + +struct proto_fileref_command { + uint32_t cmd; /* LC_FILEREF */ + uint32_t cmdsize; + union lc_str filename; /* filename these bits come from */ + uint8_t id[16]; /* uuid, size or hash etc. */ + uint64_t vmaddr; /* memory address of this segment */ + uint64_t vmsize; /* memory size of this segment */ + uint64_t fileoff; /* file offset of this segment */ + uint64_t filesize; /* amount to map from the file */ + vm_prot_t maxprot; /* maximum VM protection */ + vm_prot_t prot; /* current VM protection */ + uint32_t flags; + uint8_t share_mode; /* SM_COW etc. */ + uint8_t purgable; /* VM_PURGABLE_NONVOLATILE etc. */ + uint8_t tag; /* VM_MEMORY_MALLOC etc. */ + uint8_t extp; /* external pager */ +}; + +#define proto_LC_COREDATA 0x142 /* unofficial value! */ + +/* + * These are flag bits for the segment_command 'flags' field. + */ + +#define COMP_ALG_MASK 0x7 +/* carve out 3 bits for an enum i.e. allow for 7 flavors */ +#define COMP_ALG_SHIFT 4 /* (bottom 4 bits taken) */ + +/* zero -> no compression */ +typedef enum { + kCOMP_NONE = 0, + kCOMP_LZ4 = 1, /* 0x100 */ + kCOMP_ZLIB = 2, /* 0x205 */ + kCOMP_LZMA = 3, /* 0x306 */ + kCOMP_LZFSE = 4, /* 0x801 */ +} compression_flavor_t; + +#define COMP_ALG_TYPE(f) ((compression_flavor_t)((f) >> COMP_ALG_SHIFT) & COMP_ALG_MASK) +#define COMP_MAKE_FLAGS(t) (((t) & COMP_ALG_MASK) << COMP_ALG_SHIFT) + +struct proto_coredata_command { + uint32_t cmd; /* LC_COREDATA */ + uint32_t cmdsize; + uint64_t vmaddr; /* memory address of this segment */ + uint64_t vmsize; /* memory size of this segment */ + uint64_t fileoff; /* file offset of this segment */ + uint64_t filesize; /* amount to map from the file */ + vm_prot_t maxprot; /* maximum VM protection */ + vm_prot_t prot; /* current VM protection */ + uint32_t flags; + uint8_t share_mode; /* SM_COW etc. */ + uint8_t purgable; /* VM_PURGABLE_NONVOLATILE etc. */ + uint8_t tag; /* VM_MEMORY_MALLOC etc. */ + uint8_t extp; /* external pager */ +}; + +#endif /* _LOADER_ADDITIONS_H */ -- cgit v1.2.3-56-ge451