ia64/xen-unstable

changeset 9316:ccb437f2ed4e

[IA64] Replace huge if/else if with a switch.

Signed-off-by: Tristan Gingold <tristan.gingold@bull.net>
author awilliam@xenbuild.aw
date Mon Mar 20 09:53:17 2006 -0700 (2006-03-20)
parents d5b1bc047540
children 1dc45879fa5c
files xen/arch/ia64/xen/dom_fw.c
line diff
     1.1 --- a/xen/arch/ia64/xen/dom_fw.c	Mon Mar 20 09:33:38 2006 -0700
     1.2 +++ b/xen/arch/ia64/xen/dom_fw.c	Mon Mar 20 09:53:17 2006 -0700
     1.3 @@ -106,12 +106,9 @@ sal_emulator (long index, unsigned long 
     1.4  	long r11 = 0;
     1.5  	long status;
     1.6  
     1.7 -	/*
     1.8 -	 * Don't do a "switch" here since that gives us code that
     1.9 -	 * isn't self-relocatable.
    1.10 -	 */
    1.11  	status = 0;
    1.12 -	if (index == SAL_FREQ_BASE) {
    1.13 +	switch (index) {
    1.14 +	    case SAL_FREQ_BASE:
    1.15  		if (!running_on_sim)
    1.16  			status = ia64_sal_freq_base(in1,&r9,&r10);
    1.17  		else switch (in1) {
    1.18 @@ -131,15 +128,18 @@ sal_emulator (long index, unsigned long 
    1.19  			status = -1;
    1.20  			break;
    1.21  		}
    1.22 -	} else if (index == SAL_PCI_CONFIG_READ) {
    1.23 +		break;
    1.24 +	    case SAL_PCI_CONFIG_READ:
    1.25  		if (current->domain == dom0) {
    1.26  			u64 value;
    1.27  			// note that args 2&3 are swapped!!
    1.28  			status = ia64_sal_pci_config_read(in1,in3,in2,&value);
    1.29  			r9 = value;
    1.30  		}
    1.31 -		else printf("NON-PRIV DOMAIN CALLED SAL_PCI_CONFIG_READ\n");
    1.32 -	} else if (index == SAL_PCI_CONFIG_WRITE) {
    1.33 +		else
    1.34 +		     printf("NON-PRIV DOMAIN CALLED SAL_PCI_CONFIG_READ\n");
    1.35 +		break;
    1.36 +	    case SAL_PCI_CONFIG_WRITE:
    1.37  		if (current->domain == dom0) {
    1.38  			if (((in1 & ~0xffffffffUL) && (in4 == 0)) ||
    1.39  			    (in4 > 1) ||
    1.40 @@ -149,28 +149,40 @@ sal_emulator (long index, unsigned long 
    1.41  			// note that args are in a different order!!
    1.42  			status = ia64_sal_pci_config_write(in1,in4,in2,in3);
    1.43  		}
    1.44 -		else printf("NON-PRIV DOMAIN CALLED SAL_PCI_CONFIG_WRITE\n");
    1.45 -	} else if (index == SAL_SET_VECTORS) {
    1.46 +		else
    1.47 +		     printf("NON-PRIV DOMAIN CALLED SAL_PCI_CONFIG_WRITE\n");
    1.48 +		break;
    1.49 +	    case SAL_SET_VECTORS:
    1.50  		printf("*** CALLED SAL_SET_VECTORS.  IGNORED...\n");
    1.51 -	} else if (index == SAL_GET_STATE_INFO) {
    1.52 +		break;
    1.53 +	    case SAL_GET_STATE_INFO:
    1.54  		printf("*** CALLED SAL_GET_STATE_INFO.  IGNORED...\n");
    1.55 -	} else if (index == SAL_GET_STATE_INFO_SIZE) {
    1.56 +		break;
    1.57 +	    case SAL_GET_STATE_INFO_SIZE:
    1.58  		printf("*** CALLED SAL_GET_STATE_INFO_SIZE.  IGNORED...\n");
    1.59 -	} else if (index == SAL_CLEAR_STATE_INFO) {
    1.60 +		break;
    1.61 +	    case SAL_CLEAR_STATE_INFO:
    1.62  		printf("*** CALLED SAL_CLEAR_STATE_INFO.  IGNORED...\n");
    1.63 -	} else if (index == SAL_MC_RENDEZ) {
    1.64 +		break;
    1.65 +	    case SAL_MC_RENDEZ:
    1.66  		printf("*** CALLED SAL_MC_RENDEZ.  IGNORED...\n");
    1.67 -	} else if (index == SAL_MC_SET_PARAMS) {
    1.68 +		break;
    1.69 +	    case SAL_MC_SET_PARAMS:
    1.70  		printf("*** CALLED SAL_MC_SET_PARAMS.  IGNORED...\n");
    1.71 -	} else if (index == SAL_CACHE_FLUSH) {
    1.72 +		break;
    1.73 +	    case SAL_CACHE_FLUSH:
    1.74  		printf("*** CALLED SAL_CACHE_FLUSH.  IGNORED...\n");
    1.75 -	} else if (index == SAL_CACHE_INIT) {
    1.76 +		break;
    1.77 +	    case SAL_CACHE_INIT:
    1.78  		printf("*** CALLED SAL_CACHE_INIT.  IGNORED...\n");
    1.79 -	} else if (index == SAL_UPDATE_PAL) {
    1.80 +		break;
    1.81 +	    case SAL_UPDATE_PAL:
    1.82  		printf("*** CALLED SAL_UPDATE_PAL.  IGNORED...\n");
    1.83 -	} else {
    1.84 +		break;
    1.85 +	    default:
    1.86  		printf("*** CALLED SAL_ WITH UNKNOWN INDEX.  IGNORED...\n");
    1.87  		status = -1;
    1.88 +		break;
    1.89  	}
    1.90  	return ((struct sal_ret_values) {status, r9, r10, r11});
    1.91  }
    1.92 @@ -183,8 +195,9 @@ xen_pal_emulator(unsigned long index, u6
    1.93  	unsigned long r11 = 0;
    1.94  	long status = -1;
    1.95  
    1.96 -	if (running_on_sim) return pal_emulator_static(index);
    1.97 -	printk("xen_pal_emulator: index=%lu\n", index);
    1.98 +	if (running_on_sim)
    1.99 +		return pal_emulator_static(index);
   1.100 +
   1.101  	// pal code must be mapped by a TR when pal is called, however
   1.102  	// calls are rare enough that we will map it lazily rather than
   1.103  	// at every context switch