1 /*---------------------------------------------------------------------------*
2   Project:  TwlSDK - CP - include
3   File:     context.h
4 
5   Copyright 2003-2008 Nintendo.  All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain
8   proprietary information of Nintendo of America Inc. and/or Nintendo
9   Company Ltd., and are protected by Federal copyright law.  They may
10   not be disclosed to third parties or copied or duplicated in any form,
11   in whole or in part, without the prior written consent of Nintendo.
12 
13   $Date:: 2008-09-18#$
14   $Rev: 8573 $
15   $Author: okubata_ryoma $
16  *---------------------------------------------------------------------------*/
17 
18 #ifndef NITRO_CP_CONTEXT_H_
19 #define NITRO_CP_CONTEXT_H_
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 #ifdef SDK_NITRO
26 #include <nitro/ioreg.h>
27 #else
28 #include <twl/ioreg.h>
29 #endif
30 
31 #include <nitro/cp/divider.h>
32 
33 //----------------------------------------------------------------
34 typedef struct CPContext
35 {
36     u64     div_numer;
37     u64     div_denom;
38     u64     sqrt;
39     u16     div_mode;
40     u16     sqrt_mode;
41 }
42 CPContext;
43 
44 /*---------------------------------------------------------------------------*
45   Name:         CP_SaveContext
46 
47   Description:  Save current context into specified memory
48 
49   Arguments:    context   pointer to the memory to be stored the current context
50 
51   Returns:      None
52  *---------------------------------------------------------------------------*/
53 void    CP_SaveContext(CPContext *context);
54 
55 
56 /*---------------------------------------------------------------------------*
57   Name:         CP_RestoreContext
58 
59   Description:  Reload specified context as current context
60 
61   Arguments:    context   pointer to the memory to switch to the context
62 
63   Returns:      None
64  *---------------------------------------------------------------------------*/
65 void    CPi_RestoreContext(const CPContext *context);
CP_RestoreContext(const CPContext * context)66 static inline void CP_RestoreContext(const CPContext *context)
67 {
68     CPi_RestoreContext(context);
69     CP_WaitDiv();
70 }
71 
72 
73 
74 #ifdef __cplusplus
75 } /* extern "C" */
76 #endif
77 
78 
79 /* NITRO_CP_CONTEXT_H_ */
80 #endif
81