Linux Audio

Check our new training course

Loading...
v6.2
  1// SPDX-License-Identifier: GPL-2.0-only
  2/*
  3 *  PS3 bootwrapper support.
  4 *
  5 *  Copyright (C) 2007 Sony Computer Entertainment Inc.
  6 *  Copyright 2007 Sony Corp.
 
 
 
 
 
 
 
 
 
 
 
 
 
  7 */
  8
  9#include <stdarg.h>
 10#include <stddef.h>
 11#include "types.h"
 12#include "elf.h"
 13#include "string.h"
 14#include "stdio.h"
 15#include "page.h"
 16#include "ops.h"
 17
 18extern int lv1_panic(u64 in_1);
 19extern int lv1_get_logical_partition_id(u64 *out_1);
 20extern int lv1_get_logical_ppe_id(u64 *out_1);
 21extern int lv1_get_repository_node_value(u64 in_1, u64 in_2, u64 in_3,
 22	u64 in_4, u64 in_5, u64 *out_1, u64 *out_2);
 23
 
 
 
 
 
 
 
 24BSS_STACK(4096);
 25
 26/* A buffer that may be edited by tools operating on a zImage binary so as to
 27 * edit the command line passed to vmlinux (by setting /chosen/bootargs).
 28 * The buffer is put in it's own section so that tools may locate it easier.
 29 */
 30
 31static char cmdline[BOOT_COMMAND_LINE_SIZE]
 32	__attribute__((__section__("__builtin_cmdline")));
 33
 34static void prep_cmdline(void *chosen)
 35{
 36	if (cmdline[0] == '\0')
 37		getprop(chosen, "bootargs", cmdline, BOOT_COMMAND_LINE_SIZE-1);
 38	else
 39		setprop_str(chosen, "bootargs", cmdline);
 40
 41	printf("cmdline: '%s'\n", cmdline);
 42}
 43
 44static void ps3_console_write(const char *buf, int len)
 45{
 46}
 47
 48static void ps3_exit(void)
 49{
 50	printf("ps3_exit\n");
 51
 52	/* lv1_panic will shutdown the lpar. */
 53
 54	lv1_panic(0); /* zero = do not reboot */
 55	while (1);
 56}
 57
 58static int ps3_repository_read_rm_size(u64 *rm_size)
 59{
 60	int result;
 61	u64 lpar_id;
 62	u64 ppe_id;
 63	u64 v2;
 64
 65	result = lv1_get_logical_partition_id(&lpar_id);
 66
 67	if (result)
 68		return -1;
 69
 70	result = lv1_get_logical_ppe_id(&ppe_id);
 71
 72	if (result)
 73		return -1;
 74
 75	/*
 76	 * n1: 0000000062690000 : ....bi..
 77	 * n2: 7075000000000000 : pu......
 78	 * n3: 0000000000000001 : ........
 79	 * n4: 726d5f73697a6500 : rm_size.
 80	*/
 81
 82	result = lv1_get_repository_node_value(lpar_id, 0x0000000062690000ULL,
 83		0x7075000000000000ULL, ppe_id, 0x726d5f73697a6500ULL, rm_size,
 84		&v2);
 85
 86	printf("%s:%d: ppe_id  %lu \n", __func__, __LINE__,
 87		(unsigned long)ppe_id);
 88	printf("%s:%d: lpar_id %lu \n", __func__, __LINE__,
 89		(unsigned long)lpar_id);
 90	printf("%s:%d: rm_size %llxh \n", __func__, __LINE__, *rm_size);
 91
 92	return result ? -1 : 0;
 93}
 94
 95void ps3_copy_vectors(void)
 96{
 97	extern char __system_reset_kernel[];
 98
 99	memcpy((void *)0x100, __system_reset_kernel, 512);
100	flush_cache((void *)0x100, 512);
101}
102
103void platform_init(void)
104{
105	const u32 heapsize = 0x1000000 - (u32)_end; /* 16MiB */
106	void *chosen;
107	unsigned long ft_addr;
108	u64 rm_size;
109
110	console_ops.write = ps3_console_write;
111	platform_ops.exit = ps3_exit;
112
113	printf("\n-- PS3 bootwrapper --\n");
114
115	simple_alloc_init(_end, heapsize, 32, 64);
116	fdt_init(_dtb_start);
117
118	chosen = finddevice("/chosen");
119
120	ps3_repository_read_rm_size(&rm_size);
121	dt_fixup_memory(0, rm_size);
122
123	if (&_initrd_end > &_initrd_start) {
124		setprop_val(chosen, "linux,initrd-start", (u32)(_initrd_start));
125		setprop_val(chosen, "linux,initrd-end", (u32)(_initrd_end));
126	}
127
128	prep_cmdline(chosen);
129
130	ft_addr = dt_ops.finalize();
131
132	ps3_copy_vectors();
133
134	printf(" flat tree at 0x%lx\n\r", ft_addr);
135
136	((kernel_entry_t)0)(ft_addr, 0, NULL);
137
138	ps3_exit();
139}
v4.17
 
  1/*
  2 *  PS3 bootwrapper support.
  3 *
  4 *  Copyright (C) 2007 Sony Computer Entertainment Inc.
  5 *  Copyright 2007 Sony Corp.
  6 *
  7 *  This program is free software; you can redistribute it and/or modify
  8 *  it under the terms of the GNU General Public License as published by
  9 *  the Free Software Foundation; version 2 of the License.
 10 *
 11 *  This program is distributed in the hope that it will be useful,
 12 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 13 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 14 *  GNU General Public License for more details.
 15 *
 16 *  You should have received a copy of the GNU General Public License
 17 *  along with this program; if not, write to the Free Software
 18 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 19 */
 20
 21#include <stdarg.h>
 22#include <stddef.h>
 23#include "types.h"
 24#include "elf.h"
 25#include "string.h"
 26#include "stdio.h"
 27#include "page.h"
 28#include "ops.h"
 29
 30extern int lv1_panic(u64 in_1);
 31extern int lv1_get_logical_partition_id(u64 *out_1);
 32extern int lv1_get_logical_ppe_id(u64 *out_1);
 33extern int lv1_get_repository_node_value(u64 in_1, u64 in_2, u64 in_3,
 34	u64 in_4, u64 in_5, u64 *out_1, u64 *out_2);
 35
 36#ifdef DEBUG
 37#define DBG(fmt...) printf(fmt)
 38#else
 39static inline int __attribute__ ((format (printf, 1, 2))) DBG(
 40	const char *fmt, ...) {return 0;}
 41#endif
 42
 43BSS_STACK(4096);
 44
 45/* A buffer that may be edited by tools operating on a zImage binary so as to
 46 * edit the command line passed to vmlinux (by setting /chosen/bootargs).
 47 * The buffer is put in it's own section so that tools may locate it easier.
 48 */
 49
 50static char cmdline[BOOT_COMMAND_LINE_SIZE]
 51	__attribute__((__section__("__builtin_cmdline")));
 52
 53static void prep_cmdline(void *chosen)
 54{
 55	if (cmdline[0] == '\0')
 56		getprop(chosen, "bootargs", cmdline, BOOT_COMMAND_LINE_SIZE-1);
 57	else
 58		setprop_str(chosen, "bootargs", cmdline);
 59
 60	printf("cmdline: '%s'\n", cmdline);
 61}
 62
 63static void ps3_console_write(const char *buf, int len)
 64{
 65}
 66
 67static void ps3_exit(void)
 68{
 69	printf("ps3_exit\n");
 70
 71	/* lv1_panic will shutdown the lpar. */
 72
 73	lv1_panic(0); /* zero = do not reboot */
 74	while (1);
 75}
 76
 77static int ps3_repository_read_rm_size(u64 *rm_size)
 78{
 79	int result;
 80	u64 lpar_id;
 81	u64 ppe_id;
 82	u64 v2;
 83
 84	result = lv1_get_logical_partition_id(&lpar_id);
 85
 86	if (result)
 87		return -1;
 88
 89	result = lv1_get_logical_ppe_id(&ppe_id);
 90
 91	if (result)
 92		return -1;
 93
 94	/*
 95	 * n1: 0000000062690000 : ....bi..
 96	 * n2: 7075000000000000 : pu......
 97	 * n3: 0000000000000001 : ........
 98	 * n4: 726d5f73697a6500 : rm_size.
 99	*/
100
101	result = lv1_get_repository_node_value(lpar_id, 0x0000000062690000ULL,
102		0x7075000000000000ULL, ppe_id, 0x726d5f73697a6500ULL, rm_size,
103		&v2);
104
105	printf("%s:%d: ppe_id  %lu \n", __func__, __LINE__,
106		(unsigned long)ppe_id);
107	printf("%s:%d: lpar_id %lu \n", __func__, __LINE__,
108		(unsigned long)lpar_id);
109	printf("%s:%d: rm_size %llxh \n", __func__, __LINE__, *rm_size);
110
111	return result ? -1 : 0;
112}
113
114void ps3_copy_vectors(void)
115{
116	extern char __system_reset_kernel[];
117
118	memcpy((void *)0x100, __system_reset_kernel, 512);
119	flush_cache((void *)0x100, 512);
120}
121
122void platform_init(void)
123{
124	const u32 heapsize = 0x1000000 - (u32)_end; /* 16MiB */
125	void *chosen;
126	unsigned long ft_addr;
127	u64 rm_size;
128
129	console_ops.write = ps3_console_write;
130	platform_ops.exit = ps3_exit;
131
132	printf("\n-- PS3 bootwrapper --\n");
133
134	simple_alloc_init(_end, heapsize, 32, 64);
135	fdt_init(_dtb_start);
136
137	chosen = finddevice("/chosen");
138
139	ps3_repository_read_rm_size(&rm_size);
140	dt_fixup_memory(0, rm_size);
141
142	if (_initrd_end > _initrd_start) {
143		setprop_val(chosen, "linux,initrd-start", (u32)(_initrd_start));
144		setprop_val(chosen, "linux,initrd-end", (u32)(_initrd_end));
145	}
146
147	prep_cmdline(chosen);
148
149	ft_addr = dt_ops.finalize();
150
151	ps3_copy_vectors();
152
153	printf(" flat tree at 0x%lx\n\r", ft_addr);
154
155	((kernel_entry_t)0)(ft_addr, 0, NULL);
156
157	ps3_exit();
158}