Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / arch / i386 / xbox / xbox.c
blob75ec6758f9cbc2b62dc4ab911893017052f3afc7
1 /* $NetBSD: xbox.c,v 1.3 2007/02/04 15:26:27 jmcneill Exp $ */
3 /*-
4 * Copyright (c) 2007 Jared D. McNeill <jmcneill@invisible.ca>
5 * All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
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.
16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
30 * Microsoft XBOX helper functions
33 #include <sys/cdefs.h>
34 __KERNEL_RCSID(0, "$NetBSD: xbox.c,v 1.3 2007/02/04 15:26:27 jmcneill Exp $");
36 #include <sys/param.h>
37 #include <sys/systm.h>
38 #include <sys/device.h>
40 #include <machine/bus.h>
42 #include <arch/i386/include/xbox.h>
44 #include "pic16lc.h"
46 #if NPIC16LC > 0
47 extern void pic16lc_setled(uint8_t);
48 extern void pic16lc_reboot(void);
49 extern void pic16lc_poweroff(void);
50 #endif
52 #define XBOX_NFORCE_NIC 0xfef00000
54 void
55 xbox_startup(void)
57 bus_space_handle_t h;
58 int rv;
60 if (!arch_i386_is_xbox)
61 return;
64 * From Rink Springer @ FreeBSD:
66 * Some XBOX loaders, such as Cromwell, have a flaw which cause the
67 * nfe(4) driver to fail attaching to the NIC.
69 * This is because they leave the NIC running; this will cause the
70 * Nvidia driver to fail as the NIC does not return any sensible
71 * values and thus fails attaching (using an error 0x5, this means
72 * it cannot find a valid PHY)
74 * We bluntly tell the NIC to stop whatever it's doing; this makes
75 * nfe(4) attach correctly. As the NIC always resides at
76 * 0xfef00000-0xfef003ff on an XBOX, we simply hardcode this address.
78 rv = bus_space_map(X86_BUS_SPACE_MEM, XBOX_NFORCE_NIC,
79 0x400, 0, &h);
80 if (!rv) {
81 bus_space_write_4(X86_BUS_SPACE_MEM, h, 0x188, 0);
82 bus_space_unmap(X86_BUS_SPACE_MEM, h, 0x400);
88 void
89 xbox_setled(uint8_t val)
91 #if NPIC16LC > 0
92 pic16lc_setled(val);
93 #else
94 printf("xbox_setled: pic16lc driver missing from kernel!\n");
95 #endif
98 void
99 xbox_reboot(void)
101 #if NPIC16LC > 0
102 pic16lc_reboot();
103 #else
104 printf("xbox_reboot: pic16lc driver missing from kernel!\n");
105 printf("xbox_reboot: halting...\n");
106 for (;;)
108 #endif
111 void
112 xbox_poweroff(void)
114 #if NPIC16LC > 0
115 pic16lc_poweroff();
116 #else
117 printf("xbox_poweroff: pic16lc driver missing from kernel!\n");
118 printf("xbox_poweroff: halting...\n");
119 for (;;)
121 #endif