Tiberiu Chibici
913e65b856
==================================================== + Changed 'align 0x4' line above multiboot header in loader.asm to 'align 4' + Removed -e option for echo in build.sh + Modified build.sh for linux + Fixed triple fault when enabling paging + Fixed page faults at memory manager initialization + Fixed 'mem' console function + Added more info about page fault at crash screen + Added Panic() macro + Added verbose mode for memory manager [ BAD] BUILD 0.1.0.390 DATE 8/27/2011 AT 10:54 PM ==================================================== + Added stdlib routines, separated in different files + Rewritten physical memory manager + Added virtual mem manager + Added memory allocation/freeing + Added memory library + Added temporary allocation (at end of kernel), until paging is started - Removed functionality from debug console function 'mem' - Removed system.h, the one remaining function now in stdio.h
112 lines
2.6 KiB
C
112 lines
2.6 KiB
C
/*
|
|
* dma.c
|
|
*
|
|
* Created on: Aug 20, 2011
|
|
* Author: Tiberiu
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include "dma.h"
|
|
|
|
void DmaSetAddress (uint8 channel, uint8 low, uint8 high)
|
|
{
|
|
uint16 port = 0;
|
|
|
|
switch (channel)
|
|
{
|
|
case 0: port = DmaRegisterChannel0Address; break;
|
|
case 1: port = DmaRegisterChannel1Address; break;
|
|
case 2: port = DmaRegisterChannel2Address; break;
|
|
case 3: port = DmaRegisterChannel3Address; break;
|
|
case 4: port = DmaRegisterChannel4Address; break;
|
|
case 5: port = DmaRegisterChannel5Address; break;
|
|
case 6: port = DmaRegisterChannel6Address; break;
|
|
case 7: port = DmaRegisterChannel7Address; break;
|
|
default: return;
|
|
}
|
|
|
|
outportb(port, low); iowait();
|
|
outportb(port, high);
|
|
}
|
|
|
|
void DmaSetCount (uint8 channel, uint8 low, uint8 high)
|
|
{
|
|
uint16 port = 0;
|
|
|
|
switch (channel)
|
|
{
|
|
case 0: port = DmaRegisterChannel0Count; break;
|
|
case 1: port = DmaRegisterChannel1Count; break;
|
|
case 2: port = DmaRegisterChannel2Count; break;
|
|
case 3: port = DmaRegisterChannel3Count; break;
|
|
case 4: port = DmaRegisterChannel4Count; break;
|
|
case 5: port = DmaRegisterChannel5Count; break;
|
|
case 6: port = DmaRegisterChannel6Count; break;
|
|
case 7: port = DmaRegisterChannel7Count; break;
|
|
default: return;
|
|
}
|
|
|
|
outportb(port, low); iowait();
|
|
outportb(port, high);
|
|
}
|
|
|
|
void DmaSetExternalPageRegisters (uint8 channel, uint8 val)
|
|
{
|
|
uint16 port = 0;
|
|
|
|
switch (channel)
|
|
{
|
|
case 1: port = DmaRegisterChannel1PageAddress; break;
|
|
case 2: port = DmaRegisterChannel2PageAddress; break;
|
|
case 3: port = DmaRegisterChannel3PageAddress; break;
|
|
case 5: port = DmaRegisterChannel5PageAddress; break;
|
|
case 6: port = DmaRegisterChannel6PageAddress; break;
|
|
case 7: port = DmaRegisterChannel7PageAddress; break;
|
|
default: return;
|
|
}
|
|
|
|
outportb(port, val);
|
|
}
|
|
|
|
void DmaResetFlipFlop (uint8 channel)
|
|
{
|
|
uint16 port = (channel < 4) ? DmaRegisterFlipFlopReset : 2*DmaRegisterFlipFlopReset+0xC0;
|
|
outportb(port, 0);
|
|
}
|
|
|
|
void DmaReset ()
|
|
{
|
|
outportb(DmaRegisterMasterReset, 0);
|
|
}
|
|
|
|
void DmaUnmaskAll()
|
|
{
|
|
outportb(DmaRegisterMaskReset, 0);
|
|
}
|
|
|
|
void DmaMaskChannel(uint8 channel)
|
|
{
|
|
if (channel >= 8) return;
|
|
uint16 port = (channel < 4) ? (DmaRegisterSingleChannelMask) : (2*DmaRegisterSingleChannelMask + 0xC0);
|
|
|
|
outportb(port, channel%4 | 4);
|
|
}
|
|
|
|
void DmaUnmaskChannel (uint8 channel)
|
|
{
|
|
if (channel >= 8) return;
|
|
uint16 port = (channel < 4) ? (DmaRegisterSingleChannelMask) : (2*DmaRegisterSingleChannelMask + 0xC0);
|
|
|
|
outportb(port, channel%4);
|
|
}
|
|
|
|
void DmaSetMode (uint8 channel, uint8 mode)
|
|
{
|
|
if (channel >= 8) return;
|
|
uint16 port = (channel < 4) ? (DmaRegisterMode) : (2*DmaRegisterMode + 0xC0);
|
|
|
|
DmaMaskChannel(channel);
|
|
outportb(port, (channel%4) | mode );
|
|
DmaUnmaskAll();
|
|
}
|