android_kernel_xiaomi_sm8350/arch/ppc/boot/of1275/claim.c
Paul Mackerras c49888203d powerpc: Fixes to get the Longtrail CHRP a bit further
Talk about buggy firmware...  the OF on the Longtrail returns 0
from the claim client service rather than -1 when the claim fails.
It also has no device_type on the /memory node and blows up if
the output buffer for package-to-path is too big.

This also fixes a bug with calling alloc_up with align == 0, where
we did _ALIGN_UP(alloc_bottom, 0) which will end up as 0.

Lastly, we now check the return value (in r3) from calling the
prom, and return -1 from call_prom if we get a negative value back.
That is supposed to indicate that the requested client service
doesn't exist.

Signed-off-by: Paul Mackerras <paulus@samba.org>
2005-10-26 21:52:53 +10:00

36 lines
792 B
C

/*
* Copyright (C) Paul Mackerras 1997.
* Copyright (C) Leigh Brown 2002.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*/
#include "of1275.h"
void *
claim(unsigned int virt, unsigned int size, unsigned int align)
{
struct prom_args {
char *service;
int nargs;
int nret;
unsigned int virt;
unsigned int size;
unsigned int align;
void *ret;
} args;
args.service = "claim";
args.nargs = 3;
args.nret = 1;
args.virt = virt;
args.size = size;
args.align = align;
args.ret = (void *) 0;
(*of_prom_entry)(&args);
return args.ret;
}