Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / devices / serial / include / serial_mod.h
CommitLineData
920dae64
AT
1/*
2* ========== Copyright Header Begin ==========================================
3*
4* OpenSPARC T2 Processor File: serial_mod.h
5* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
6* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
7*
8* The above named program is free software; you can redistribute it and/or
9* modify it under the terms of the GNU General Public
10* License version 2 as published by the Free Software Foundation.
11*
12* The above named program is distributed in the hope that it will be
13* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15* General Public License for more details.
16*
17* You should have received a copy of the GNU General Public
18* License along with this work; if not, write to the Free Software
19* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
20*
21* ========== Copyright Header End ============================================
22*/
23/*
24 * Copyright 2004 by Sun Microsystems, Inc.
25 * All rights reserved.
26 *
27 * @(#)serial_mod.h 1.3 04/08/04
28 */
29#ifndef _SERIAL_MOD_H
30#define _SERIAL_MOD_H
31
32//#include "pci.h"
33#include "types.h"
34#include "pci_dev.h"
35#include "serial.h"
36#include "serial_impl.h"
37#include "dr.h"
38#include "mmi.h"
39#include "module.h"
40#include "arg.h"
41#include "serial_props.h"
42#include "system.h"
43
44class serialInterface{
45 public:
46 int portH;
47 virtual void chars_send(char *str, int portH) = 0;
48 virtual int reg_access(char *buf, uint64_t paddr, bool wr) = 0;
49};
50
51
52class Serial : public Module, public genericPciDev ,serialInterface {
53
54 private:
55 uint64_t pciMem32_size;
56
57
58 private:
59 serialT *msp;
60 uint64_t pciMem32_base;
61
62 bool dump(FILE* fp);
63 bool restore(FILE* fp);
64 serialT *allocation_obj();
65 void enq(channel_regs * rcv_regs, char c);
66 char deq(channel_regs * rcv_regs);
67 void char_input(uint8_t c, int portnum);
68 char rd_port(int portnum);
69 void wr_port(int portnum, uint8_t c);
70 uint8_t rd_control(int portnum);
71 void transmit(int portnum);
72 void channel_cmd(int portnum);
73 void status(int portnum);
74 void wr_control(int portnum, unsigned char buf);
75 void reset_scc();
76
77 bool isSystemConsole;
78 const char * termAredirect;
79 const char * termBredirect;
80
81 int portHandle[2];
82
83 char * ttyAname;
84 char * ttyBname;
85
86 FILE * termAfp;
87 FILE * termBfp;
88
89 int mapHandle2Port(int port){
90 if(port == portHandle[0])
91 return 0;
92 else if(port == portHandle[1])
93 return 1;
94 else
95 debug_err("%s illegal serial port number\n");
96 return -1;
97 }
98
99 char * display;
100
101 public:
102 void chars_send(char *str, int portnum);
103 int reg_access(char *buf, uint64_t paddr, bool wr);
104
105 Serial(const char *modname, const char *instance_name);
106 ~Serial();
107
108 public: // Module interface
109 const char *get_help();
110 bool parse_arg(const char *);
111 bool check_args();
112 void init_done();
113 void module_added(mmi_instance_t, const char*);
114 void module_deleted(mmi_instance_t, const char*);
115 void modinfo();
116 void *get_interface(const char*);
117 void get_dev_props();
118
119 private:
120 //override the genericPciDev virtual functions
121 mmi_instance_t pciDev_getInstance();
122 const char * pciDev_getName();
123 void pciDev_confAccessCb(bool_t wr, uint64_t offset, uint8_t size);
124
125 //override the pciTarget_mem32access function
126 pciXactnStatus pciTarget_mem32access(uint64_t offset, bool wr,uint64_t * buf, uint8_t size);
127
128 void initPci();
129};
130
131extern "C"{
132 void handleSerialIp(void *,char *, int);
133}
134
135
136#endif /* _SERIAL_MOD */