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 */
uint64_t addr2
Definition: device.h:47
uint64_t len
Definition: device.h:48
void * device_add(struct machine *machine, const char *name_and_params)
Definition: device.cc:252
void autodev_init(void)
Definition: autodev.cc:150
Definition: device.h:59
char * name
Definition: device.h:43
int device_unregister(char *name)
Definition: device.cc:210
void device_dumplist(void)
Definition: device.cc:408
Definition: device.h:64
int pci_register(const char *name, void(*initf)(struct machine *, struct memory *, struct pci_device *))
Definition: device.cc:114
void device_init(void)
Definition: device.cc:447
int pci_little_endian
Definition: device.h:54
struct device_entry * device_lookup(char *name)
Definition: device.cc:162
void * return_ptr
Definition: device.h:56
void device_set_exit_on_error(int exit_on_error)
Definition: device.cc:433
int addr_mult
Definition: device.h:53
char * name
Definition: device.h:60
char * name2
Definition: device.h:44
int in_use
Definition: device.h:52
Definition: device.h:40
struct machine * machine
Definition: device.h:41
char * name
Definition: device.h:65
Definition: memory.h:75
uint64_t addr
Definition: device.h:46
void(*)(struct machine *machine, struct memory *mem, struct pci_device *pd) pci_lookup_initf(const char *name)
Definition: device.h:87
int device_register(const char *name, int(*initf)(struct devinit *))
Definition: device.cc:89
char * interrupt_path
Definition: device.h:50
int(* initf)(struct devinit *)
Definition: device.h:61

Generated on Sun Sep 30 2018 16:05:18 for GXemul by doxygen 1.8.13