Commit 40bc1788 authored by svn-taljeth's avatar svn-taljeth
Browse files

+ CDI: IO-Port-Zugriffe

+ sis900: Soft-Reset der Karte


git-svn-id: svn+ssh://overgames.de/lost/trunk@647 1fb02b30-9e10-0410-89f7-8f5a202ca6a9
No related merge requests found
Showing with 151 additions and 0 deletions
+151 -0
/*
* Copyright (c) 2007 Kevin Wolf
*
* This program is free software. It comes without any warranty, to
* the extent permitted by applicable law. You can redistribute it
* and/or modify it under the terms of the Do What The Fuck You Want
* To Public License, Version 2, as published by Sam Hocevar. See
* http://sam.zoy.org/projects/COPYING.WTFPL for more details.
*/
#ifndef _CDI_IO_H_
#define _CDI_IO_H_
#include <stdint.h>
static inline uint16_t cdi_inw(uint16_t _port)
{
uint16_t result;
__asm__ ("inw %1, %0" : "=a" (result) : "Nd" (_port));
return result;
}
static inline uint8_t cdi_inb(uint16_t _port)
{
uint8_t result;
__asm__ ("inb %1, %0" : "=a" (result) : "Nd" (_port));
return result;
}
static inline uint32_t cdi_inl(uint16_t _port)
{
uint32_t result;
__asm__ ("inl %1, %0" : "=a" (result) : "Nd" (_port));
return result;
}
static inline void cdi_outw(uint16_t _port, uint16_t _data)
{
__asm__ ("outw %0, %1" : : "a" (_data), "Nd" (_port));
}
static inline void cdi_outb(uint16_t _port, uint8_t _data)
{
__asm__ ("outb %0, %1" : : "a" (_data), "Nd" (_port));
}
static inline void cdi_outl(uint16_t _port, uint32_t _data)
{
__asm__ ("outl %0, %1" : : "a"(_data), "Nd" (_port));
}
#endif
......@@ -36,10 +36,22 @@
#include <stdint.h>
#include "cdi.h"
#include "device.h"
#include "io.h"
static void reset_nic(struct sis900_device* device)
{
reg_outl(device, REG_COMMAND, CR_RESET);
while (reg_inl(device, REG_COMMAND) & CR_RESET);
}
void sis900_init_device(struct cdi_driver* driver, struct cdi_device* device)
{
struct sis900_device* netcard = (struct sis900_device*) device;
reset_nic(netcard);
}
void sis900_remove_device(struct cdi_driver* driver, struct cdi_device* device)
......
......@@ -40,9 +40,15 @@
#include "cdi/net.h"
#include "cdi/pci.h"
#define REG_COMMAND 0x00
#define CR_RESET 0x100
struct sis900_device {
struct cdi_net_device dev;
struct cdi_pci_device* pci;
uint16_t port_base;
};
void sis900_init_device(struct cdi_driver* driver, struct cdi_device* device);
......
/*
* Copyright (c) 2007 The LOST Project. All rights reserved.
*
* This code is derived from software contributed to the LOST Project
* by Kevin Wolf.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the LOST Project
* and its contributors.
* 4. Neither the name of the LOST Project nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _SIS900_IO_H_
#define _SIS900_IO_H_
#include <stdint.h>
#include "cdi/io.h"
static inline void reg_outb
(struct sis900_device* netcard, uint8_t reg, uint8_t value)
{
cdi_outb(netcard->port_base + reg, value);
}
static inline void reg_outw
(struct sis900_device* netcard, uint8_t reg, uint16_t value)
{
cdi_outw(netcard->port_base + reg, value);
}
static inline void reg_outl
(struct sis900_device* netcard, uint8_t reg, uint32_t value)
{
cdi_outl(netcard->port_base + reg, value);
}
static inline uint8_t reg_inb(struct sis900_device* netcard, uint8_t reg)
{
return cdi_inb(netcard->port_base + reg);
}
static inline uint16_t reg_inw(struct sis900_device* netcard, uint8_t reg)
{
return cdi_inw(netcard->port_base + reg);
}
static inline uint32_t reg_inl(struct sis900_device* netcard, uint8_t reg)
{
return cdi_inl(netcard->port_base + reg);
}
#endif
......@@ -120,4 +120,6 @@ static void sis900_device_init(
struct sis900_device* device, struct cdi_pci_device* pcidev)
{
device->pci = pcidev;
// TODO port_base initialisieren
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment