/* 
 * Copyright 2011 Stefan Lankes, Chair for Operating Systems,
 *                               RWTH Aachen University
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * This file is part of MetalSVM. 
 */

#ifndef __HAVE_RCKEMAC_H__
#define __HAVE_RCKEMAC_H__

#include <metalsvm/stddef.h>
#include <metalsvm/mailbox.h>

#if defined(CONFIG_LWIP) && defined(CONFIG_ROCKCREEK)

/*
 * Helper struct to hold private data used to operate your ethernet interface.
 */
typedef struct rckemacif {
	struct eth_addr *ethaddr;
	/* Add whatever per-interface state that is needed here. */
	uint8_t*	rx_buffer;
	uint32_t	rx_buffer_max;
        uint32_t	rx_read_offset;
	uint8_t*	tx_buffer;
        uint32_t	tx_buffer_max;
        uint32_t	tx_write_offset;
	void*		irq_address;
	uint32_t	core;
	uint32_t	num_emac;
	mailbox_ptr_t	mbox;
} rckemacif_t;

/*
 * Wait for incoming messages.
 *
 * poll = 0 : wait blocks until a message is received
 * poll != 0: non-blocking wait 
 */
err_t rckemacif_wait(struct netif* netif, uint32_t poll);

/*
 * Initialize the eMAC network driver
 */
err_t rckemacif_init(struct netif* netif);

#endif

#endif