Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / devices / serial / include / serial_mod.h
/*
* ========== Copyright Header Begin ==========================================
*
* OpenSPARC T2 Processor File: serial_mod.h
* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
*
* The above named program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License version 2 as published by the Free Software Foundation.
*
* The above named program is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this work; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
* ========== Copyright Header End ============================================
*/
/*
* Copyright 2004 by Sun Microsystems, Inc.
* All rights reserved.
*
* @(#)serial_mod.h 1.3 04/08/04
*/
#ifndef _SERIAL_MOD_H
#define _SERIAL_MOD_H
//#include "pci.h"
#include "types.h"
#include "pci_dev.h"
#include "serial.h"
#include "serial_impl.h"
#include "dr.h"
#include "mmi.h"
#include "module.h"
#include "arg.h"
#include "serial_props.h"
#include "system.h"
class serialInterface{
public:
int portH;
virtual void chars_send(char *str, int portH) = 0;
virtual int reg_access(char *buf, uint64_t paddr, bool wr) = 0;
};
class Serial : public Module, public genericPciDev ,serialInterface {
private:
uint64_t pciMem32_size;
private:
serialT *msp;
uint64_t pciMem32_base;
bool dump(FILE* fp);
bool restore(FILE* fp);
serialT *allocation_obj();
void enq(channel_regs * rcv_regs, char c);
char deq(channel_regs * rcv_regs);
void char_input(uint8_t c, int portnum);
char rd_port(int portnum);
void wr_port(int portnum, uint8_t c);
uint8_t rd_control(int portnum);
void transmit(int portnum);
void channel_cmd(int portnum);
void status(int portnum);
void wr_control(int portnum, unsigned char buf);
void reset_scc();
bool isSystemConsole;
const char * termAredirect;
const char * termBredirect;
int portHandle[2];
char * ttyAname;
char * ttyBname;
FILE * termAfp;
FILE * termBfp;
int mapHandle2Port(int port){
if(port == portHandle[0])
return 0;
else if(port == portHandle[1])
return 1;
else
debug_err("%s illegal serial port number\n");
return -1;
}
char * display;
public:
void chars_send(char *str, int portnum);
int reg_access(char *buf, uint64_t paddr, bool wr);
Serial(const char *modname, const char *instance_name);
~Serial();
public: // Module interface
const char *get_help();
bool parse_arg(const char *);
bool check_args();
void init_done();
void module_added(mmi_instance_t, const char*);
void module_deleted(mmi_instance_t, const char*);
void modinfo();
void *get_interface(const char*);
void get_dev_props();
private:
//override the genericPciDev virtual functions
mmi_instance_t pciDev_getInstance();
const char * pciDev_getName();
void pciDev_confAccessCb(bool_t wr, uint64_t offset, uint8_t size);
//override the pciTarget_mem32access function
pciXactnStatus pciTarget_mem32access(uint64_t offset, bool wr,uint64_t * buf, uint8_t size);
void initPci();
};
extern "C"{
void handleSerialIp(void *,char *, int);
}
#endif /* _SERIAL_MOD */