1 /* Intel PRO/1000 Family Driver
2 * Copyright (C) 2004 Marcus Overhagen <marcus@overhagen.de>. All rights reserved.
4 * Permission to use, copy, modify and distribute this software and its
5 * documentation for any purpose and without fee is hereby granted, provided
6 * that the above copyright notice appear in all copies, and that both the
7 * copyright notice and this permission notice appear in supporting documentation.
9 * Marcus Overhagen makes no representations about the suitability of this software
10 * for any purpose. It is provided "as is" without express or implied warranty.
12 * MARCUS OVERHAGEN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
13 * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL MARCUS
14 * OVERHAGEN BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
15 * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
17 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 #include "if_em_osdep.h"
28 driver_malloc(int size
, int p2
, int p3
)
35 driver_free(void *p
, int p2
)
42 contigmalloc(int size
, int p1
, int p2
, int p3
, int p4
, int p5
, int p6
)
45 if (create_area("contigmalloc", &adr
, B_ANY_KERNEL_ADDRESS
, size
,
46 B_CONTIGUOUS
, 0) < B_OK
)
53 contigfree(void *p
, int p1
, int p2
)
55 delete_area(area_for(p
));
60 callout_handle_init(struct callout_handle
*handle
)
67 timeout(timer_function func
, void *cookie
, bigtime_t timeout
)
69 struct callout_handle handle
;
70 handle
.timer
= create_timer(func
, cookie
, timeout
, B_ONE_SHOT_RELATIVE_TIMER
);
76 untimeout(timer_function func
, void *cookie
, struct callout_handle handle
)
78 delete_timer(handle
.timer
);
83 bus_alloc_resource(device_t dev
, int type
, int *rid
, int d
, int e
, int f
, int g
)
88 uint32 v
= pci_read_config(dev
, *rid
, 4) & PCI_address_io_mask
;
89 INIT_DEBUGOUT2("bus_alloc_resource SYS_RES_IOPORT, reg 0x%x, adr %p\n", *rid
, (void *)v
);
90 return (struct resource
*) v
;
95 uint32 v
= pci_read_config(dev
, *rid
, 4) & PCI_address_memory_32_mask
;
96 uint32 size
= 128 * 1024; // XXX get size from BAR
98 INIT_DEBUGOUT2("bus_alloc_resource SYS_RES_MEMORY, reg 0x%x, adr %p\n", *rid
, (void *)v
);
99 if (map_mem(&virt
, (void *)v
, size
, 0, "SYS_RES_MEMORY") < 0)
101 return (struct resource
*) virt
;
106 uint8 v
= pci_read_config(dev
, PCI_interrupt_line
, 1);
107 if (v
== 0 || v
== 0xff) {
108 ERROROUT("bus_alloc_resource SYS_RES_IRQ: no irq");
111 return (struct resource
*)(int)v
;
115 INIT_DEBUGOUT("bus_alloc_resource default!\n");
122 bus_release_resource(device_t dev
, int type
, int reg
, struct resource
*res
)
130 delete_area(area_for(res
));
134 INIT_DEBUGOUT("bus_release_resource default!\n");
141 rman_get_start(struct resource
*res
)
148 interrupt_handler int_func
;
155 bus_setup_intr(device_t dev
, struct resource
*res
, int p3
, interrupt_handler int_func
, void *cookie
, void **tag
)
159 struct int_tag
*int_tag
= (struct int_tag
*) malloc(sizeof(struct int_tag
));
160 int_tag
->int_func
= int_func
;
161 int_tag
->cookie
= cookie
;
165 return install_io_interrupt_handler(irq
, int_func
, cookie
, 0);
170 bus_teardown_intr(device_t dev
, struct resource
*res
, void *tag
)
172 struct int_tag
*int_tag
= (struct int_tag
*) tag
;
173 remove_io_interrupt_handler(int_tag
->irq
, int_tag
->int_func
, int_tag
->cookie
);