device.h Source File

Back to the index.

device.h
Go to the documentation of this file.
1 #ifndef DEVICE_H
2 #define DEVICE_H
3 
4 /*
5  * Copyright (C) 2005-2010 Anders Gavare. All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  * 3. The name of the author may not be used to endorse or promote products
16  * derived from this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28  * SUCH DAMAGE.
29  *
30  *
31  * Device registry. (See device.c for more info.)
32  */
33 
34 #include "misc.h"
35 
36 struct machine;
37 struct pci_device;
38 
39 
40 struct devinit {
41  struct machine *machine;
42 
43  char *name; /* e.g. "cons" */
44  char *name2; /* e.g. "secondary serial port" */
45 
46  uint64_t addr; /* Device base address */
47  uint64_t addr2; /* Secondary address (optional) */
48  uint64_t len;
49 
51 
52  int in_use;
53  int addr_mult;
55 
56  void *return_ptr;
57 };
58 
59 struct device_entry {
60  char *name;
61  int (*initf)(struct devinit *);
62 };
63 
64 struct pci_entry {
65  char *name;
66  void (*initf)(struct machine *, struct memory *,
67  struct pci_device *);
68 };
69 
70 #define DEVINIT(name) int devinit_ ## name (struct devinit *devinit)
71 
72 /* autodev.c: (built automatically in the devices/ directory): */
73 void autodev_init(void);
74 
75 /* device.c: */
76 int device_register(const char *name, int (*initf)(struct devinit *));
77 struct device_entry *device_lookup(char *name);
78 int device_unregister(char *name);
79 void *device_add(struct machine *machine, const char *name_and_params);
80 void device_dumplist(void);
81 void device_set_exit_on_error(int exit_on_error);
82 void device_init(void);
83 
84 /* PCI stuff: (TODO: move somewhere else?) */
85 int pci_register(const char *name, void (*initf)(struct machine *, struct memory *,
86  struct pci_device *));
87 void (*pci_lookup_initf(const char *name))(struct machine *machine,
88  struct memory *mem, struct pci_device *pd);
89 
90 #endif /* DEVICE_H */
device_dumplist
void device_dumplist(void)
Definition: device.cc:408
device_add
void * device_add(struct machine *machine, const char *name_and_params)
Definition: device.cc:252
autodev_init
void autodev_init(void)
Definition: autodev.cc:150
memory
Definition: memory.h:75
pci_entry::initf
void(* initf)(struct machine *, struct memory *, struct pci_device *)
Definition: device.h:66
devinit::addr
uint64_t addr
Definition: device.h:46
devinit::machine
struct machine * machine
Definition: device.h:41
devinit::len
uint64_t len
Definition: device.h:48
devinit::addr2
uint64_t addr2
Definition: device.h:47
device_set_exit_on_error
void device_set_exit_on_error(int exit_on_error)
Definition: device.cc:433
pci_register
int pci_register(const char *name, void(*initf)(struct machine *, struct memory *, struct pci_device *))
Definition: device.cc:114
device_init
void device_init(void)
Definition: device.cc:447
devinit::interrupt_path
char * interrupt_path
Definition: device.h:50
device_unregister
int device_unregister(char *name)
Definition: device.cc:210
device_lookup
struct device_entry * device_lookup(char *name)
Definition: device.cc:162
misc.h
machine
Definition: machine.h:97
devinit::name
char * name
Definition: device.h:43
devinit::pci_little_endian
int pci_little_endian
Definition: device.h:54
devinit
Definition: device.h:40
device_register
int device_register(const char *name, int(*initf)(struct devinit *))
Definition: device.cc:89
device_entry
Definition: device.h:59
devinit::return_ptr
void * return_ptr
Definition: device.h:56
device_entry::name
char * name
Definition: device.h:60
pci_entry::name
char * name
Definition: device.h:65
devinit::name2
char * name2
Definition: device.h:44
device_entry::initf
int(* initf)(struct devinit *)
Definition: device.h:61
pci_entry
Definition: device.h:64
devinit::in_use
int in_use
Definition: device.h:52
devinit::addr_mult
int addr_mult
Definition: device.h:53
pci_lookup_initf
void(*)(struct machine *machine, struct memory *mem, struct pci_device *pd) pci_lookup_initf(const char *name)
Definition: device.h:87

Generated on Tue Aug 25 2020 19:25:06 for GXemul by doxygen 1.8.18