/*
    Copyright 2000 (c) by David Schweikert,
    Swiss Federal Institute of Technology,
    Computer Engineering and Networks Laboratory.
 
    TOPSY -- A Teachable Operating System.
             Implementation of a tiny and simple
             micro kernel for teaching purposes.
 
    For further information, please visit http://www.tik.ee.ethz.ch/~topsy
 
    This software is provided under the terms of the GNU General Public 
    Licence. A full copy of the GNU GPL is provided in the file COPYING 
    found in the development root of Topsy.
*/
/*
	
    File:                  $Source: /home/ruf/cvs_Topsy/cvs/Topsy/IO/Drivers/Ethertap.h,v $
    Author(s):             
    Affiliation:           ETH Zuerich, TIK
    Version:               $Revision: 2922 $
    Creation Date:         
    Last Date of Change:   $Date: 2007-03-19 17:48:52 +0100 (Mon, 19 Mär 2007) $      by: $Author: baderma $
 
 
    $Log: Ethertap.h,v $
    Revision 1.3  2000/11/15 09:50:04  ruf
    IO/Drivers: Directory Cleaning
 
    Revision 1.2  2000/04/05 12:04:57  gfa
    *** empty log message ***
 
    Revision 1.1  2000/03/31 17:50:32  gfa
    Merged with /Net from several term projects
 
 
*/

#ifndef _ETHERTAP_H
#define _ETHERTAP_H

#include "Topsy.h"
#include "MMHeapMemory.h"
#include "IODevice.h"
#include "Configuration.h"

#define ETHERTAP_BASE              0xbff00000
#define ETHERTAP_STATUS_REGISTER   0x000
#define ETHERTAP_CONTROL_REGISTER  0x004
#define ETHERTAP_HW_ADDRESS        0x010
#define ETHERTAP_RX_SIZE           0x020
#define ETHERTAP_RX_DATA           0x024
#define ETHERTAP_RX_END            0x7FF
#define ETHERTAP_TX_SIZE           0x800
#define ETHERTAP_TX_DATA           0x804
#define ETHERTAP_TX_END            0xFFF

#define ETHERTAP_SEND_MASK         0x01 // Control register
#define ETHERTAP_READ_MASK         0x02
#define ETHERTAP_RECV_MASK         0x01 // Status register

#define ETHERTAP_FLAG_FRAGMENT     0x01

typedef struct EthertapDesc_t
{
  ThreadId subscribed;
  int fragment;
  unsigned long flags;
}
EthertapDesc;

typedef EthertapDesc* Ethertap;

void  ethertap_interruptHandler(IODevice this);
Error ethertap_init(IODevice this);
Error ethertap_read(IODevice this, ThreadId threadId, char* buffer, long int* size);
Error ethertap_write(IODevice this, ThreadId threadId, char* buffer, long int* size);
Error ethertap_close(IODevice this);
void  ethertap_handleMsg(IODevice this, Message *msg);

#endif
