1 /******************************************************************************
2 * Copyright (c) 2004, 2008 IBM Corporation
4 * This program and the accompanying materials
5 * are made available under the terms of the BSD License
6 * which accompanies this distribution, and is available at
7 * http://www.opensource.org/licenses/bsd-license.php
10 * IBM Corporation - initial implementation
11 *****************************************************************************/
15 #include "rtas_table.h"
19 //#define _RTAS_COUNT_CALLS
22 #ifdef _RTAS_COUNT_CALLS
23 int rtas_callcount[0x40] __attribute__((aligned (16)));
26 /* rtas_config is used to store the run-time configuration flags (which are
27 * provided by SLOF during instantiate-rtas) */
32 void rtas_call (rtas_args_t *rtas_args);
38 rtas_args: pointer to RTAS arguments structure
41 Decription: Handle RTAS call. This C function is called
42 from the asm function rtas_entry.
46 rtas_call (rtas_args_t *rtas_args)
50 #ifdef _RTAS_COUNT_CALLS
51 /* Count how often every RTAS function is called. */
52 if (rtas_args->token < (int)(sizeof(rtas_callcount)/sizeof(rtas_callcount[0]))) {
53 static int callcount_initialized = 0;
54 /* If the array is used the first time, we have to set all entries to 0 */
55 if (!callcount_initialized) {
57 callcount_initialized = 1;
58 for (i = 0; i < sizeof(rtas_callcount)/sizeof(rtas_callcount[0]); i++)
59 rtas_callcount[i] = 0;
61 /* Increment the counter of the RTAS call */
62 rtas_callcount[rtas_args->token] += 1;
67 unsigned int parCnt = rtas_args->nargs;
68 unsigned int *pInt = rtas_args->args;
69 printf("\n\r*** rtas_call=0x%x", rtas_args->token);
70 #ifdef _RTAS_COUNT_CALLS
71 printf(" count=0x%x", rtas_callcount[rtas_args->token]);
73 printf(" len=0x%x", parCnt);
76 printf("0x%x ", *pInt++);
80 idx = rtas_args->token - 1;
82 /* Check if there's a function for the token: */
83 if (idx >= 0 && idx < rtas_func_tab_size
84 && rtas_func_tab[idx].func != NULL) {
85 /* Now jump to the RTAS function: */
86 rtas_func_tab[idx].func(rtas_args);
89 /* We didn't find a function - return error code: */
90 rtas_args->args[rtas_args->nargs] = -1;