merge mainline into sgi

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2011-05-15 02:23:36 +02:00
commit bee1aeb9a1
49 changed files with 1148 additions and 348 deletions

View file

@ -626,7 +626,7 @@ grub_dl_load_file (const char *filename)
return 0;
}
mod->ref_count = 0;
mod->ref_count--;
return mod;
}
@ -683,8 +683,7 @@ grub_dl_unload (grub_dl_t mod)
{
depn = dep->next;
if (! grub_dl_unref (dep->mod))
grub_dl_unload (dep->mod);
grub_dl_unload (dep->mod);
grub_free (dep);
}

View file

@ -53,8 +53,8 @@ grub_module_iterate (int (*hook) (struct grub_module_header *header))
}
}
/* This is actualy platform-independant but used only on yeeloong and sparc. */
#if defined (GRUB_MACHINE_MIPS_YEELOONG) || defined (GRUB_MACHINE_SPARC64)
/* This is actualy platform-independant but used only on loongson and sparc. */
#if defined (GRUB_MACHINE_MIPS_LOONGSON) || defined (GRUB_MACHINE_SPARC64)
grub_addr_t
grub_modules_get_end (void)
{

View file

@ -8,3 +8,38 @@ FUNCTION (grub_cpu_flush_cache)
FUNCTION (grub_arch_sync_caches)
#include "cache_flush.S"
j $ra
FUNCTION (grub_arch_sync_dma_caches)
move $t2, $a0
addu $t3, $a0, $a1
srl $t2, $t2, 5
sll $t2, $t2, 5
addu $t3, $t3, 0x1f
srl $t3, $t3, 5
sll $t3, $t3, 5
move $t0, $t2
subu $t1, $t3, $t2
1:
cache 1, 0($t0)
addiu $t1, $t1, 0xffff
bne $t1, $zero, 1b
addiu $t0, $t0, 0x1
sync
move $t0, $t2
subu $t1, $t3, $t2
2:
cache 0, 0($t0)
addiu $t1, $t1, 0xffff
bne $t1, $zero, 2b
addiu $t0, $t0, 0x1
sync
move $t0, $t2
subu $t1, $t3, $t2
2:
cache 23, 0($t0)
addiu $t1, $t1, 0xffff
bne $t1, $zero, 2b
addiu $t0, $t0, 0x1
sync
jr $ra

View file

@ -34,6 +34,7 @@
#include <grub/cpu/memory.h>
extern void grub_video_sm712_init (void);
extern void grub_video_sis315pro_init (void);
extern void grub_video_init (void);
extern void grub_bitmap_init (void);
extern void grub_font_init (void);
@ -64,7 +65,7 @@ init_pci (void)
/* FIXME: autoscan for BARs and devices. */
switch (pciid)
{
case GRUB_YEELOONG_OHCI_PCIID:
case GRUB_LOONGSON_OHCI_PCIID:
addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
grub_pci_write (addr, 0x5025000);
addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND);
@ -76,7 +77,7 @@ init_pci (void)
addr = grub_pci_make_address (dev, GRUB_PCI_REG_STATUS);
grub_pci_write_word (addr, 0x0200 | GRUB_PCI_STATUS_CAPABILITIES);
break;
case GRUB_YEELOONG_EHCI_PCIID:
case GRUB_LOONGSON_EHCI_PCIID:
addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
grub_pci_write (addr, 0x5026000);
addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND);
@ -148,7 +149,7 @@ grub_machine_init (void)
if (err)
grub_fatal ("Couldn't init SMBus: %s\n", grub_errmsg);
/* Yeeloong has only one memory slot. */
/* Yeeloong and Fuloong have only one memory slot. */
err = grub_cs5536_read_spd (smbbase, GRUB_SMB_RAM_START_ADDR, &spd);
if (err)
grub_fatal ("Couldn't read SPD: %s\n", grub_errmsg);
@ -187,12 +188,14 @@ grub_machine_init (void)
relies on a working heap. */
grub_video_init ();
grub_video_sm712_init ();
grub_video_sis315pro_init ();
grub_bitmap_init ();
grub_font_init ();
grub_gfxterm_init ();
grub_keylayouts_init ();
grub_at_keyboard_init ();
if (grub_arch_machine == GRUB_ARCH_MACHINE_YEELOONG)
grub_at_keyboard_init ();
grub_terminfo_init ();
grub_serial_init ();
@ -208,10 +211,28 @@ grub_machine_fini (void)
void
grub_halt (void)
{
grub_outb (grub_inb (GRUB_CPU_LOONGSON_GPIOCFG)
& ~GRUB_CPU_LOONGSON_SHUTDOWN_GPIO, GRUB_CPU_LOONGSON_GPIOCFG);
grub_millisleep (1500);
switch (grub_arch_machine)
{
case GRUB_ARCH_MACHINE_FULOONG:
{
grub_pci_device_t dev;
grub_port_t p;
if (grub_cs5536_find (&dev))
{
p = (grub_cs5536_read_msr (dev, GRUB_CS5536_MSR_GPIO_BAR)
& GRUB_CS5536_LBAR_ADDR_MASK) + GRUB_MACHINE_PCI_IO_BASE;
grub_outl ((1 << 13), p + 4);
grub_outl ((1 << 29), p);
grub_millisleep (5000);
}
}
break;
case GRUB_ARCH_MACHINE_YEELOONG:
grub_outb (grub_inb (GRUB_CPU_LOONGSON_GPIOCFG)
& ~GRUB_CPU_YEELOONG_SHUTDOWN_GPIO, GRUB_CPU_LOONGSON_GPIOCFG);
grub_millisleep (1500);
break;
}
grub_printf ("Shutdown failed\n");
grub_refresh ();

View file

@ -20,6 +20,7 @@
#include <grub/symbol.h>
#include <grub/offsets.h>
#include <grub/machine/memory.h>
#include <grub/machine/kernel.h>
#include <grub/offsets.h>
#define BASE_ADDR 8
@ -35,7 +36,7 @@ start:
bal cont
nop
. = _start + GRUB_KERNEL_MIPS_YEELOONG_TOTAL_MODULE_SIZE
. = _start + GRUB_KERNEL_MIPS_LOONGSON_TOTAL_MODULE_SIZE
total_module_size:
.long 0
@ -52,25 +53,28 @@ VARIABLE(grub_prefix)
. = _start + GRUB_KERNEL_MACHINE_PREFIX_END
VARIABLE (grub_arch_cpuclock)
.long 0
#ifdef GRUB_MACHINE_MIPS_YEELOONG
#ifdef GRUB_MACHINE_MIPS_LOONGSON
VARIABLE (grub_arch_busclock)
.long 0
VARIABLE (grub_arch_memsize)
.long 0
VARIABLE (grub_arch_highmemsize)
.long 0
VARIABLE (grub_arch_machine)
.long GRUB_ARCH_MACHINE_FULOONG
#endif
cont:
/* Save our base. */
move $s0, $ra
#ifdef GRUB_MACHINE_MIPS_YEELOONG
#ifdef GRUB_MACHINE_MIPS_LOONGSON
lui $t1, %hi(grub_arch_busclock)
addiu $t1, %lo(grub_arch_busclock)
sw $s2, 0($t1)
sw $s3, 4($t1)
sw $s4, 8($t1)
sw $s5, 12($t1)
sw $s7, 16($t1)
#endif
/* Move the modules out of BSS. */

View file

@ -311,11 +311,13 @@ grub_memalign (grub_size_t align, grub_size_t size)
count++;
goto again;
#if 0
case 1:
/* Unload unneeded modules. */
grub_dl_unload_unneeded ();
count++;
goto again;
#endif
default:
break;