boot1.c (329175) | boot1.c (332154) |
---|---|
1/*- 2 * Copyright (c) 1998 Robert Nordier 3 * All rights reserved. 4 * Copyright (c) 2001 Robert Drehmel 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms are freely 8 * permitted provided that the above copyright notice and this 9 * paragraph and the following disclaimer are duplicated in all 10 * such forms. 11 * 12 * This software is provided "AS IS" and without any express or 13 * implied warranties, including, without limitation, the implied 14 * warranties of merchantability and fitness for a particular 15 * purpose. 16 */ 17 18#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1998 Robert Nordier 3 * All rights reserved. 4 * Copyright (c) 2001 Robert Drehmel 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms are freely 8 * permitted provided that the above copyright notice and this 9 * paragraph and the following disclaimer are duplicated in all 10 * such forms. 11 * 12 * This software is provided "AS IS" and without any express or 13 * implied warranties, including, without limitation, the implied 14 * warranties of merchantability and fitness for a particular 15 * purpose. 16 */ 17 18#include <sys/cdefs.h> |
19__FBSDID("$FreeBSD: stable/11/stand/powerpc/boot1.chrp/boot1.c 329175 2018-02-12 17:44:35Z kevans $"); | 19__FBSDID("$FreeBSD: stable/11/stand/powerpc/boot1.chrp/boot1.c 332154 2018-04-06 21:37:25Z kevans $"); |
20 21#include <sys/param.h> 22#include <sys/dirent.h> 23#include <machine/elf.h> 24#include <machine/stdarg.h> 25#include <machine/md_var.h> 26 27#include "paths.h" --- 21 unchanged lines hidden (view full) --- 49static unsigned int fsblks; 50 51static uint32_t fs_off; 52 53int main(int ac, char **av); 54 55static void exit(int) __dead2; 56static void load(const char *); | 20 21#include <sys/param.h> 22#include <sys/dirent.h> 23#include <machine/elf.h> 24#include <machine/stdarg.h> 25#include <machine/md_var.h> 26 27#include "paths.h" --- 21 unchanged lines hidden (view full) --- 49static unsigned int fsblks; 50 51static uint32_t fs_off; 52 53int main(int ac, char **av); 54 55static void exit(int) __dead2; 56static void load(const char *); |
57static int dskread(void *, u_int64_t, int); | 57static int dskread(void *, uint64_t, int); |
58 59static void usage(void); 60 61static void bcopy(const void *src, void *dst, size_t len); 62static void bzero(void *b, size_t len); 63 64static int domount(const char *device, int quiet); 65 --- 8 unchanged lines hidden (view full) --- 74static int __puts(const char *s, putc_func_t *putc, void *arg); 75static int __sputc(char c, void *arg); 76static char *__uitoa(char *buf, u_int val, int base); 77static char *__ultoa(char *buf, u_long val, int base); 78 79/* 80 * Open Firmware interface functions 81 */ | 58 59static void usage(void); 60 61static void bcopy(const void *src, void *dst, size_t len); 62static void bzero(void *b, size_t len); 63 64static int domount(const char *device, int quiet); 65 --- 8 unchanged lines hidden (view full) --- 74static int __puts(const char *s, putc_func_t *putc, void *arg); 75static int __sputc(char c, void *arg); 76static char *__uitoa(char *buf, u_int val, int base); 77static char *__ultoa(char *buf, u_long val, int base); 78 79/* 80 * Open Firmware interface functions 81 */ |
82typedef u_int32_t ofwcell_t; 83typedef u_int32_t u_ofwh_t; | 82typedef uint32_t ofwcell_t; 83typedef uint32_t u_ofwh_t; |
84typedef int (*ofwfp_t)(void *); 85ofwfp_t ofw; /* the prom Open Firmware entry */ 86ofwh_t chosenh; 87 88void ofw_init(void *, int, int (*)(void *), char *, int); 89static ofwh_t ofw_finddevice(const char *); 90static ofwh_t ofw_open(const char *); 91static int ofw_close(ofwh_t); 92static int ofw_getprop(ofwh_t, const char *, void *, size_t); 93static int ofw_setprop(ofwh_t, const char *, void *, size_t); 94static int ofw_read(ofwh_t, void *, size_t); 95static int ofw_write(ofwh_t, const void *, size_t); 96static int ofw_claim(void *virt, size_t len, u_int align); | 84typedef int (*ofwfp_t)(void *); 85ofwfp_t ofw; /* the prom Open Firmware entry */ 86ofwh_t chosenh; 87 88void ofw_init(void *, int, int (*)(void *), char *, int); 89static ofwh_t ofw_finddevice(const char *); 90static ofwh_t ofw_open(const char *); 91static int ofw_close(ofwh_t); 92static int ofw_getprop(ofwh_t, const char *, void *, size_t); 93static int ofw_setprop(ofwh_t, const char *, void *, size_t); 94static int ofw_read(ofwh_t, void *, size_t); 95static int ofw_write(ofwh_t, const void *, size_t); 96static int ofw_claim(void *virt, size_t len, u_int align); |
97static int ofw_seek(ofwh_t, u_int64_t); | 97static int ofw_seek(ofwh_t, uint64_t); |
98static void ofw_exit(void) __dead2; 99 100ofwh_t bootdevh; 101ofwh_t stdinh, stdouth; 102 103__asm(" \n\ 104 .data \n\ 105 .align 4 \n\ --- 211 unchanged lines hidden (view full) --- 317 if ((*ofw)(args)) { 318 printf("ofw_write: devh=0x%x buf=%p len=%u\n", devh, buf, len); 319 return (1); 320 } 321 return (0); 322} 323 324static int | 98static void ofw_exit(void) __dead2; 99 100ofwh_t bootdevh; 101ofwh_t stdinh, stdouth; 102 103__asm(" \n\ 104 .data \n\ 105 .align 4 \n\ --- 211 unchanged lines hidden (view full) --- 317 if ((*ofw)(args)) { 318 printf("ofw_write: devh=0x%x buf=%p len=%u\n", devh, buf, len); 319 return (1); 320 } 321 return (0); 322} 323 324static int |
325ofw_seek(ofwh_t devh, u_int64_t off) | 325ofw_seek(ofwh_t devh, uint64_t off) |
326{ 327 ofwcell_t args[] = { 328 (ofwcell_t)"seek", 329 3, 330 1, 331 (u_ofwh_t)devh, 332 off >> 32, 333 off, --- 202 unchanged lines hidden (view full) --- 536 __syncicache(p, ph.p_memsz); 537 } 538 ofw_close(bootdev); 539 (*(void (*)(void *, int, ofwfp_t, char *, int))eh.e_entry)(NULL, 0, 540 ofw,NULL,0); 541} 542 543static int | 326{ 327 ofwcell_t args[] = { 328 (ofwcell_t)"seek", 329 3, 330 1, 331 (u_ofwh_t)devh, 332 off >> 32, 333 off, --- 202 unchanged lines hidden (view full) --- 536 __syncicache(p, ph.p_memsz); 537 } 538 ofw_close(bootdev); 539 (*(void (*)(void *, int, ofwfp_t, char *, int))eh.e_entry)(NULL, 0, 540 ofw,NULL,0); 541} 542 543static int |
544dskread(void *buf, u_int64_t lba, int nblk) | 544dskread(void *buf, uint64_t lba, int nblk) |
545{ 546 /* 547 * The Open Firmware should open the correct partition for us. 548 * That means, if we read from offset zero on an open instance handle, 549 * we should read from offset zero of that partition. 550 */ 551 ofw_seek(bootdev, lba * DEV_BSIZE); 552 ofw_read(bootdev, buf, nblk * DEV_BSIZE); --- 224 unchanged lines hidden --- | 545{ 546 /* 547 * The Open Firmware should open the correct partition for us. 548 * That means, if we read from offset zero on an open instance handle, 549 * we should read from offset zero of that partition. 550 */ 551 ofw_seek(bootdev, lba * DEV_BSIZE); 552 ofw_read(bootdev, buf, nblk * DEV_BSIZE); --- 224 unchanged lines hidden --- |