Annotation of qemu/roms/SLOF/rtas/rtas_call.c, revision 1.1.1.1

1.1       root        1: /******************************************************************************
                      2:  * Copyright (c) 2004, 2008 IBM Corporation
                      3:  * All rights reserved.
                      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
                      8:  *
                      9:  * Contributors:
                     10:  *     IBM Corporation - initial implementation
                     11:  *****************************************************************************/
                     12: 
                     13: #include <stdint.h>
                     14: #include <rtas.h>
                     15: #include "rtas_table.h"
                     16: 
                     17: 
                     18: //#define _RTAS_TRACE
                     19: //#define _RTAS_COUNT_CALLS
                     20: 
                     21: 
                     22: #ifdef _RTAS_COUNT_CALLS
                     23: int rtas_callcount[0x40] __attribute__((aligned (16)));
                     24: #endif
                     25: 
                     26: /* rtas_config is used to store the run-time configuration flags (which are
                     27:  * provided by SLOF during instantiate-rtas) */
                     28: long rtas_config;
                     29: 
                     30: 
                     31: /* 
                     32: Function: rtas_call
                     33:        Input:
                     34:                rtas_args: pointer to RTAS arguments structure
                     35:        Output:
                     36:                
                     37: Decription: Handle RTAS call. This C function is called
                     38:                from the asm function rtas_entry.
                     39: */
                     40: 
                     41: void
                     42: rtas_call (rtas_args_t *rtas_args)
                     43: {
                     44:        int idx;
                     45: 
                     46: #ifdef _RTAS_COUNT_CALLS
                     47:        /* Count how often every RTAS function is called. */
                     48:        if (rtas_args->token < (int)(sizeof(rtas_callcount)/sizeof(rtas_callcount[0]))) {
                     49:                static int callcount_initialized = 0;
                     50:                /* If the array is used the first time, we have to set all entries to 0 */
                     51:                if (!callcount_initialized) {
                     52:                        unsigned int i;
                     53:                        callcount_initialized = 1;
                     54:                        for (i = 0; i < sizeof(rtas_callcount)/sizeof(rtas_callcount[0]); i++)
                     55:                                rtas_callcount[i] = 0;
                     56:                }
                     57:                /* Increment the counter of the RTAS call */
                     58:                rtas_callcount[rtas_args->token] += 1;
                     59:        }
                     60: #endif
                     61: 
                     62: #ifdef _RTAS_TRACE
                     63:        unsigned int parCnt = rtas_args->nargs;
                     64:        unsigned int *pInt = rtas_args->args;
                     65:        printf("\n\r*** rtas_call=0x%x", rtas_args->token);
                     66: #ifdef _RTAS_COUNT_CALLS
                     67:        printf(" count=0x%x", rtas_callcount[rtas_args->token]);
                     68: #endif
                     69:        printf(" len=0x%x", parCnt);
                     70:        printf("\n\r ");
                     71:        while(parCnt--) {
                     72:                printf("0x%x ", *pInt++);
                     73:        }
                     74: #endif
                     75: 
                     76:        idx = rtas_args->token - 1;
                     77: 
                     78:        /* Check if there's a function for the token: */
                     79:        if (idx >= 0 && idx < rtas_func_tab_size
                     80:            && rtas_func_tab[idx].func != NULL) {
                     81:                /* Now jump to the RTAS function: */
                     82:                rtas_func_tab[idx].func(rtas_args);
                     83:        }
                     84:        else {
                     85:                /* We didn't find a function - return error code: */
                     86:                rtas_args->args[rtas_args->nargs] = -1;
                     87:        }
                     88: 
                     89: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.