]> rtime.felk.cvut.cz Git - l4.git/blob - kernel/fiasco/src/lib/uart/ppc32/uart_mpc52xx.h
update
[l4.git] / kernel / fiasco / src / lib / uart / ppc32 / uart_mpc52xx.h
1 #ifndef L4_CXX_UART_MPC52XX_H__
2 #define L4_CXX_UART_MPC52XX_H__
3
4 #include "uart_base.h"
5 #include "of1275.h"
6
7 namespace L4
8 {
9   class Uart_mpc52xx : public Uart
10   {
11   private:
12     typedef unsigned char  u8;
13     typedef unsigned short u16;
14     typedef unsigned int   u32;
15
16     /**
17      * PSC registers
18      */
19     //psc + 0x00, size u8
20     unsigned long mode() const
21     { return _psc_base; }
22
23     //psc + 0x04, size u16
24     unsigned long status() const
25     { return _psc_base + 0x04; }
26
27     //psc + 0x08, size u8
28     unsigned long command() const
29     { return _psc_base + 0x08; }
30
31     //psc + 0x0c, size u32
32     unsigned long buffer() const
33     { return _psc_base + 0x0c; }
34
35     //psc + 0x14, size u16
36     unsigned long imr() const
37     { return _psc_base + 0x14; }
38
39     unsigned long sicr() const
40     { return _psc_base + 0x44; }
41
42     template < typename T >
43     void wr(unsigned long addr, T val) const;
44
45     template < typename T > 
46     T rd(unsigned long addr) const;
47
48     template < typename T >
49     void wr_dirty(unsigned long addr, T val) const;
50
51     template < typename T > 
52     T rd_dirty(unsigned long addr) const;
53
54     inline void mpc52xx_out_char(char c) const;
55  
56     unsigned long _psc_base;
57   public:
58     Uart_mpc52xx(int rx_irq, int tx_irq) : Uart(rx_irq, tx_irq) {}
59     bool startup(unsigned long base);
60     void shutdown();
61     bool enable_rx_irq(bool enable = true);
62     bool enable_tx_irq(bool enable = true);
63     bool change_mode(Transfer_mode m, Baud_rate r);
64     int get_char(bool blocking = true) const;
65     int char_avail() const;
66     inline void out_char(char c) const;
67     int write(char const *s, unsigned long count) const;
68   };
69 };
70
71 #endif