# $QNXLicenseC: 
# Copyright 2007, 2008, QNX Software Systems.  
# 
# Licensed under the Apache License, Version 2.0 (the "License"). You  
# may not reproduce, modify or distribute this software except in  
# compliance with the License. You may obtain a copy of the License  
# at: http://www.apache.org/licenses/LICENSE-2.0  
#  
# Unless required by applicable law or agreed to in writing, software  
# distributed under the License is distributed on an "AS IS" basis,  
# WITHOUT WARRANTIES OF ANY KIND, either express or implied. 
# 
# This file may contain contributions from others, either as  
# contributors under the License or as licensors under other terms.   
# Please review this entire file for other proprietary rights or license  
# notices, as well as the QNX Development Suite License Guide at  
# http://licensing.qnx.com/license-guide/ for other information. 
# $



#
# An entry point for a hardware kernel callout.
# It may be called by an interrupt handler.
# This code MUST be position independant.
#

	.include "callout.ah"

		
patcher:
	# R3: syspage paddr
	# R4: syspage vaddr
	# R5: rtn dst offset
	# R6: r/w offset
	# R7: patch data
	# R8: rtn src

	stwu    %r1, -32(%r1)
	mflr    %r0
	stw     %r31, 28(%r1)
	stw     %r0, 36(%r1)

	add     %r31,%r3,%r5

	loadi	%r4, 0xF8000000
	loadi   %r3, 32
	bl      callout_io_map

	sth     %r3, 6(%r31)
	srwi    %r3,%r3, 16
	sth     %r3, 2(%r31)

	lwz     %r0, 36(%r1)
	mtlr    %r0
	lwz     %r31, 28(%r1)
	addi    %r1, %r1, 32
	blr


CALLOUT_START	reboot_mpc8323rdb, 0, patcher
	lis		%r4, 0x1234
	ori		%r4, %r4, 0x5678
	
	#disable interrupts
	loadi	%r9,PPC_MSR_EE
	mfmsr	%r8
	andc	%r9,%r8,%r9
	mtmsr	%r9
	isync

	lbz		%r0, 7(%r4)
	rlwinm	%r6, %r0, 0, 24, 30
	stb		%r6, 7(%r4)

1:
	b		1b
CALLOUT_END		reboot_mpc8323rdb
