git: 52abe2166d06 - stable/12 - loader: cstyle cleanup of bootstrap.h
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 08 Oct 2021 06:11:14 UTC
The branch stable/12 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=52abe2166d06f34f105f843fe12ab6d51dd0ac23 commit 52abe2166d06f34f105f843fe12ab6d51dd0ac23 Author: Toomas Soome <tsoome@FreeBSD.org> AuthorDate: 2020-11-08 09:35:41 +0000 Commit: Kyle Evans <kevans@FreeBSD.org> CommitDate: 2021-10-08 05:24:27 +0000 loader: cstyle cleanup of bootstrap.h No functional changes intended. (cherry picked from commit 90b307a8975327b195e4549b9b0745bcc684f646) --- stand/common/bootstrap.h | 252 +++++++++++++++++++++++++---------------------- 1 file changed, 133 insertions(+), 119 deletions(-) diff --git a/stand/common/bootstrap.h b/stand/common/bootstrap.h index 809859c276b9..af71fcb78436 100644 --- a/stand/common/bootstrap.h +++ b/stand/common/bootstrap.h @@ -40,11 +40,11 @@ typedef int (bootblk_cmd_t)(int argc, char *argv[]); #define COMMAND_ERRBUFSZ (256) extern const char *command_errmsg; extern char command_errbuf[COMMAND_ERRBUFSZ]; -#define CMD_OK 0 -#define CMD_WARN 1 -#define CMD_ERROR 2 -#define CMD_CRIT 3 -#define CMD_FATAL 4 +#define CMD_OK 0 +#define CMD_WARN 1 +#define CMD_ERROR 2 +#define CMD_CRIT 3 +#define CMD_FATAL 4 /* interp.c */ void interact(void); @@ -52,9 +52,9 @@ void interp_emit_prompt(void); int interp_builtin_cmd(int argc, char *argv[]); /* Called by interp.c for interp_*.c embedded interpreters */ -int interp_include(const char *filename); /* Execute commands from filename */ -void interp_init(void); /* Initialize interpreater */ -int interp_run(const char *line); /* Run a single command */ +int interp_include(const char *); /* Execute commands from filename */ +void interp_init(void); /* Initialize interpreater */ +int interp_run(const char *); /* Run a single command */ /* interp_backslash.c */ char *backslash(const char *str); @@ -88,64 +88,70 @@ int bcache_strategy(void *devdata, int rw, daddr_t blk, size_t size, */ struct bcache_devdata { - int (*dv_strategy)(void *devdata, int rw, daddr_t blk, - size_t size, char *buf, size_t *rsize); - void *dv_devdata; - void *dv_cache; + int (*dv_strategy)(void *, int, daddr_t, size_t, char *, size_t *); + void *dv_devdata; + void *dv_cache; }; /* * Modular console support. */ -struct console +struct console { - const char *c_name; - const char *c_desc; - int c_flags; -#define C_PRESENTIN (1<<0) /* console can provide input */ -#define C_PRESENTOUT (1<<1) /* console can provide output */ -#define C_ACTIVEIN (1<<2) /* user wants input from console */ -#define C_ACTIVEOUT (1<<3) /* user wants output to console */ + const char *c_name; + const char *c_desc; + int c_flags; +#define C_PRESENTIN (1<<0) /* console can provide input */ +#define C_PRESENTOUT (1<<1) /* console can provide output */ +#define C_ACTIVEIN (1<<2) /* user wants input from console */ +#define C_ACTIVEOUT (1<<3) /* user wants output to console */ #define C_WIDEOUT (1<<4) /* c_out routine groks wide chars */ - void (* c_probe)(struct console *cp); /* set c_flags to match hardware */ - int (* c_init)(int arg); /* reinit XXX may need more args */ - void (* c_out)(int c); /* emit c */ - int (* c_in)(void); /* wait for and return input */ - int (* c_ready)(void); /* return nonzer if input waiting */ + + /* set c_flags to match hardware */ + void (* c_probe)(struct console *cp); + /* reinit XXX may need more args */ + int (* c_init)(int arg); + /* emit c */ + void (* c_out)(int c); + int (* c_in)(void); + /* wait for and return input */ + /* return nonzer if input waiting */ + int (* c_ready)(void); }; -extern struct console *consoles[]; -void cons_probe(void); +extern struct console *consoles[]; +void cons_probe(void); /* * Plug-and-play enumerator/configurator interface. */ -struct pnphandler +struct pnphandler { - const char *pp_name; /* handler/bus name */ - void (* pp_enumerate)(void); /* enumerate PnP devices, add to chain */ + const char *pp_name; /* handler/bus name */ + void (*pp_enumerate)(void); /* enumerate PnP devices, add to chain */ }; struct pnpident { - char *id_ident; /* ASCII identifier, actual format varies with bus/handler */ - STAILQ_ENTRY(pnpident) id_link; + /* ASCII identifier, actual format varies with bus/handler */ + char *id_ident; + STAILQ_ENTRY(pnpident) id_link; }; struct pnpinfo { - char *pi_desc; /* ASCII description, optional */ - int pi_revision; /* optional revision (or -1) if not supported */ - char *pi_module; /* module/args nominated to handle device */ - int pi_argc; /* module arguments */ - char **pi_argv; - struct pnphandler *pi_handler; /* handler which detected this device */ - STAILQ_HEAD(,pnpident) pi_ident; /* list of identifiers */ - STAILQ_ENTRY(pnpinfo) pi_link; + char *pi_desc; /* ASCII description, optional */ + int pi_revision; /* optional revision (or -1) if not supported */ + char *pi_module; /* module/args nominated to handle device */ + int pi_argc; /* module arguments */ + char **pi_argv; + struct pnphandler *pi_handler; /* handler which detected this device */ + STAILQ_HEAD(, pnpident) pi_ident; /* list of identifiers */ + STAILQ_ENTRY(pnpinfo) pi_link; }; STAILQ_HEAD(pnpinfo_stql, pnpinfo); -extern struct pnphandler *pnphandlers[]; /* provided by MD code */ +extern struct pnphandler *pnphandlers[]; /* provided by MD code */ void pnp_addident(struct pnpinfo *pi, char *ident); struct pnpinfo *pnp_allocinfo(void); @@ -158,7 +164,7 @@ char *pnp_eisaformat(uint8_t *data); * == 0 - Maybe ISA, search for read data port * > 0 - ISA in system, value is read data port address */ -extern int isapnp_readport; +extern int isapnp_readport; /* * Version information @@ -179,12 +185,12 @@ const char bootprog_interp[] = "$Interpreter:" interpstr * Metadata are allocated on our heap, and copied into kernel space * before executing the kernel. */ -struct file_metadata +struct file_metadata { - size_t md_size; - uint16_t md_type; - struct file_metadata *md_next; - char md_data[1]; /* data are immediately appended */ + size_t md_size; + uint16_t md_type; + struct file_metadata *md_next; + char md_data[1]; /* data are immediately appended */ }; struct preloaded_file; @@ -192,11 +198,11 @@ struct mod_depend; struct kernel_module { - char *m_name; /* module name */ - int m_version; /* module version */ -/* char *m_args;*/ /* arguments for the module */ - struct preloaded_file *m_fp; - struct kernel_module *m_next; + char *m_name; /* module name */ + int m_version; /* module version */ + /* char *m_args; */ /* arguments for the module */ + struct preloaded_file *m_fp; + struct kernel_module *m_next; }; /* @@ -210,47 +216,54 @@ struct kernel_module */ struct preloaded_file { - char *f_name; /* file name */ - char *f_type; /* verbose file type, eg 'ELF kernel', 'pnptable', etc. */ - char *f_args; /* arguments for the file */ - struct file_metadata *f_metadata; /* metadata that will be placed in the module directory */ - int f_loader; /* index of the loader that read the file */ - vm_offset_t f_addr; /* load address */ - size_t f_size; /* file size */ - struct kernel_module *f_modules; /* list of modules if any */ - struct preloaded_file *f_next; /* next file */ + char *f_name; /* file name */ + char *f_type; /* verbose file type, eg 'ELF kernel', 'pnptable', etc. */ + char *f_args; /* arguments for the file */ + /* metadata that will be placed in the module directory */ + struct file_metadata *f_metadata; + int f_loader; /* index of the loader that read the file */ + vm_offset_t f_addr; /* load address */ + size_t f_size; /* file size */ + struct kernel_module *f_modules; /* list of modules if any */ + struct preloaded_file *f_next; /* next file */ }; struct file_format { - /* Load function must return EFTYPE if it can't handle the module supplied */ - int (* l_load)(char *filename, uint64_t dest, struct preloaded_file **result); - /* Only a loader that will load a kernel (first module) should have an exec handler */ - int (* l_exec)(struct preloaded_file *mp); + /* + * Load function must return EFTYPE if it can't handle + * the module supplied + */ + int (*l_load)(char *, uint64_t, struct preloaded_file **); + /* + * Only a loader that will load a kernel (first module) + * should have an exec handler + */ + int (*l_exec)(struct preloaded_file *); }; -extern struct file_format *file_formats[]; /* supplied by consumer */ -extern struct preloaded_file *preloaded_files; +extern struct file_format *file_formats[]; /* supplied by consumer */ +extern struct preloaded_file *preloaded_files; -int mod_load(char *name, struct mod_depend *verinfo, int argc, char *argv[]); -int mod_loadkld(const char *name, int argc, char *argv[]); -void unload(void); +int mod_load(char *name, struct mod_depend *verinfo, int argc, char *argv[]); +int mod_loadkld(const char *name, int argc, char *argv[]); +void unload(void); struct preloaded_file *file_alloc(void); struct preloaded_file *file_findfile(const char *name, const char *type); struct file_metadata *file_findmetadata(struct preloaded_file *fp, int type); struct preloaded_file *file_loadraw(const char *name, char *type, int insert); void file_discard(struct preloaded_file *fp); -void file_addmetadata(struct preloaded_file *fp, int type, size_t size, void *p); -int file_addmodule(struct preloaded_file *fp, char *modname, int version, - struct kernel_module **newmp); +void file_addmetadata(struct preloaded_file *, int, size_t, void *); +int file_addmodule(struct preloaded_file *, char *, int, + struct kernel_module **); void file_removemetadata(struct preloaded_file *fp); /* MI module loaders */ #ifdef __elfN /* Relocation types. */ -#define ELF_RELOC_REL 1 -#define ELF_RELOC_RELA 2 +#define ELF_RELOC_REL 1 +#define ELF_RELOC_RELA 2 /* Relocation offset for some architectures */ extern uint64_t __elfN(relocation_offset); @@ -258,35 +271,33 @@ extern uint64_t __elfN(relocation_offset); struct elf_file; typedef Elf_Addr (symaddr_fn)(struct elf_file *ef, Elf_Size symidx); -int __elfN(loadfile)(char *filename, uint64_t dest, struct preloaded_file **result); -int __elfN(obj_loadfile)(char *filename, uint64_t dest, - struct preloaded_file **result); +int __elfN(loadfile)(char *, uint64_t, struct preloaded_file **); +int __elfN(obj_loadfile)(char *, uint64_t, struct preloaded_file **); int __elfN(reloc)(struct elf_file *ef, symaddr_fn *symaddr, const void *reldata, int reltype, Elf_Addr relbase, Elf_Addr dataaddr, void *data, size_t len); -int __elfN(loadfile_raw)(char *filename, uint64_t dest, - struct preloaded_file **result, int multiboot); -int __elfN(load_modmetadata)(struct preloaded_file *fp, uint64_t dest); +int __elfN(loadfile_raw)(char *, uint64_t, struct preloaded_file **, int); +int __elfN(load_modmetadata)(struct preloaded_file *, uint64_t); #endif /* - * Support for commands + * Support for commands */ -struct bootblk_command +struct bootblk_command { const char *c_name; const char *c_desc; bootblk_cmd_t *c_fn; }; -#define COMMAND_SET(tag, key, desc, func) \ +#define COMMAND_SET(tag, key, desc, func) \ static bootblk_cmd_t func; \ static struct bootblk_command _cmd_ ## tag = { key, desc, func }; \ DATA_SET(Xcommand_set, _cmd_ ## tag) SET_DECLARE(Xcommand_set, struct bootblk_command); -/* +/* * The intention of the architecture switch is to provide a convenient * encapsulation of the interface between the bootstrap MI and MD code. * MD code may selectively populate the switch at runtime based on the @@ -294,49 +305,52 @@ SET_DECLARE(Xcommand_set, struct bootblk_command); */ struct arch_switch { - /* Automatically load modules as required by detected hardware */ - int (*arch_autoload)(void); - /* Locate the device for (name), return pointer to tail in (*path) */ - int (*arch_getdev)(void **dev, const char *name, const char **path); - /* Copy from local address space to module address space, similar to bcopy() */ - ssize_t (*arch_copyin)(const void *src, vm_offset_t dest, - const size_t len); - /* Copy to local address space from module address space, similar to bcopy() */ - ssize_t (*arch_copyout)(const vm_offset_t src, void *dest, - const size_t len); - /* Read from file to module address space, same semantics as read() */ - ssize_t (*arch_readin)(readin_handle_t fd, vm_offset_t dest, - const size_t len); - /* Perform ISA byte port I/O (only for systems with ISA) */ - int (*arch_isainb)(int port); - void (*arch_isaoutb)(int port, int value); - - /* - * Interface to adjust the load address according to the "object" - * being loaded. - */ - uint64_t (*arch_loadaddr)(u_int type, void *data, uint64_t addr); + /* Automatically load modules as required by detected hardware */ + int (*arch_autoload)(void); + /* Locate the device for (name), return pointer to tail in (*path) */ + int (*arch_getdev)(void **dev, const char *name, const char **path); + /* + * Copy from local address space to module address space, + * similar to bcopy() + */ + ssize_t (*arch_copyin)(const void *, vm_offset_t, const size_t); + /* + * Copy to local address space from module address space, + * similar to bcopy() + */ + ssize_t (*arch_copyout)(const vm_offset_t, void *, const size_t); + /* Read from file to module address space, same semantics as read() */ + ssize_t (*arch_readin)(readin_handle_t, vm_offset_t, const size_t); + /* Perform ISA byte port I/O (only for systems with ISA) */ + int (*arch_isainb)(int port); + void (*arch_isaoutb)(int port, int value); + + /* + * Interface to adjust the load address according to the "object" + * being loaded. + */ + uint64_t (*arch_loadaddr)(u_int type, void *data, uint64_t addr); #define LOAD_ELF 1 /* data points to the ELF header. */ #define LOAD_RAW 2 /* data points to the file name. */ - /* - * Interface to inform MD code about a loaded (ELF) segment. This - * can be used to flush caches and/or set up translations. - */ + /* + * Interface to inform MD code about a loaded (ELF) segment. This + * can be used to flush caches and/or set up translations. + */ #ifdef __elfN - void (*arch_loadseg)(Elf_Ehdr *eh, Elf_Phdr *ph, uint64_t delta); + void (*arch_loadseg)(Elf_Ehdr *eh, Elf_Phdr *ph, uint64_t delta); #else - void (*arch_loadseg)(void *eh, void *ph, uint64_t delta); + void (*arch_loadseg)(void *eh, void *ph, uint64_t delta); #endif - /* Probe ZFS pool(s), if needed. */ - void (*arch_zfs_probe)(void); + /* Probe ZFS pool(s), if needed. */ + void (*arch_zfs_probe)(void); - /* Return the hypervisor name/type or NULL if not virtualized. */ - const char *(*arch_hypervisor)(void); + /* Return the hypervisor name/type or NULL if not virtualized. */ + const char *(*arch_hypervisor)(void); - /* For kexec-type loaders, get ksegment structure */ - void (*arch_kexec_kseg_get)(int *nseg, void **kseg); + /* For kexec-type loaders, get ksegment structure */ + void (*arch_kexec_kseg_get)(int *nseg, void **kseg); }; extern struct arch_switch archsw;