5d063cdc10
* configure.ac: Rename yeeloong platform to loongson. All users updated. * grub-core/Makefile.core.def (fwstart_fuloong): New image. * grub-core/boot/mips/loongson/fuloong.S: New file. * grub-core/boot/mips/loongson/fwstart.S: Wait for CS5536 to come up. Explicitly init CS5536. [FULOONG]: Don't use serial until CS5536 is available. Set GPIO based on dumps. (serial_hw_init) [FULOONG]: Handle CS5536 parts. [FULOONG]: Handle GPIO and memory controller differences. Parse machine type in $a2. * grub-core/boot/mips/startup_raw.S: Determine and save the architecture. * grub-core/bus/cs5536.c (gpiodump): Move to fwstart.S. (grub_cs5536_init_geode): Remove gpio part. Conditionalise DIVIL init on architecture type. * grub-core/kern/mips/loongson/init.c (grub_machine_init): Init SIS315E. Don't init at_keyboard on fuloong. (grub_halt): Support Fuloong. * grub-core/kern/mips/startup.S [LOONGSON]: Save $s7. * grub-core/loader/mips/linux.c (LOONGSON_MACHTYPE): Removed. (loongson_machtypes): New array. (grub_cmd_linux) [GRUB_MACHINE_MIPS_LOONGSON]: Pass the right machine type. * grub-core/term/ns8250.c (serial_get_divisor): New parameter port and config. All users updated. Handle CS5536 serial. * grub-core/term/serial.c (grub_serial_register): Conditionalise default port on machine type. Register serial as inactive. * grub-core/video/sis315pro.c: New file. * include/grub/cs5536.h (GRUB_CS5536_MSR_MAILBOX_CONFIG_ENABLED): New definition. (GRUB_CS5536_MSR_MAILBOX_CONFIG): Likewise. (GRUB_CS5536_MSR_DIVIL_LEG_IO_UART1_COM1): Likewise. (GRUB_CS5536_MSR_DIVIL_LEG_IO_UART2_COM3): Likewise. (GRUB_CS5536_MSR_DIVIL_UART1_CONF): Likewise. (GRUB_CS5536_MSR_DIVIL_UART2_CONF): Likewise. * include/grub/mips/loongson.h (GRUB_CPU_LOONGSON_SHUTDOWN_GPIO): Rename to ... (GRUB_CPU_YEELOONG_SHUTDOWN_GPIO): ... this. * include/grub/mips/loongson/kernel.h (GRUB_ARCH_MACHINE_YEELOONG): New definition. (GRUB_ARCH_MACHINE_FULOONG): Likewise. (grub_arch_machine): New extern var. * include/grub/mips/loongson/serial.h (GRUB_MACHINE_SERIAL_DIVISOR_115200): Renamed to ... (GRUB_MACHINE_SERIAL_PORT0_DIVISOR_115200): ... this. (GRUB_MACHINE_SERIAL_PORT): Renamed to ... (GRUB_MACHINE_SERIAL_PORT0): ... this. (GRUB_MACHINE_SERIAL_PORT2_DIVISOR_115200): New definition. (GRUB_MACHINE_SERIAL_PORT1): Likewise. (GRUB_MACHINE_SERIAL_PORT2): Likewise. (GRUB_MACHINE_SERIAL_PORTS): Include ports 1 and 2. * include/grub/term.h (grub_term_register_input_inactive): New inline function. (grub_term_register_output_inactive): Likewise. * include/grub/video.h (grub_video_driver_id): New value GRUB_VIDEO_DRIVER_SIS315PRO. * util/grub-mkimage.c (image_target_desc): Rename name to dirname. New field "names". All users updated. New field value IMAGE_FULOONG_FLASH. (generate_image): USe separate fwstart hashes for yeeloong and fuloong.
137 lines
3.4 KiB
C
137 lines
3.4 KiB
C
/* pci.c - Generic PCI interfaces. */
|
|
/*
|
|
* GRUB -- GRand Unified Bootloader
|
|
* Copyright (C) 2007,2009 Free Software Foundation, Inc.
|
|
*
|
|
* GRUB is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* GRUB is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include <grub/dl.h>
|
|
#include <grub/pci.h>
|
|
#include <grub/mm.h>
|
|
#include <grub/mm_private.h>
|
|
#include <grub/cache.h>
|
|
|
|
GRUB_MOD_LICENSE ("GPLv3+");
|
|
|
|
/* FIXME: correctly support 64-bit architectures. */
|
|
/* #if GRUB_TARGET_SIZEOF_VOID_P == 4 */
|
|
struct grub_pci_dma_chunk *
|
|
grub_memalign_dma32 (grub_size_t align, grub_size_t size)
|
|
{
|
|
void *ret = grub_memalign (align, size);
|
|
if (!ret)
|
|
return 0;
|
|
grub_arch_sync_dma_caches (ret, size);
|
|
return ret;
|
|
}
|
|
|
|
/* FIXME: evil. */
|
|
void
|
|
grub_dma_free (struct grub_pci_dma_chunk *ch)
|
|
{
|
|
grub_size_t size = (((struct grub_mm_header *) ch) - 1)->size * GRUB_MM_ALIGN;
|
|
grub_arch_sync_dma_caches (ch, size);
|
|
grub_free (ch);
|
|
}
|
|
/* #endif */
|
|
|
|
#ifdef GRUB_MACHINE_MIPS_LOONGSON
|
|
volatile void *
|
|
grub_dma_get_virt (struct grub_pci_dma_chunk *ch)
|
|
{
|
|
return (void *) ((((grub_uint32_t) ch) & 0x1fffffff) | 0xa0000000);
|
|
}
|
|
|
|
grub_uint32_t
|
|
grub_dma_get_phys (struct grub_pci_dma_chunk *ch)
|
|
{
|
|
return (((grub_uint32_t) ch) & 0x1fffffff) | 0x80000000;
|
|
}
|
|
#else
|
|
|
|
volatile void *
|
|
grub_dma_get_virt (struct grub_pci_dma_chunk *ch)
|
|
{
|
|
return (void *) ch;
|
|
}
|
|
|
|
grub_uint32_t
|
|
grub_dma_get_phys (struct grub_pci_dma_chunk *ch)
|
|
{
|
|
return (grub_uint32_t) (grub_addr_t) ch;
|
|
}
|
|
|
|
#endif
|
|
|
|
grub_pci_address_t
|
|
grub_pci_make_address (grub_pci_device_t dev, int reg)
|
|
{
|
|
return (1 << 31) | (dev.bus << 16) | (dev.device << 11)
|
|
| (dev.function << 8) | reg;
|
|
}
|
|
|
|
void
|
|
grub_pci_iterate (grub_pci_iteratefunc_t hook)
|
|
{
|
|
grub_pci_device_t dev;
|
|
grub_pci_address_t addr;
|
|
grub_pci_id_t id;
|
|
grub_uint32_t hdr;
|
|
|
|
for (dev.bus = 0; dev.bus < GRUB_PCI_NUM_BUS; dev.bus++)
|
|
{
|
|
for (dev.device = 0; dev.device < GRUB_PCI_NUM_DEVICES; dev.device++)
|
|
{
|
|
for (dev.function = 0; dev.function < 8; dev.function++)
|
|
{
|
|
addr = grub_pci_make_address (dev, GRUB_PCI_REG_PCI_ID);
|
|
id = grub_pci_read (addr);
|
|
|
|
/* Check if there is a device present. */
|
|
if (id >> 16 == 0xFFFF)
|
|
{
|
|
if (dev.function == 0)
|
|
/* Devices are required to implement function 0, so if
|
|
it's missing then there is no device here. */
|
|
break;
|
|
else
|
|
continue;
|
|
}
|
|
|
|
#ifdef GRUB_MACHINE_MIPS_LOONGSON
|
|
/* Skip ghosts. */
|
|
if (id == GRUB_LOONGSON_OHCI_PCIID
|
|
&& dev.function == GRUB_LOONGSON_OHCI_GHOST_FUNCTION)
|
|
continue;
|
|
if (id == GRUB_LOONGSON_EHCI_PCIID
|
|
&& dev.function == GRUB_LOONGSON_EHCI_GHOST_FUNCTION)
|
|
continue;
|
|
#endif
|
|
|
|
if (hook (dev, id))
|
|
return;
|
|
|
|
/* Probe only func = 0 if the device if not multifunction */
|
|
if (dev.function == 0)
|
|
{
|
|
addr = grub_pci_make_address (dev, GRUB_PCI_REG_CACHELINE);
|
|
hdr = grub_pci_read (addr);
|
|
if (!(hdr & 0x800000))
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|