[parisc-linux-cvs] [PATCH] 32-bit PDC wrapper patch

Matthew Wilcox matthew@wil.cx
Wed, 14 Mar 2001 06:11:54 +0000


On Tue, Mar 13, 2001 at 06:41:31PM -0700, Ryan Bradetich wrote:
> Here is the patch.

I've never liked the PDC interface.  Too much magic, unnecessary
use of varargs... ick.  This only makes it worse :-)

Here's a proposed (I hope) simplification.  feedback welcome, as ever.

>  int pdc_chassis_disp(unsigned long disp)
>  {
> -	return mem_pdc_call(PDC_CHASSIS, PDC_CHASSIS_DISP, disp);
> +	return mem_pdc_call(PDC_ARG2_IS_NOT_RADDR, PDC_CHASSIS, PDC_CHASSIS_DISP, disp);
>  }

int pdc_chassis_disp(unsigned long disp)
{
	return mem_pdc_call3(PDC_CHASSIS, PDC_CHASSIS_DISP, disp);
}


>  int pdc_chassis_info(void *pdc_result, void *chassis_info, unsigned long len)
>  {
>  	ASSERT_ALIGN(pdc_result, 4);
>  	ASSERT_ALIGN(chassis_info, 4);
> -	return mem_pdc_call(PDC_CHASSIS,PDC_RETURN_CHASSIS_INFO, 
> -	        __pa(pdc_result), __pa(chassis_info), len);
> +	return mem_pdc_call(PDC_ARG2_IS_RADDR, PDC_CHASSIS, PDC_RETURN_CHASSIS_INFO,
> +			    __pa(pdc_result), __pa(chassis_info), len);
>  }

int pdc_chassis_info(void *pdc_result, void *chassis_info, unsigned long len)
{
	int result;
	ASSERT_ALIGN(pdc_result, 4);
	ASSERT_ALIGN(chassis_info, 4);
	result = mem_pdc_call5(PDC_CHASSIS,PDC_RETURN_CHASSIS_INFO,
		__pa(pdc_result), __pa(chassis_info), len);
	convert_to_wide(pdc_result);
}


etc.  And then:

#ifdef __LP64__
#define real_call real64_call_asm
#define MEM_PDC PAGE0->mem_pdc | PAGE0->mem_pdc_hi << 32
#else
#define real_call real32_call_asm
#define MEM_PDC PAGE0->mem_pdc
#endif

int mem_pdc_call5(long arg0, long arg1, long arg2, long arg3, long arg4)
{
	real_stack.arg4 = arg4;
	real_stack.arg3 = arg3;
	return mem_pdc_call3(arg0, arg1, arg2);
}

int mem_pdc_call3(long arg0, long arg1, long arg2)
{
	unsigned long flags, r;

	real_stack.arg0 = arg0;
	real_stack.arg1 = arg1;
	real_stack.arg2 = arg2;

	spin_lock_irqsave(&pdc_lock, flags);
	r = real_call(&real_stack.sp, &real_stack.arg0, MEM_PDC);
	spin_lock_irqrestore(&pdc_lock, flags);

	return r;
}

then real1.c is all but eliminated (merged into pdc.c) with probably a
stub left over for the benefit of the STI console.

Can these routines be called from interrupt context?

-- 
Revolutions do not require corporate support.