View Full Version: Dex4u Network

dex >>DexOS >>Dex4u Network


Dex- 06-09-2006
Dex4u Network
I am starting work on Dex4u's network code, i will add any intersting info here; PS: As i know very little about the way TCP/IP etc works, this means i am starting from scratch, i may if members want me to, post a sort of blog, so you can see how i get from not knowing anything, to full working TCP/IP stack etc. This may help other people with there projects for Dex4u.

redaman- 06-09-2006

I found this very interesting SO http://www.sics.se/~adam/contiki/ perhaps the network implementation with this aproach be nice... work well in 8bits.... i think this fly with dex

Dex- 06-09-2006

@redaman, First thank for the link :) and second i down load your Reda4, it worked great, nice work 8).

solidus117- 06-09-2006

Do you know the different layers and the methods to send packets, or is it that you know but never implemented a IP stack? I haven't either. :p

Dex- 06-10-2006

Do you know the different layers and the methods to send packets, or is it that you know but never implemented a IP stack? I haven't either. :p Yes i know the basic layers, etc, so its more i have never implemented a IP stack :wink: PS: Once we have it working , i think Dex4u will come into its own, as Dex4u will be well suted to network type programming.

tonyMac- 06-10-2006

I think we definitely will. We're drawing morea nd more attention, we're such a relatively new project, and we've come so far... I'll be wirting more code ina few weeks, it's finals week and my Test PC got buried under my bed. :( I've got to write down everything I've said I'd like to do, spin in circles 10 times, close my eyes and put my finger on one. :lol: I have been thinking, and I believe a terminal App would be extremely beneficial. I'd probably use a good deal of the Text editor for my interface, as long as that's ok. (I've got to watch myself, I'm becoming like M$, lots of vaporware.) :roll:

Dex- 06-10-2006

Maybe you could write a simple program, to pic one for you, then if its the wrong one blame your PC :lol:. Something like that, was my first visualbasic program, a lottery program and first time i used it, i won. And a terminal program would be great, and your welcome to use any code from tex4u or anyother program i have code :) .

DennisCGc- 06-11-2006

Woops, guess I haven't read this topic. Anyway, it looks like someone else is doing it? After looking more through the forum, I think networking is needed. Anyway, just don't forget there are far more protocols out there than only Ethernet, IP and TCP. I haven't taken a closer look to MenuetOS' stack, but I think it's badly designed. This is because: You have/had to recompile the ppp daemon, wtf? You can have only one NIC active at a time, never heard of having a routing table or such? It's slow. Very slow. I tested it on a PC which had a compatible NIC, but the speed was terrible This was done on MeOS 32 0.78 . Sorry for all the critics made, but mentioning MenuetOS' stack... neah, better stacks were made in the past. DennisCGc.

Dex- 06-11-2006

@DennisCGc, i know you are working on Dex4u's network code, but at the same time its time for me to learn more about this part of the OS, so there is know better way to learn than make, by us both working on it we can help each other (mostly you help me, as you know a lot more than me), and also compear our designs for speed etc.

tonyMac- 06-11-2006

Reminds me of a certain PCI developement race, which I lost horribly. :lol:

Dex- 06-12-2006

:lol: :lol: :lol:

Dex- 06-12-2006

RTL8139 Driver Part 1. As this project is going to be a tut too, i will start at the very basic (that where i always start ) and work our way up. First i will be making a driver, for my RealTek 8139 ethernet card, there are drivers out there, but i find it better to code your own and may use other drivers as a referance, only if something does not work. The drivers will start life as a normal program and be converted to a module later. Also do not worry about differant drivers at this stage, as because of the way the module interface work, you just need to load the right module for your card. So lets get coding first thing to do is test for a RTL8139 ethernet card on our PC. Here's how we do that: ;=========================================================; ; Test for RTL8139 12/06/06 ; ;---------------------------------------------------------; ; By Dex. ; ; ; ; To assemble use fasm as follows ; ; c:\fasm RTL8139.asm RTL8139.dex ; ;=========================================================; use32 ORG 0x200000 ; where our program is loaded to jmp start ; jump to the start of program. db 'DEX1' ; We check for this, to make sure it a valid Dex4u file. Msg1: db 'Press any key to test for RTL8139 ethernet card.',13,0 Msg2: db 'RTL8139 ethernet card, found! ;) ',13,0 MsgError: db 'Error!, RTL8139 ethernet card not found :(.',13,0 ;----------------------------------------------------; ; Start of program. ; ;----------------------------------------------------; start: mov ax,18h ; set ax to nonlinear base mov ds,ax ; add them to ds mov es,ax ; and es. ;----------------------------------------------------; ; Get calltable address. ; ;----------------------------------------------------; mov edi,Functions ; this is the interrupt mov al,0 ; we use to load the DexFunction.inc mov ah,0x0a ; with the address to dex4u functions. int 40h ;----------------------------------------------------; ; Try print string. ; ;----------------------------------------------------; mov esi,Msg1 ; this point's to our string. call [PrintString] ; this call the print function. call [WaitForKeyPress] ; is the wait for keypress function. mov eax,0x813910ec ; vendor + device ID call [PciFindDevice] ; Scan PCI bus for RTL8139 card jc CardNotFound ; IF no card print error and exit. mov dword[PciEthAddress],eax ;----------------------------------------------------; ; Print card found. ; ;----------------------------------------------------; mov esi,Msg2 ; this point's to our string. call [PrintString] ; this call the print function. call [WaitForKeyPress] ; is the wait for keypress function. ret ; This returns to the CLI/GUI ;----------------------------------------------------; ; Print card not found. ; ;----------------------------------------------------; CardNotFound: mov esi,MsgError ; this point's to our string. call [PrintString] ; this call the print function. call [WaitForKeyPress] ; is the wait for keypress function. ret ; This returns to the CLI/GUI ;----------------------------------------------------; ; Data. ; ;----------------------------------------------------; PciEthAddress dd 0 ;put here temp. include 'DexFunctions.inc' ; Here is where we includ our "DexFunctions.inc" file Now let test the code first before i install the card. Now lets try it with the card installed. Good that seems to work 8). RTL8139 Driver Part 2. The RTL8139 driver ( or anyother ethernet driver ), will only need to implement 4 functions. 1. Probe ( enables it ) 2. Reset ( a virgin state ) 3. Poll ( test for a received packet ) 4. Transmit (transmits a packet ) So we will start by writing each function, at the same time we will include some code, that will be used for testing and debuging, that can be removed later. First function we will write is the "Probe" function, luck for us, we have some built in Dex4u functions to help us. So let do some coding, first we will need some constans, that we will put in a include file called "EtherNetConst.inc", the info to make these constants will come from doc like rt8139.pdf, Linu, menuetOS and we will add them as needed. EtherNetConst.inc PciRegCommand equ 0x04 ; command reg PciBitPio equ 0 ; bit0: io space control PciBitMmio equ 1 ; bit1: memory space control PciBitMaster equ 2 ; bit2: device acts as a PCI master Probe function code Probe: mov eax,[PciEthAddress] add eax,PciRegCommand call [PciRegRead32] or dl, (1 shl PciBitMaster) or (1 shl PciBitPio) and dl, not (1 shl PciBitMmio)

Dex- 06-14-2006

Here is some study doc to go with this ethernet driver tut. http://www.thought.net/jason/dev/ether/RealTek/rt8139b.pdf I will add more code tomorrow ;).

tonyMac- 06-15-2006

Should we decide on an interface format, so that the hardware can be abstracted from all of that protocol rubbish? :lol: I need to look up ISA addressing, I have a few ISA ethernet cards :lol::lol: They are 10 Mbps cards. My Laptop uses a broadcom ethernet, I'm afraid a driver for it may be waaaaaaaaaay beyond my scope, since even Linux didn't support it until recently...

Dex- 06-16-2006

Should we decide on an interface format, so that the hardware can be abstracted from all of that protocol rubbish? :lol: I need to look up ISA addressing, I have a few ISA ethernet cards :lol::lol: They are 10 Mbps cards. The interface format is this, as i like to keep things simple. First we need to list minimum functions for ethernet card drivers. From what i have learnt so far, i make this 4. 1. Probe 2. Reset 3. Poll 4. Transmit Every ethernet driver module will implement at lest these 4 function and in the same order. Example of calling each of the above functions from Dex program, using module interface. ;----------------------------------------------------; ; Call a module function. ; ;----------------------------------------------------; mov esi,ModID ; Points to module ID string. mov ah,1 ; Module function number ( Probe ) call [ModuleFunction] ; call module function jnc @f ; jump if no error. call ModError ; If error call print error mesage. @@: mov esi,ModID mov ah,2 ;( Reset ) call [ModuleFunction] jnc @f call ModError @@: mov esi,ModID mov ah,3 ;( Poll ) call [ModuleFunction] jnc @f call ModError @@: mov esi,ModID mov ah,4 ;( Transmit ) call [ModuleFunction] jnc @f call ModError @@: call [WaitForKeyPress] ret ;----------------------------------------------------; ; ModError. ; ;----------------------------------------------------; ModError: mov esi,msg1 call [PrintString] ret ;----------------------------------------------------; ; Data. ; ;----------------------------------------------------; ModID db 'DEX4UETH',0 ;ID String Maybe we can mod the module interface, so we can call it directly, if we have any problems with speed :? . All ethenet modules will have the same ID eg: 'DEX4UETH' and function numbers, that means, all people have to do is load the right module for there card, and any program that users ethernet will not need to know type. :wink: . My Laptop uses a broadcom ethernet, I'm afraid a driver for it may be waaaaaaaaaay beyond my scope, since even Linux didn't support it until recently... I have the same card on one of my PC, to get it to work with linux, replaced it for a RTL8139, not as easy on a laptop, but as i have that card if a driver can be made, at lest we both have test cards :) .

Forumer™ is Voted #1 Free Forum Hosting provider
Build your own community today with the largest message board hosting company.