Fri Aug 30 00:01:33 2019 UTC ()
Only set #address-cells and #size-cells properties on /chosen if we are
fabricating a devicetree (ACPI mode). Fixes PR# 54494


(jmcneill)
diff -r1.18 -r1.19 src/sys/stand/efiboot/efifdt.c

cvs diff -r1.18 -r1.19 src/sys/stand/efiboot/efifdt.c (expand / switch to unified diff)

--- src/sys/stand/efiboot/efifdt.c 2019/08/01 13:11:16 1.18
+++ src/sys/stand/efiboot/efifdt.c 2019/08/30 00:01:33 1.19
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: efifdt.c,v 1.18 2019/08/01 13:11:16 jmcneill Exp $ */ 1/* $NetBSD: efifdt.c,v 1.19 2019/08/30 00:01:33 jmcneill Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2019 Jason R. Thorpe 4 * Copyright (c) 2019 Jason R. Thorpe
5 * Copyright (c) 2018 Jared McNeill <jmcneill@invisible.ca> 5 * Copyright (c) 2018 Jared McNeill <jmcneill@invisible.ca>
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
@@ -282,28 +282,35 @@ efi_fdt_gop(void) @@ -282,28 +282,35 @@ efi_fdt_gop(void)
282 printf("GOP: PixelBitmask R 0x%x G 0x%x B 0x%x Res 0x%x\n", 282 printf("GOP: PixelBitmask R 0x%x G 0x%x B 0x%x Res 0x%x\n",
283 mode->Info->PixelInformation.RedMask, 283 mode->Info->PixelInformation.RedMask,
284 mode->Info->PixelInformation.GreenMask, 284 mode->Info->PixelInformation.GreenMask,
285 mode->Info->PixelInformation.BlueMask, 285 mode->Info->PixelInformation.BlueMask,
286 mode->Info->PixelInformation.ReservedMask); 286 mode->Info->PixelInformation.ReservedMask);
287 printf("GOP: Pixels per scanline %d\n", mode->Info->PixelsPerScanLine); 287 printf("GOP: Pixels per scanline %d\n", mode->Info->PixelsPerScanLine);
288#endif 288#endif
289 289
290 if (mode->Info->PixelFormat == PixelBltOnly) { 290 if (mode->Info->PixelFormat == PixelBltOnly) {
291 printf("GOP: PixelBltOnly pixel format not supported\n"); 291 printf("GOP: PixelBltOnly pixel format not supported\n");
292 continue; 292 continue;
293 } 293 }
294 294
 295 fdt_setprop_u32(fdt_data,
 296 fdt_path_offset(fdt_data, FDT_CHOSEN_NODE_PATH), "#address-cells", 2);
 297 fdt_setprop_u32(fdt_data,
 298 fdt_path_offset(fdt_data, FDT_CHOSEN_NODE_PATH), "#size-cells", 2);
 299 fdt_setprop_empty(fdt_data,
 300 fdt_path_offset(fdt_data, FDT_CHOSEN_NODE_PATH), "ranges");
 301
295 snprintf(buf, sizeof(buf), "framebuffer@%" PRIx64, mode->FrameBufferBase); 302 snprintf(buf, sizeof(buf), "framebuffer@%" PRIx64, mode->FrameBufferBase);
296 fb = fdt_add_subnode(fdt_data, fdt_path_offset(fdt_data, "/chosen"), buf); 303 fb = fdt_add_subnode(fdt_data, fdt_path_offset(fdt_data, FDT_CHOSEN_NODE_PATH), buf);
297 if (fb < 0) 304 if (fb < 0)
298 panic("FDT: Failed to create framebuffer node"); 305 panic("FDT: Failed to create framebuffer node");
299 306
300 fdt_appendprop_string(fdt_data, fb, "compatible", "simple-framebuffer"); 307 fdt_appendprop_string(fdt_data, fb, "compatible", "simple-framebuffer");
301 fdt_appendprop_string(fdt_data, fb, "status", "okay"); 308 fdt_appendprop_string(fdt_data, fb, "status", "okay");
302 fdt_appendprop_u64(fdt_data, fb, "reg", mode->FrameBufferBase); 309 fdt_appendprop_u64(fdt_data, fb, "reg", mode->FrameBufferBase);
303 fdt_appendprop_u64(fdt_data, fb, "reg", mode->FrameBufferSize); 310 fdt_appendprop_u64(fdt_data, fb, "reg", mode->FrameBufferSize);
304 fdt_appendprop_u32(fdt_data, fb, "width", mode->Info->HorizontalResolution); 311 fdt_appendprop_u32(fdt_data, fb, "width", mode->Info->HorizontalResolution);
305 fdt_appendprop_u32(fdt_data, fb, "height", mode->Info->VerticalResolution); 312 fdt_appendprop_u32(fdt_data, fb, "height", mode->Info->VerticalResolution);
306 fdt_appendprop_u32(fdt_data, fb, "stride", mode->Info->PixelsPerScanLine * 4); /* XXX */ 313 fdt_appendprop_u32(fdt_data, fb, "stride", mode->Info->PixelsPerScanLine * 4); /* XXX */
307 fdt_appendprop_string(fdt_data, fb, "format", "a8b8g8r8"); 314 fdt_appendprop_string(fdt_data, fb, "format", "a8b8g8r8");
308 315
309 snprintf(buf, sizeof(buf), "/chosen/framebuffer@%" PRIx64, mode->FrameBufferBase); 316 snprintf(buf, sizeof(buf), "/chosen/framebuffer@%" PRIx64, mode->FrameBufferBase);
@@ -317,30 +324,26 @@ efi_fdt_gop(void) @@ -317,30 +324,26 @@ efi_fdt_gop(void)
317void 324void
318efi_fdt_bootargs(const char *bootargs) 325efi_fdt_bootargs(const char *bootargs)
319{ 326{
320 struct efi_block_part *bpart = efi_block_boot_part(); 327 struct efi_block_part *bpart = efi_block_boot_part();
321 uint8_t macaddr[6]; 328 uint8_t macaddr[6];
322 int chosen; 329 int chosen;
323 330
324 chosen = fdt_path_offset(fdt_data, FDT_CHOSEN_NODE_PATH); 331 chosen = fdt_path_offset(fdt_data, FDT_CHOSEN_NODE_PATH);
325 if (chosen < 0) 332 if (chosen < 0)
326 chosen = fdt_add_subnode(fdt_data, fdt_path_offset(fdt_data, "/"), FDT_CHOSEN_NODE_NAME); 333 chosen = fdt_add_subnode(fdt_data, fdt_path_offset(fdt_data, "/"), FDT_CHOSEN_NODE_NAME);
327 if (chosen < 0) 334 if (chosen < 0)
328 panic("FDT: Failed to create " FDT_CHOSEN_NODE_PATH " node"); 335 panic("FDT: Failed to create " FDT_CHOSEN_NODE_PATH " node");
329 336
330 fdt_setprop_u32(fdt_data, chosen, "#address-cells", 2); 
331 fdt_setprop_u32(fdt_data, chosen, "#size-cells", 2); 
332 fdt_setprop_empty(fdt_data, chosen, "ranges"); 
333 
334 if (*bootargs) 337 if (*bootargs)
335 fdt_setprop_string(fdt_data, chosen, "bootargs", bootargs); 338 fdt_setprop_string(fdt_data, chosen, "bootargs", bootargs);
336 339
337 if (bpart) { 340 if (bpart) {
338 switch (bpart->type) { 341 switch (bpart->type) {
339 case EFI_BLOCK_PART_DISKLABEL: 342 case EFI_BLOCK_PART_DISKLABEL:
340 fdt_setprop(fdt_data, chosen, "netbsd,mbr", 343 fdt_setprop(fdt_data, chosen, "netbsd,mbr",
341 bpart->hash, sizeof(bpart->hash)); 344 bpart->hash, sizeof(bpart->hash));
342 fdt_setprop_u32(fdt_data, chosen, "netbsd,partition", 345 fdt_setprop_u32(fdt_data, chosen, "netbsd,partition",
343 bpart->index); 346 bpart->index);
344 break; 347 break;
345 case EFI_BLOCK_PART_GPT: 348 case EFI_BLOCK_PART_GPT:
346 if (bpart->gpt.ent.ent_name[0] == 0x0000) { 349 if (bpart->gpt.ent.ent_name[0] == 0x0000) {