Subversion Repositories HelenOS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. /*
  2.  * Copyright (c) 2008 Jakub Jermar
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that the following conditions
  7.  * are met:
  8.  *
  9.  * - Redistributions of source code must retain the above copyright
  10.  *   notice, this list of conditions and the following disclaimer.
  11.  * - Redistributions in binary form must reproduce the above copyright
  12.  *   notice, this list of conditions and the following disclaimer in the
  13.  *   documentation and/or other materials provided with the distribution.
  14.  * - The name of the author may not be used to endorse or promote products
  15.  *   derived from this software without specific prior written permission.
  16.  *
  17.  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  18.  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  19.  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  20.  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  21.  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  22.  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  23.  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  24.  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25.  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  26.  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27.  */
  28.  
  29. /** @addtogroup sparc64
  30.  * @{
  31.  */
  32. /**
  33.  * @file
  34.  * @brief   Driver for the UPA to PCI bridge (Psycho).
  35.  */
  36.  
  37. #include <arch/drivers/psycho.h>
  38. #include <arch/trap/interrupt.h>
  39. #include <mm/page.h>
  40. #include <mm/slab.h>
  41. #include <arch/types.h>
  42. #include <genarch/ofw/ofw_tree.h>
  43.  
  44. #define PSYCHO_IGN      0x7c0
  45. #define PSYCHO_KEYBOARD_INR 0x29
  46.  
  47. psycho_t *psycho_a = NULL;
  48. psycho_t *psycho_b = NULL;
  49.  
  50. psycho_t *psycho_init(ofw_tree_node_t *node)
  51. {
  52.     psycho_t *psycho;
  53.     ofw_tree_property_t *prop;
  54.  
  55.     prop = ofw_tree_getprop(node, "reg");
  56.    
  57.     if (!prop || !prop->value)
  58.         return NULL;
  59.        
  60.     ofw_upa_reg_t *reg = &((ofw_upa_reg_t *) prop->value)[0]; /* XXX */
  61.  
  62.     uintptr_t paddr;
  63.     if (!ofw_upa_apply_ranges(node->parent, reg, &paddr))
  64.         return NULL;
  65.  
  66.     psycho = (psycho_t *) malloc(sizeof(psycho_t), FRAME_ATOMIC);
  67.     if (!psycho)
  68.         return NULL;
  69.  
  70.     psycho->regs = (uint64_t *) hw_map(paddr, reg->size);
  71.    
  72.     return psycho;
  73. }
  74.  
  75. void psycho_enable_interrupt(psycho_t *psycho, int inr)
  76. {
  77.     inr -= PSYCHO_IGN;
  78.     switch (inr) {
  79.     case PSYCHO_KEYBOARD_INR:
  80.         psycho->regs[0] = 1;    /* XXX */
  81.         break;
  82.     default:
  83.         panic("Unexpected INR (%d)\n", inr);
  84.         break;
  85.     }
  86. }
  87.  
  88. void psycho_clear_interrupt(psycho_t *psycho, int inr)
  89. {
  90.     inr -= PSYCHO_IGN;
  91.     switch (inr) {
  92.     case PSYCHO_KEYBOARD_INR:
  93.         psycho->regs[0] = 0;    /* XXX */
  94.         break;
  95.     default:
  96.         panic("Unexpected INR (%d)\n", inr);
  97.         break;
  98.     }
  99. }
  100.  
  101. /** @}
  102.  */
  103.