Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RTL8168 Implementation #1652

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions source/Cosmos.Core/Ports.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Cosmos.Core
{
public static class Ports
{
/// <summary>
/// Reads a byte
/// </summary>
/// <param name="port"></param>
/// <returns></returns>
public static byte InB(ushort port)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer we go with the same approach we have for other drivers as well, which is that we define all the the IOPorts we need and then access the one we actually need. For example see

public class ATA : IOGroup

That approach should be quicker since we arnt constantly creating new objects and less error prone than calculating the port address every time.

{
var io = new IOPort(port);
return io.Byte;
}

/// <summary>
/// Reads a 32 bit word
/// </summary>
/// <param name="port"></param>
/// <returns></returns>
public static uint InD(ushort port)
{
var io = new IOPort(port);
return io.DWord;
}

/// <summary>
/// Reads a 16 bit word
/// </summary>
/// <param name="port"></param>
/// <returns></returns>
public static ushort InW(ushort port)
{
var io = new IOPort(port);
return io.Word;
}

/// <summary>
/// Writes a byte
/// </summary>
/// <param name="port"></param>
/// <param name="data"></param>
public static void OutB(ushort port, byte data)
{
var io = new IOPort(port);
io.Byte = data;
}

/// <summary>
/// Writes a 32 bit word
/// </summary>
/// <param name="port"></param>
/// <param name="data"></param>
public static void OutD(ushort port, byte data)
{
var io = new IOPort(port);
io.DWord = data;
}

/// <summary>
/// Writes a 32 bit word
/// </summary>
/// <param name="port"></param>
/// <param name="data"></param>
public static void OutD(ushort port, uint data)
{
var io = new IOPort(port);
io.DWord = data;
}

/// <summary>
/// Writes a 16 bit word
/// </summary>
/// <param name="port"></param>
/// <param name="data"></param>
public static void OutW(ushort port, ushort data)
{
var io = new IOPort(port);
io.Word = data;
}
}
}
Loading