* drop typedef device_t

* rename magic device callbacks to phases
* drop obsolete printk_* macros
* add some prototypes to lar.h

Signed-off-by: Ronald G. Minnich <rminnich@gmail.com> 
Acked-by: Stefan Reinauer <stepan@coresystems.de>



git-svn-id: svn://coreboot.org/repository/LinuxBIOSv3@74 f3766cd6-281f-0410-b1cd-43a5c92072e9
This commit is contained in:
Stefan Reinauer 2007-02-22 21:18:02 +00:00
parent af8c57a00e
commit d0d2aa1b43
5 changed files with 73 additions and 145 deletions

View file

@ -43,103 +43,5 @@ extern struct console_driver console_drivers[];
extern struct console_driver econsole_drivers[];
extern int console_loglevel;
int do_printk(int msg_level, const char *fmt, ...);
#define printk_emerg(fmt, arg...) do_printk(BIOS_EMERG ,fmt, ##arg)
#define printk_alert(fmt, arg...) do_printk(BIOS_ALERT ,fmt, ##arg)
#define printk_crit(fmt, arg...) do_printk(BIOS_CRIT ,fmt, ##arg)
#define printk_err(fmt, arg...) do_printk(BIOS_ERR ,fmt, ##arg)
#define printk_warning(fmt, arg...) do_printk(BIOS_WARNING ,fmt, ##arg)
#define printk_notice(fmt, arg...) do_printk(BIOS_NOTICE ,fmt, ##arg)
#define printk_info(fmt, arg...) do_printk(BIOS_INFO ,fmt, ##arg)
#define printk_debug(fmt, arg...) do_printk(BIOS_DEBUG ,fmt, ##arg)
#define printk_spew(fmt, arg...) do_printk(BIOS_SPEW ,fmt, ##arg)
#if MAXIMUM_CONSOLE_LOGLEVEL <= BIOS_EMERG
#undef printk_emerg
#define printk_emerg(fmt, arg...) do {} while(0)
#endif
#if MAXIMUM_CONSOLE_LOGLEVEL <= BIOS_ALERT
#undef printk_alert
#define printk_alert(fmt, arg...) do {} while(0)
#endif
#if MAXIMUM_CONSOLE_LOGLEVEL <= BIOS_CRIT
#undef printk_crit
#define printk_crit(fmt, arg...) do {} while(0)
#endif
#if MAXIMUM_CONSOLE_LOGLEVEL <= BIOS_ERR
#undef printk_err
#define printk_err(fmt, arg...) do {} while(0)
#endif
#if MAXIMUM_CONSOLE_LOGLEVEL <= BIOS_WARNING
#undef printk_warning
#define printk_warning(fmt, arg...) do {} while(0)
#endif
#if MAXIMUM_CONSOLE_LOGLEVEL <= BIOS_NOTICE
#undef printk_notice
#define printk_notice(fmt, arg...) do {} while(0)
#endif
#if MAXIMUM_CONSOLE_LOGLEVEL <= BIOS_INFO
#undef printk_info
#define printk_info(fmt, arg...) do {} while(0)
#endif
#if MAXIMUM_CONSOLE_LOGLEVEL <= BIOS_DEBUG
#undef printk_debug
#define printk_debug(fmt, arg...) do {} while(0)
#endif
#if MAXIMUM_CONSOLE_LOGLEVEL <= BIOS_SPEW
#undef printk_spew
#define printk_spew(fmt, arg...) do {} while(0)
#endif
#define print_emerg(STR) printk_emerg ("%s", (STR))
#define print_alert(STR) printk_alert ("%s", (STR))
#define print_crit(STR) printk_crit ("%s", (STR))
#define print_err(STR) printk_err ("%s", (STR))
#define print_warning(STR) printk_warning("%s", (STR))
#define print_notice(STR) printk_notice ("%s", (STR))
#define print_info(STR) printk_info ("%s", (STR))
#define print_debug(STR) printk_debug ("%s", (STR))
#define print_spew(STR) printk_spew ("%s", (STR))
#define print_emerg_char(CH) printk_emerg ("%c", (CH))
#define print_alert_char(CH) printk_alert ("%c", (CH))
#define print_crit_char(CH) printk_crit ("%c", (CH))
#define print_err_char(CH) printk_err ("%c", (CH))
#define print_warning_char(CH) printk_warning("%c", (CH))
#define print_notice_char(CH) printk_notice ("%c", (CH))
#define print_info_char(CH) printk_info ("%c", (CH))
#define print_debug_char(CH) printk_debug ("%c", (CH))
#define print_spew_char(CH) printk_spew ("%c", (CH))
#define print_emerg_hex8(HEX) printk_emerg ("%02x", (HEX))
#define print_alert_hex8(HEX) printk_alert ("%02x", (HEX))
#define print_crit_hex8(HEX) printk_crit ("%02x", (HEX))
#define print_err_hex8(HEX) printk_err ("%02x", (HEX))
#define print_warning_hex8(HEX) printk_warning("%02x", (HEX))
#define print_notice_hex8(HEX) printk_notice ("%02x", (HEX))
#define print_info_hex8(HEX) printk_info ("%02x", (HEX))
#define print_debug_hex8(HEX) printk_debug ("%02x", (HEX))
#define print_spew_hex8(HEX) printk_spew ("%02x", (HEX))
#define print_emerg_hex16(HEX) printk_emerg ("%04x", (HEX))
#define print_alert_hex16(HEX) printk_alert ("%04x", (HEX))
#define print_crit_hex16(HEX) printk_crit ("%04x", (HEX))
#define print_err_hex16(HEX) printk_err ("%04x", (HEX))
#define print_warning_hex16(HEX) printk_warning("%04x", (HEX))
#define print_notice_hex16(HEX) printk_notice ("%04x", (HEX))
#define print_info_hex16(HEX) printk_info ("%04x", (HEX))
#define print_debug_hex16(HEX) printk_debug ("%04x", (HEX))
#define print_spew_hex16(HEX) printk_spew ("%04x", (HEX))
#define print_emerg_hex32(HEX) printk_emerg ("%08x", (HEX))
#define print_alert_hex32(HEX) printk_alert ("%08x", (HEX))
#define print_crit_hex32(HEX) printk_crit ("%08x", (HEX))
#define print_err_hex32(HEX) printk_err ("%08x", (HEX))
#define print_warning_hex32(HEX) printk_warning("%08x", (HEX))
#define print_notice_hex32(HEX) printk_notice ("%08x", (HEX))
#define print_info_hex32(HEX) printk_info ("%08x", (HEX))
#define print_debug_hex32(HEX) printk_debug ("%08x", (HEX))
#define print_spew_hex32(HEX) printk_spew ("%08x", (HEX))
#endif /* CONSOLE_CONSOLE_H_ */

View file

@ -23,7 +23,6 @@
struct device;
typedef struct device * device_t;
struct pci_operations;
struct pci_bus_operations;
struct smbus_bus_operations;
@ -36,15 +35,35 @@ struct chip_operations {
struct bus;
/* we are moving from the confusing naming scheme to a numbering scheme. We are hoping
* this makes it easier for people to know the order of operations.
*/
struct device_operations {
void (*read_resources)(device_t dev);
void (*set_resources)(device_t dev);
void (*enable_resources)(device_t dev);
void (*init)(device_t dev);
unsigned int (*scan_bus)(device_t bus, unsigned int max);
void (*enable)(device_t dev);
void (*set_link)(device_t dev, unsigned int link);
// void (*enable)(struct device * dev);
/* for now, we leave these, since they seem generic */
void (*set_link)(struct device * dev, unsigned int link);
void (*reset_bus)(struct bus *bus);
/* phase1 is called ONLY if you CAN NEVER use printk. Only very early console needs this now */
void (*phase1)(struct device * dev);
/* phase 2 is for any magic you have to do before the busses are scanned */
void (*phase2)(struct device * dev);
/* phase 3 is for scanning the bus, if needed. */
unsigned int (*phase3)(struct device * bus, unsigned int max);
/* typically used by phase4 */
/* again, if we never use this anywhere else, we may change the names */
void (*phase4_read_resources)(struct device * dev);
void (*phase4_set_resources)(struct device * dev);
/* phase 5: enable devices */
void (*phase5)(struct device * dev);
/* phase 6: any post-setup device initialization that might be needed */
void (*phase6)();
const struct pci_operations *ops_pci;
const struct smbus_bus_operations *ops_smbus_bus;
const struct pci_bus_operations *ops_pci_bus;
@ -52,8 +71,8 @@ struct device_operations {
struct bus {
device_t dev; /* This bridge device */
device_t children; /* devices behind this bridge */
struct device * dev; /* This bridge device */
struct device * children; /* devices behind this bridge */
unsigned bridge_ctrl; /* Bridge control register */
unsigned char link; /* The index of this link */
unsigned char secondary; /* secondary bus number */
@ -73,8 +92,8 @@ struct bus {
struct device {
struct bus * bus; /* bus this device is on, for bridge
* devices, it is the up stream bus */
device_t sibling; /* next device on this bus */
device_t next; /* chain of all devices */
struct device * sibling; /* next device on this bus */
struct device * next; /* chain of all devices */
struct device_path path;
unsigned vendor;
@ -110,7 +129,7 @@ extern struct device *all_devices; /* list of all devices */
/* Generic device interface functions */
extern device_t alloc_dev(struct bus *parent, struct device_path *path);
extern struct device * alloc_dev(struct bus *parent, struct device_path *path);
extern void dev_enumerate(void);
extern void dev_configure(void);
extern void dev_enable(void);
@ -126,18 +145,18 @@ extern void assign_resources(struct bus *bus);
extern void enable_resources(struct device *dev);
extern void enumerate_static_device(void);
extern void enumerate_static_devices(void);
extern const char *dev_path(device_t dev);
extern const char *dev_path(struct device * dev);
const char *bus_path(struct bus *bus);
extern void dev_set_enabled(device_t dev, int enable);
extern void dev_set_enabled(struct device * dev, int enable);
extern void disable_children(struct bus *bus);
/* Helper functions */
device_t find_dev_path(struct bus *parent, struct device_path *path);
device_t alloc_find_dev(struct bus *parent, struct device_path *path);
device_t dev_find_device (unsigned int vendor, unsigned int device, device_t from);
device_t dev_find_class (unsigned int class, device_t from);
device_t dev_find_slot (unsigned int bus, unsigned int devfn);
device_t dev_find_slot_on_smbus (unsigned int bus, unsigned int addr);
struct device * find_dev_path(struct bus *parent, struct device_path *path);
struct device * alloc_find_dev(struct bus *parent, struct device_path *path);
struct device * dev_find_device (unsigned int vendor, unsigned int device, struct device * from);
struct device * dev_find_class (unsigned int class, struct device * from);
struct device * dev_find_slot (unsigned int bus, unsigned int devfn);
struct device * dev_find_slot_on_smbus (unsigned int bus, unsigned int addr);
/* Rounding for boundaries.
@ -147,11 +166,12 @@ device_t dev_find_slot_on_smbus (unsigned int bus, unsigned int addr);
#define DEVICE_MEM_ALIGN 4096
struct device_operations default_dev_ops_root;
extern void root_dev_read_resources(device_t dev);
extern void root_dev_set_resources(device_t dev);
extern unsigned int scan_static_bus(device_t bus, unsigned int max);
extern void enable_childrens_resources(device_t dev);
extern void root_dev_enable_resources(device_t dev);
extern unsigned int root_dev_scan_bus(device_t root, unsigned int max);
extern void root_dev_init(device_t dev);
extern void root_dev_read_resources(struct device * dev);
extern void root_dev_set_resources(struct device * dev);
extern unsigned int scan_static_bus(struct device * bus, unsigned int max);
extern void enable_childrens_resources(struct device * dev);
extern void root_dev_enable_resources(struct device * dev);
extern unsigned int root_dev_scan_bus(struct device * root, unsigned int max);
extern void root_dev_init(struct device * dev);
extern void dev_init(void);
#endif /* DEVICE_H */

View file

@ -41,7 +41,7 @@
/* Common pci operations without a standard interface */
struct pci_operations {
/* set the Subsystem IDs for the PCI device */
void (*set_subsystem)(device_t dev, unsigned vendor, unsigned device);
void (*set_subsystem)(struct device * dev, unsigned vendor, unsigned device);
};
/* Common pci bus operations */
@ -75,30 +75,30 @@ extern struct pci_driver epci_drivers[];
extern struct device_operations default_pci_ops_dev;
extern struct device_operations default_pci_ops_bus;
void pci_dev_read_resources(device_t dev);
void pci_bus_read_resources(device_t dev);
void pci_dev_set_resources(device_t dev);
void pci_dev_enable_resources(device_t dev);
void pci_bus_enable_resources(device_t dev);
void pci_dev_read_resources(struct device * dev);
void pci_bus_read_resources(struct device * dev);
void pci_dev_set_resources(struct device * dev);
void pci_dev_enable_resources(struct device * dev);
void pci_bus_enable_resources(struct device * dev);
void pci_bus_reset(struct bus *bus);
device_t pci_probe_dev(device_t dev, struct bus *bus, unsigned devfn);
unsigned int do_pci_scan_bridge(device_t bus, unsigned int max,
struct device * pci_probe_dev(struct device * dev, struct bus *bus, unsigned devfn);
unsigned int do_pci_scan_bridge(struct device * bus, unsigned int max,
unsigned int (*do_scan_bus)(struct bus *bus,
unsigned min_devfn, unsigned max_devfn, unsigned int max));
unsigned int pci_scan_bridge(device_t bus, unsigned int max);
unsigned int pci_scan_bridge(struct device * bus, unsigned int max);
unsigned int pci_scan_bus(struct bus *bus, unsigned min_devfn, unsigned max_devfn, unsigned int max);
u8 pci_moving_config8(struct device *dev, unsigned reg);
u16 pci_moving_config16(struct device *dev, unsigned reg);
u32 pci_moving_config32(struct device *dev, unsigned reg);
unsigned pci_find_next_capability(device_t dev, unsigned cap, unsigned last);
unsigned pci_find_capability(device_t dev, unsigned cap);
unsigned pci_find_next_capability(struct device * dev, unsigned cap, unsigned last);
unsigned pci_find_capability(struct device * dev, unsigned cap);
struct resource *pci_get_resource(struct device *dev, unsigned long index);
void pci_dev_set_subsystem(device_t dev, unsigned vendor, unsigned device);
void pci_dev_set_subsystem(struct device * dev, unsigned vendor, unsigned device);
#define PCI_IO_BRIDGE_ALIGN 4096
#define PCI_MEM_BRIDGE_ALIGN (1024*1024)
static inline const struct pci_operations *ops_pci(device_t dev)
static inline const struct pci_operations *ops_pci(struct device * dev)
{
const struct pci_operations *pops;
pops = 0;

View file

@ -20,11 +20,11 @@
#include <arch/types.h>
#include <device/device.h>
u8 pci_read_config8(device_t dev, unsigned where);
u16 pci_read_config16(device_t dev, unsigned where);
u32 pci_read_config32(device_t dev, unsigned where);
void pci_write_config8(device_t dev, unsigned where, u8 val);
void pci_write_config16(device_t dev, unsigned where, u16 val);
void pci_write_config32(device_t dev, unsigned where, u32 val);
u8 pci_read_config8(struct device * dev, unsigned where);
u16 pci_read_config16(struct device * dev, unsigned where);
u32 pci_read_config32(struct device * dev, unsigned where);
void pci_write_config8(struct device * dev, unsigned where, u8 val);
void pci_write_config16(struct device * dev, unsigned where, u16 val);
void pci_write_config32(struct device * dev, unsigned where, u32 val);
#endif /* PCI_OPS_H */

View file

@ -36,3 +36,9 @@ struct mem_file {
void *start;
int len;
};
/* prototypes */
int find_file(struct mem_file *archive, char *filename, struct mem_file *result);
int copy_file(struct mem_file *archive, char *filename, void *where);
int run_file(struct mem_file *archive, char *filename, void *where);