diff options
Diffstat (limited to 'arch/ppc/boot/of1275')
-rw-r--r-- | arch/ppc/boot/of1275/Makefile | 6 | ||||
-rw-r--r-- | arch/ppc/boot/of1275/claim.c | 34 | ||||
-rw-r--r-- | arch/ppc/boot/of1275/enter.c | 22 | ||||
-rw-r--r-- | arch/ppc/boot/of1275/exit.c | 24 | ||||
-rw-r--r-- | arch/ppc/boot/of1275/finddevice.c | 31 | ||||
-rw-r--r-- | arch/ppc/boot/of1275/getprop.c | 37 | ||||
-rw-r--r-- | arch/ppc/boot/of1275/map.c | 48 | ||||
-rw-r--r-- | arch/ppc/boot/of1275/ofinit.c | 27 | ||||
-rw-r--r-- | arch/ppc/boot/of1275/ofstdio.c | 32 | ||||
-rw-r--r-- | arch/ppc/boot/of1275/read.c | 35 | ||||
-rw-r--r-- | arch/ppc/boot/of1275/release.c | 30 | ||||
-rw-r--r-- | arch/ppc/boot/of1275/write.c | 35 |
12 files changed, 361 insertions, 0 deletions
diff --git a/arch/ppc/boot/of1275/Makefile b/arch/ppc/boot/of1275/Makefile new file mode 100644 index 000000000000..02e6f235d7cb --- /dev/null +++ b/arch/ppc/boot/of1275/Makefile | |||
@@ -0,0 +1,6 @@ | |||
1 | # | ||
2 | # Makefile of1275 stuff | ||
3 | # | ||
4 | |||
5 | lib-y := claim.o enter.o exit.o finddevice.o getprop.o ofinit.o \ | ||
6 | ofstdio.o read.o release.o write.o map.o | ||
diff --git a/arch/ppc/boot/of1275/claim.c b/arch/ppc/boot/of1275/claim.c new file mode 100644 index 000000000000..e060292ae2a7 --- /dev/null +++ b/arch/ppc/boot/of1275/claim.c | |||
@@ -0,0 +1,34 @@ | |||
1 | /* | ||
2 | * Copyright (C) Paul Mackerras 1997. | ||
3 | * Copyright (C) Leigh Brown 2002. | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public License | ||
7 | * as published by the Free Software Foundation; either version | ||
8 | * 2 of the License, or (at your option) any later version. | ||
9 | */ | ||
10 | |||
11 | #include "of1275.h" | ||
12 | |||
13 | void * | ||
14 | claim(unsigned int virt, unsigned int size, unsigned int align) | ||
15 | { | ||
16 | struct prom_args { | ||
17 | char *service; | ||
18 | int nargs; | ||
19 | int nret; | ||
20 | unsigned int virt; | ||
21 | unsigned int size; | ||
22 | unsigned int align; | ||
23 | void *ret; | ||
24 | } args; | ||
25 | |||
26 | args.service = "claim"; | ||
27 | args.nargs = 3; | ||
28 | args.nret = 1; | ||
29 | args.virt = virt; | ||
30 | args.size = size; | ||
31 | args.align = align; | ||
32 | (*of_prom_entry)(&args); | ||
33 | return args.ret; | ||
34 | } | ||
diff --git a/arch/ppc/boot/of1275/enter.c b/arch/ppc/boot/of1275/enter.c new file mode 100644 index 000000000000..abe87a8fe2db --- /dev/null +++ b/arch/ppc/boot/of1275/enter.c | |||
@@ -0,0 +1,22 @@ | |||
1 | /* | ||
2 | * Copyright (C) Paul Mackerras 1997. | ||
3 | * Copyright (C) Leigh Brown 2002. | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public License | ||
7 | * as published by the Free Software Foundation; either version | ||
8 | * 2 of the License, or (at your option) any later version. | ||
9 | */ | ||
10 | |||
11 | #include "of1275.h" | ||
12 | |||
13 | void | ||
14 | enter(void) | ||
15 | { | ||
16 | struct prom_args { | ||
17 | char *service; | ||
18 | } args; | ||
19 | |||
20 | args.service = "enter"; | ||
21 | (*of_prom_entry)(&args); | ||
22 | } | ||
diff --git a/arch/ppc/boot/of1275/exit.c b/arch/ppc/boot/of1275/exit.c new file mode 100644 index 000000000000..b9f89b6a8b45 --- /dev/null +++ b/arch/ppc/boot/of1275/exit.c | |||
@@ -0,0 +1,24 @@ | |||
1 | /* | ||
2 | * Copyright (C) Paul Mackerras 1997. | ||
3 | * Copyright (C) Leigh Brown 2002. | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public License | ||
7 | * as published by the Free Software Foundation; either version | ||
8 | * 2 of the License, or (at your option) any later version. | ||
9 | */ | ||
10 | |||
11 | #include "of1275.h" | ||
12 | |||
13 | void | ||
14 | exit(void) | ||
15 | { | ||
16 | struct prom_args { | ||
17 | char *service; | ||
18 | } args; | ||
19 | |||
20 | for (;;) { | ||
21 | args.service = "exit"; | ||
22 | (*of_prom_entry)(&args); | ||
23 | } | ||
24 | } | ||
diff --git a/arch/ppc/boot/of1275/finddevice.c b/arch/ppc/boot/of1275/finddevice.c new file mode 100644 index 000000000000..2c0f7cbb793e --- /dev/null +++ b/arch/ppc/boot/of1275/finddevice.c | |||
@@ -0,0 +1,31 @@ | |||
1 | /* | ||
2 | * Copyright (C) Paul Mackerras 1997. | ||
3 | * Copyright (C) Leigh Brown 2002. | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public License | ||
7 | * as published by the Free Software Foundation; either version | ||
8 | * 2 of the License, or (at your option) any later version. | ||
9 | */ | ||
10 | |||
11 | #include "of1275.h" | ||
12 | |||
13 | phandle | ||
14 | finddevice(const char *name) | ||
15 | { | ||
16 | struct prom_args { | ||
17 | char *service; | ||
18 | int nargs; | ||
19 | int nret; | ||
20 | const char *devspec; | ||
21 | phandle device; | ||
22 | } args; | ||
23 | |||
24 | args.service = "finddevice"; | ||
25 | args.nargs = 1; | ||
26 | args.nret = 1; | ||
27 | args.devspec = name; | ||
28 | args.device = OF_INVALID_HANDLE; | ||
29 | (*of_prom_entry)(&args); | ||
30 | return args.device; | ||
31 | } | ||
diff --git a/arch/ppc/boot/of1275/getprop.c b/arch/ppc/boot/of1275/getprop.c new file mode 100644 index 000000000000..0cf75f035e4e --- /dev/null +++ b/arch/ppc/boot/of1275/getprop.c | |||
@@ -0,0 +1,37 @@ | |||
1 | /* | ||
2 | * Copyright (C) Paul Mackerras 1997. | ||
3 | * Copyright (C) Leigh Brown 2002. | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public License | ||
7 | * as published by the Free Software Foundation; either version | ||
8 | * 2 of the License, or (at your option) any later version. | ||
9 | */ | ||
10 | |||
11 | #include "of1275.h" | ||
12 | |||
13 | int | ||
14 | getprop(phandle node, const char *name, void *buf, int buflen) | ||
15 | { | ||
16 | struct prom_args { | ||
17 | char *service; | ||
18 | int nargs; | ||
19 | int nret; | ||
20 | phandle node; | ||
21 | const char *name; | ||
22 | void *buf; | ||
23 | int buflen; | ||
24 | int size; | ||
25 | } args; | ||
26 | |||
27 | args.service = "getprop"; | ||
28 | args.nargs = 4; | ||
29 | args.nret = 1; | ||
30 | args.node = node; | ||
31 | args.name = name; | ||
32 | args.buf = buf; | ||
33 | args.buflen = buflen; | ||
34 | args.size = -1; | ||
35 | (*of_prom_entry)(&args); | ||
36 | return args.size; | ||
37 | } | ||
diff --git a/arch/ppc/boot/of1275/map.c b/arch/ppc/boot/of1275/map.c new file mode 100644 index 000000000000..443256c6f6d6 --- /dev/null +++ b/arch/ppc/boot/of1275/map.c | |||
@@ -0,0 +1,48 @@ | |||
1 | /* | ||
2 | * Copyright (C) Paul Mackerras 1997. | ||
3 | * Copyright (C) Leigh Brown 2002. | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public License | ||
7 | * as published by the Free Software Foundation; either version | ||
8 | * 2 of the License, or (at your option) any later version. | ||
9 | */ | ||
10 | |||
11 | #include "of1275.h" | ||
12 | #include "nonstdio.h" | ||
13 | |||
14 | extern ihandle of_prom_mmu; | ||
15 | |||
16 | int | ||
17 | map(unsigned int phys, unsigned int virt, unsigned int size) | ||
18 | { | ||
19 | struct prom_args { | ||
20 | char *service; | ||
21 | int nargs; | ||
22 | int nret; | ||
23 | char *method; | ||
24 | ihandle mmu_ihandle; | ||
25 | int misc; | ||
26 | unsigned int size; | ||
27 | unsigned int virt; | ||
28 | unsigned int phys; | ||
29 | int ret0; | ||
30 | } args; | ||
31 | |||
32 | if (of_prom_mmu == 0) { | ||
33 | printf("map() called, no MMU found\n"); | ||
34 | return -1; | ||
35 | } | ||
36 | args.service = "call-method"; | ||
37 | args.nargs = 6; | ||
38 | args.nret = 1; | ||
39 | args.method = "map"; | ||
40 | args.mmu_ihandle = of_prom_mmu; | ||
41 | args.misc = 0; | ||
42 | args.phys = phys; | ||
43 | args.virt = virt; | ||
44 | args.size = size; | ||
45 | (*of_prom_entry)(&args); | ||
46 | |||
47 | return (int)args.ret0; | ||
48 | } | ||
diff --git a/arch/ppc/boot/of1275/ofinit.c b/arch/ppc/boot/of1275/ofinit.c new file mode 100644 index 000000000000..0ee8af7639e9 --- /dev/null +++ b/arch/ppc/boot/of1275/ofinit.c | |||
@@ -0,0 +1,27 @@ | |||
1 | /* | ||
2 | * Copyright (C) Paul Mackerras 1997. | ||
3 | * Copyright (C) Leigh Brown 2002. | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public License | ||
7 | * as published by the Free Software Foundation; either version | ||
8 | * 2 of the License, or (at your option) any later version. | ||
9 | */ | ||
10 | |||
11 | #include "of1275.h" | ||
12 | |||
13 | prom_entry of_prom_entry; | ||
14 | ihandle of_prom_mmu; | ||
15 | |||
16 | void | ||
17 | ofinit(prom_entry prom_ptr) | ||
18 | { | ||
19 | phandle chosen; | ||
20 | |||
21 | of_prom_entry = prom_ptr; | ||
22 | |||
23 | if ((chosen = finddevice("/chosen")) == OF_INVALID_HANDLE) | ||
24 | return; | ||
25 | if (getprop(chosen, "mmu", &of_prom_mmu, sizeof(ihandle)) != 4) | ||
26 | return; | ||
27 | } | ||
diff --git a/arch/ppc/boot/of1275/ofstdio.c b/arch/ppc/boot/of1275/ofstdio.c new file mode 100644 index 000000000000..10abbe32b31f --- /dev/null +++ b/arch/ppc/boot/of1275/ofstdio.c | |||
@@ -0,0 +1,32 @@ | |||
1 | /* | ||
2 | * Copyright (C) Paul Mackerras 1997. | ||
3 | * Copyright (C) Leigh Brown 2002. | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public License | ||
7 | * as published by the Free Software Foundation; either version | ||
8 | * 2 of the License, or (at your option) any later version. | ||
9 | */ | ||
10 | |||
11 | #include "of1275.h" | ||
12 | |||
13 | int | ||
14 | ofstdio(ihandle *stdin, ihandle *stdout, ihandle *stderr) | ||
15 | { | ||
16 | ihandle in, out; | ||
17 | phandle chosen; | ||
18 | |||
19 | if ((chosen = finddevice("/chosen")) == OF_INVALID_HANDLE) | ||
20 | goto err; | ||
21 | if (getprop(chosen, "stdout", &out, sizeof(out)) != 4) | ||
22 | goto err; | ||
23 | if (getprop(chosen, "stdin", &in, sizeof(in)) != 4) | ||
24 | goto err; | ||
25 | |||
26 | *stdin = in; | ||
27 | *stdout = out; | ||
28 | *stderr = out; | ||
29 | return 0; | ||
30 | err: | ||
31 | return -1; | ||
32 | } | ||
diff --git a/arch/ppc/boot/of1275/read.c b/arch/ppc/boot/of1275/read.c new file mode 100644 index 000000000000..122813649fce --- /dev/null +++ b/arch/ppc/boot/of1275/read.c | |||
@@ -0,0 +1,35 @@ | |||
1 | /* | ||
2 | * Copyright (C) Paul Mackerras 1997. | ||
3 | * Copyright (C) Leigh Brown 2002. | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public License | ||
7 | * as published by the Free Software Foundation; either version | ||
8 | * 2 of the License, or (at your option) any later version. | ||
9 | */ | ||
10 | |||
11 | #include "of1275.h" | ||
12 | |||
13 | int | ||
14 | read(ihandle instance, void *buf, int buflen) | ||
15 | { | ||
16 | struct prom_args { | ||
17 | char *service; | ||
18 | int nargs; | ||
19 | int nret; | ||
20 | ihandle instance; | ||
21 | void *buf; | ||
22 | int buflen; | ||
23 | int actual; | ||
24 | } args; | ||
25 | |||
26 | args.service = "read"; | ||
27 | args.nargs = 3; | ||
28 | args.nret = 1; | ||
29 | args.instance = instance; | ||
30 | args.buf = buf; | ||
31 | args.buflen = buflen; | ||
32 | args.actual = -1; | ||
33 | (*of_prom_entry)(&args); | ||
34 | return args.actual; | ||
35 | } | ||
diff --git a/arch/ppc/boot/of1275/release.c b/arch/ppc/boot/of1275/release.c new file mode 100644 index 000000000000..28032d37145d --- /dev/null +++ b/arch/ppc/boot/of1275/release.c | |||
@@ -0,0 +1,30 @@ | |||
1 | /* | ||
2 | * Copyright (C) Paul Mackerras 1997. | ||
3 | * Copyright (C) Leigh Brown 2002. | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public License | ||
7 | * as published by the Free Software Foundation; either version | ||
8 | * 2 of the License, or (at your option) any later version. | ||
9 | */ | ||
10 | |||
11 | #include "of1275.h" | ||
12 | |||
13 | void | ||
14 | release(void *virt, unsigned int size) | ||
15 | { | ||
16 | struct prom_args { | ||
17 | char *service; | ||
18 | int nargs; | ||
19 | int nret; | ||
20 | void *virt; | ||
21 | unsigned int size; | ||
22 | } args; | ||
23 | |||
24 | args.service = "release"; | ||
25 | args.nargs = 2; | ||
26 | args.nret = 0; | ||
27 | args.virt = virt; | ||
28 | args.size = size; | ||
29 | (*of_prom_entry)(&args); | ||
30 | } | ||
diff --git a/arch/ppc/boot/of1275/write.c b/arch/ppc/boot/of1275/write.c new file mode 100644 index 000000000000..7361b9b2fca5 --- /dev/null +++ b/arch/ppc/boot/of1275/write.c | |||
@@ -0,0 +1,35 @@ | |||
1 | /* | ||
2 | * Copyright (C) Paul Mackerras 1997. | ||
3 | * Copyright (C) Leigh Brown 2002. | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public License | ||
7 | * as published by the Free Software Foundation; either version | ||
8 | * 2 of the License, or (at your option) any later version. | ||
9 | */ | ||
10 | |||
11 | #include "of1275.h" | ||
12 | |||
13 | int | ||
14 | write(ihandle instance, void *buf, int buflen) | ||
15 | { | ||
16 | struct prom_args { | ||
17 | char *service; | ||
18 | int nargs; | ||
19 | int nret; | ||
20 | ihandle instance; | ||
21 | void *buf; | ||
22 | int buflen; | ||
23 | int actual; | ||
24 | } args; | ||
25 | |||
26 | args.service = "write"; | ||
27 | args.nargs = 3; | ||
28 | args.nret = 1; | ||
29 | args.instance = instance; | ||
30 | args.buf = buf; | ||
31 | args.buflen = buflen; | ||
32 | args.actual = -1; | ||
33 | (*of_prom_entry)(&args); | ||
34 | return args.actual; | ||
35 | } | ||