Skip to content

Commit e4e7a42

Browse files
heiherchenx97
authored andcommitted
mips64: Add support for Loongson.
1 parent 61a3db3 commit e4e7a42

File tree

10 files changed

+1184
-21
lines changed

10 files changed

+1184
-21
lines changed

configure.ac

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,15 @@ case "$target_cpu" in
110110
amd64) target_cpu=x86_64 ;;
111111
sparc) target_cpu=sparc64 ;;
112112
mips64el)
113-
target_cpu=mips64el
113+
target_cpu=mips64el
114114
machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPS64EL=1"
115115
;;
116116
mipsel)
117-
target_cpu=mipsel
117+
target_cpu=mipsel
118118
machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPSEL=1"
119119
;;
120120
mips|mips64)
121-
target_cpu=mips
121+
target_cpu=mips
122122
machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPS=1"
123123
;;
124124
arm*) target_cpu=arm ;;

grub-core/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ if COND_mips64_efi
243243
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h
244244
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h
245245
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h
246+
KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/loongson.h
246247
endif
247248

248249
if COND_powerpc_ieee1275

grub-core/Makefile.core.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,9 @@ kernel = {
337337
mips64 = kern/mips64/cache.S;
338338
mips64 = kern/generic/rtc_get_time_ms.c;
339339
mips64_efi = kern/mips64/efi/init.c;
340+
mips64_efi = kern/mips64/efi/loongson.c;
341+
mips64_efi = lib/mips64/efi/loongson.c;
342+
mips64_efi = lib/mips64/efi/loongson_asm.S;
340343

341344
powerpc_ieee1275 = kern/powerpc/cache.S;
342345
powerpc_ieee1275 = kern/powerpc/dl.c;

grub-core/kern/mips64/efi/init.c

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,61 @@
2424
#include <grub/cpu/time.h>
2525
#include <grub/efi/efi.h>
2626
#include <grub/loader.h>
27+
#include <grub/machine/loongson.h>
28+
29+
static grub_uint64_t tmr;
30+
static grub_efi_event_t tmr_evt;
31+
32+
static grub_uint64_t
33+
grub_efi_get_time_ms (void)
34+
{
35+
return tmr;
36+
}
37+
38+
static void
39+
grub_loongson_increment_timer (grub_efi_event_t event __attribute__ ((unused)),
40+
void *context __attribute__ ((unused)))
41+
{
42+
tmr += 10;
43+
}
44+
45+
2746

2847
void
2948
grub_machine_init (void)
3049
{
50+
grub_efi_boot_services_t *b;
51+
3152
grub_efi_init ();
3253

33-
/* FIXME: Get cpuclock from EFI. */
34-
grub_timer_init (1000000000U);
54+
b = grub_efi_system_table->boot_services;
55+
efi_call_5 (b->create_event, GRUB_EFI_EVT_TIMER | GRUB_EFI_EVT_NOTIFY_SIGNAL,
56+
GRUB_EFI_TPL_CALLBACK, grub_loongson_increment_timer, NULL, &tmr_evt);
57+
efi_call_3 (b->set_timer, tmr_evt, GRUB_EFI_TIMER_PERIODIC, 100000);
58+
59+
grub_install_get_time_ms (grub_efi_get_time_ms);
60+
61+
if (grub_efi_is_loongson ())
62+
grub_efi_loongson_init ();
63+
else
64+
/* FIXME: Get cpuclock from EFI. */
65+
grub_timer_init (1000000000U);
3566
}
3667

3768
void
3869
grub_machine_fini (int flags)
3970
{
71+
grub_efi_boot_services_t *b;
72+
4073
if (!(flags & GRUB_LOADER_FLAG_NORETURN))
4174
return;
4275

76+
b = grub_efi_system_table->boot_services;
77+
78+
efi_call_3 (b->set_timer, tmr_evt, GRUB_EFI_TIMER_CANCEL, 0);
79+
efi_call_1 (b->close_event, tmr_evt);
80+
81+
if (grub_efi_is_loongson ())
82+
grub_efi_loongson_fini ();
4383
grub_efi_fini ();
4484
}

grub-core/kern/mips64/efi/loongson.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* GRUB -- GRand Unified Bootloader
3+
* Copyright (C) 2017 Free Software Foundation, Inc.
4+
*
5+
* GRUB is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* GRUB is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
#include <grub/efi/efi.h>
20+
#include <grub/cpu/time.h>
21+
#include <grub/loader.h>
22+
#include <grub/machine/loongson.h>
23+
24+
void
25+
grub_efi_loongson_init (void)
26+
{
27+
}
28+
29+
void
30+
grub_efi_loongson_fini (void)
31+
{
32+
}

0 commit comments

Comments
 (0)