~pmdj/ubuntu/trusty/qemu/2.9+applesmc+fadtv3

« back to all changes in this revision

Viewing changes to roms/openbios/arch/sparc64/boot.c

  • Committer: Phil Dennis-Jordan
  • Date: 2017-07-21 08:03:43 UTC
  • mfrom: (1.1.1)
  • Revision ID: phil@philjordan.eu-20170721080343-2yr2vdj7713czahv
New upstream release 2.9.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *
 
3
 */
 
4
#undef BOOTSTRAP
 
5
#include "config.h"
 
6
#include "libopenbios/bindings.h"
 
7
#include "arch/common/nvram.h"
 
8
#include "libc/diskio.h"
 
9
#include "libc/vsprintf.h"
 
10
#include "libopenbios/initprogram.h"
 
11
#include "libopenbios/sys_info.h"
 
12
#include "boot.h"
 
13
 
 
14
uint64_t kernel_image;
 
15
uint64_t kernel_size;
 
16
uint64_t qemu_cmdline;
 
17
uint64_t cmdline_size;
 
18
char boot_device;
 
19
 
 
20
extern int sparc64_of_client_interface( int *params );
 
21
 
 
22
/* ( path len -- path len ) */
 
23
 
 
24
void boot(void)
 
25
{
 
26
        char *path, *param;
 
27
 
 
28
        /* Copy the incoming path */
 
29
        fword("2dup");
 
30
        path = pop_fstr_copy();
 
31
 
 
32
        /* Boot preloaded kernel */
 
33
        if (kernel_size) {
 
34
            void (*entry)(unsigned long p1, unsigned long p2, unsigned long p3,
 
35
                          unsigned long p4, unsigned long p5);
 
36
 
 
37
            printk("[sparc64] Kernel already loaded\n");
 
38
            entry = (void *) (unsigned long)kernel_image;
 
39
            entry(0, 0, 0, 0, (unsigned long)&sparc64_of_client_interface);
 
40
        }
 
41
 
 
42
        /* Invoke Linux directly -- probably not supported */
 
43
        if(!path) {
 
44
            /* No path specified, so grab defaults from /chosen */
 
45
            push_str("bootpath");
 
46
            push_str("/chosen");
 
47
            fword("(find-dev)");
 
48
            POP();
 
49
            fword("get-package-property");
 
50
            POP();
 
51
            /* Update our local copy of path as well as the one on the stack */
 
52
            fword("2dup");
 
53
            path = pop_fstr_copy();
 
54
        }
 
55
 
 
56
        if (path) {
 
57
            param = strchr(path, ' ');
 
58
            if(param) {
 
59
                *param = '\0';
 
60
                param++;
 
61
            } else if (cmdline_size) {
 
62
                param = (char *)qemu_cmdline;
 
63
            } else {
 
64
                push_str("boot-args");
 
65
                push_str("/options");
 
66
                fword("(find-dev)");
 
67
                POP();
 
68
                fword("get-package-property");
 
69
                POP();
 
70
                param = pop_fstr_copy();
 
71
            }
 
72
 
 
73
            /* Invoke platform-specific Linux loader */
 
74
            linux_load(&sys_info, path, param);
 
75
 
 
76
            free(path);
 
77
        }
 
78
}