Main Page Data Structures File List Data Fields Globals Related Pages

# amd186.cpp File Reference

`#include <iostream>`
`#include <dos.h>`
`#include <stdio.h>`
`#include "clib/hwapi.h"`
`#include "amd186.h"`

Go to the source code of this file.

## Functions
void | REP_INSB (int port, void *dest, int numBytes)
| Wrapper for REP INSB instruction.
void | REP_INSW (int port, void *dest, int numWords)
| Wrapper for REP INSW instruction.
void | REP_OUTSB (int port, void *src, int numBytes)
| Wrapper for REP OUTSB instruction.
void | REP_OUTSW (int port, void *src, int numWords)
| Wrapper for REP OUTSW instruction.
void | usleep (unsigned us)
| Wait some microseconds.
void | AMD_TestPios ()
| Test the mapping between SC12 and AMD PIO pins.
void | AMD_SetPioData (unsigned long mask, unsigned long data)
| Set the AMD PIO Data register.
void | AMD_SetPioDir (unsigned long mask, unsigned long dir)
| Set the AMD PIO Direction register.
void | AMD_SetPioMode (unsigned long mask, unsigned long mode)
| Set the AMD PIO Mode register.
void | AMD_SetPcsWaitStates (int waitstates)
| Set PCS0-3 Chipselect Waitstates.
void | AMD_StartDma (int channel, DmaInfo *dma)
| Initiate a DMA Transfer.
void | AMD_StopDma (int channel)
| Immediately Stop a DMA Transfer.
void | AMD_GetDmaInfo (int channel, DmaInfo *dma)
| Get information about current DMA Transfer.
void | AMD_EnableDrq (int channel, int onoff)

## Function Documentation

void AMD_EnableDrq | ( | int | channel,
|  | int | onoff
| ) |

| Definition at line 464 of file amd186.cpp. References AMD_SetPioDir(), and AMD_SetPioMode(). Referenced by RC_Init(), SCI_ReadReg(), SCI_WriteReg(), VS_PlayMpegAsync(), and VS_Reset().

void AMD_GetDmaInfo | ( | int | channel,
|  | DmaInfo * | dma
| ) |

  | Get information about current DMA Transfer. \note: in order to read the DMA status reliably, a running transfer will be interrupted while the registers are read. This might be an issue, if you do something very timing critical! Parameters:
  channel | DMA channel, either 0 or 1
  dma | pointer to DMAInfo structure. May not be null.
Definition at line 424 of file amd186.cpp. References DmaInfo::control, DCON_DMIO, DCON_SMIO, DCON_ST, DCON_START, DCON_STOP, DmaInfo::dstMem, DmaInfo::dstPort, DmaInfo::length, PCB_D0CON, PCB_D0DSTL, PCB_D0SRCH, PCB_D0SRCL, PCB_D0TC, PCB_D1CON, PCB_D1DSTL, PCB_D1SRCH, PCB_D1SRCL, PCB_D1TC, DmaInfo::srcMem, and DmaInfo::srcPort. Referenced by timerHandler(), and VS_IsPlaying().

void AMD_SetPcsWaitStates | ( | int | waitstates | ) |

  | Set PCS0-3 Chipselect Waitstates. Note that you cannot modify the PCS5 and 6 waitstates. The SC12 hardware manual says that they must remain set to 3 waitstates. Parameters:
  waitstates | number of waitstates, the value is rounded up, if there's no exact match. Possible values are 0, 1, 2, 3, 5, 7, 9 and 15
Definition at line 350 of file amd186.cpp. References PCB_PACS.

void AMD_SetPioData | ( | unsigned long | mask,
|  | unsigned long | data
| ) |

  | Set the AMD PIO Data register. Please see the AMD186ED user manual before using this function. Always remember that there is a strange mapping between the SC12 PIO pins and the real AMD ones Parameters:
  data | data bits to write
  mask | only bits contained in the mask are touched
See also: AMD_PIO Definition at line 212 of file amd186.cpp. References PCB_PDATA0, and PCB_PDATA1.

void AMD_SetPioDir | ( | unsigned long | mask,
|  | unsigned long | dir
| ) |

  | Set the AMD PIO Direction register. Please see the AMD186ED user manual before using this function. Always remember that there is a strange mapping between the SC12 PIO pins and the real AMD ones Parameters:
  dir | direction bits to write
  mask | only bits contained in the mask are touched
See also: AMD_PIO Definition at line 258 of file amd186.cpp. References PCB_PDIR0, and PCB_PDIR1. Referenced by AMD_EnableDrq().

void AMD_SetPioMode | ( | unsigned long | mask,
|  | unsigned long | mode
| ) |

  | Set the AMD PIO Mode register. Please see the AMD186ED user manual before using this function. Always remember that there is a strange mapping between the SC12 PIO pins and the real AMD ones Parameters:
  mode | mode bits to write
  mask | only bits contained in the mask are touched
See also: AMD_PIO Definition at line 304 of file amd186.cpp. References PCB_PIOMODE0, and PCB_PIOMODE1. Referenced by AMD_EnableDrq().

void AMD_StartDma | ( | int | channel,
|  | DmaInfo * | dma
| ) |

  | Initiate a DMA Transfer. Please read chapter 9 of the AMD 186ED user manual before using this function (the DMAInfo structure should be quite self-explanatory then) Parameters:
  channel | DMA channel, either 0 or 1
  dma | filled DMAInfo structure
Definition at line 372 of file amd186.cpp. References DmaInfo::control, DCON_DMIO, DCON_SMIO, DCON_START, DCON_STOP, DmaInfo::dstMem, DmaInfo::dstPort, DmaInfo::length, PCB_D0CON, PCB_D0DSTH, PCB_D0DSTL, PCB_D0SRCH, PCB_D0SRCL, PCB_D0TC, PCB_D1CON, PCB_D1DSTH, PCB_D1DSTL, PCB_D1SRCH, PCB_D1SRCL, PCB_D1TC, src, DmaInfo::srcMem, and DmaInfo::srcPort. Referenced by RC_Init(), timerHandler(), and VS_PlayMpegAsync().

void AMD_StopDma | ( | int | channel | ) |

  | Immediately Stop a DMA Transfer. Parameters:
  channel | DMA channel to stop, either 0 or 1
Definition at line 403 of file amd186.cpp. References DCON_START, DCON_STOP, PCB_D0CON, and PCB_D1CON. Referenced by RC_Done(), and VS_Stop().

void AMD_TestPios | ( |  | ) |

| Test the mapping between SC12 and AMD PIO pins. This function doesn't need to be called by a user program, and is only useful if there's a new, incompatible revision of the @chip. (as they always promise ;) Warning: this function should only be used without any external hardware connected. Definition at line 182 of file amd186.cpp. References AMD_GetPioDir(), pfe_enable_pio(), PIO_IPD, PIO_IPU, and PIO_O0.

void REP_INSB | ( | int | port,
|  | void * | dest,
|  | int | numBytes
| ) |

  | Wrapper for REP INSB instruction. Parameters:
  port | i/o port to read from
  dest | memory buffer to read to
  numBytes | number of bytes to transfer
Definition at line 32 of file amd186.cpp.

void REP_INSW | ( | int | port,
|  | void * | dest,
|  | int | numWords
| ) |

  | Wrapper for REP INSW instruction. Parameters:
  port | i/o port to read from
  dest | memory buffer to read to
  numWords | number of words to transfer
Definition at line 63 of file amd186.cpp.

void REP_OUTSB | ( | int | port,
|  | void * | src,
|  | int | numBytes
| ) |

  | Wrapper for REP OUTSB instruction. Parameters:
  port | i/o port to write to
  src | memory buffer to read from
  numBytes | number of bytes to transfer
Definition at line 94 of file amd186.cpp. References src.

void REP_OUTSW | ( | int | port,
|  | void * | src,
|  | int | numWords
| ) |

  | Wrapper for REP OUTSW instruction. Parameters:
  port | i/o port to write to
  src | memory buffer to read from
  numWords | number of words to transfer
Definition at line 125 of file amd186.cpp. References src.

void usleep | ( | unsigned | us | ) |

  | Wait some microseconds. This function has been tested on an IPC@Chip SC12 at 20MHz, and is not very accurate. You can time the actual delay by using the ZTimer functions. Note: for a value of 10000, the function actually waits 11149 microseconds. Parameters:
  us | time to wait in microseconds
Todo: re-calibrate this function (push/pop added) Definition at line 159 of file amd186.cpp. Referenced by SCI_ReadReg(), SCI_WriteReg(), and VS_Reset().