Converting IAR compiler code for ATmega8 to gcc

I'm trying to convert some code written using IAR to compile using gcc and have hit a wall with converting register definitions. They seem to be defined in <ioavr.h> but I have no access to this file so was wondering if someone has the IAR compiler and can discover/extract the relevant IO file(s) for the ATmega8 or point me in the right direction for changing them to gcc versions.

An example of the problem definitions...

void SPI_PowerControl(unsigned char ucPowerLevel)
{
  if (ucPowerLevel == plNormalPower)
  {
    SPI_MOSI_DDR = SPI_SCK_DDR = SPI_SS_DDR = 1;
    SPI_MISO_DDR = 0;
    SPSR_SPI2X = 1;
    SPCR |= (1 << SPE) | (1 << MSTR);
  }
  else if (ucPowerLevel == plLowPower)
  {
    SPSR_SPI2X = 0;
  }
  else
  {
    SPSR = 0x00;
    SPCR = 0x00;
    SPI_MOSI_DDR = SPI_SCK_DDR = SPI_SS_DDR = 0;
    SPI_MOSI_PORT = SPI_SCK_PORT = SPI_SS_PORT = 0;
  }
}

The list of errors is currently...

||=== Mega8 Mass Storage, Debug ===|
Drivers\MegaPeriph.cpp||In function 'void SPI_PowerControl(unsigned char)':expressionless:
Drivers\MegaPeriph.cpp|11|error: 'DDRB_DDB2' was not declared in this scope|
Drivers\MegaPeriph.cpp|11|error: 'DDRB_DDB1' was not declared in this scope|
Drivers\MegaPeriph.cpp|11|error: 'DDRB_DDB0' was not declared in this scope|
Drivers\MegaPeriph.cpp|13|error: 'DDRB_DDB3' was not declared in this scope|
Drivers\MegaPeriph.cpp|15|error: 'SPSR_SPI2X' was not declared in this scope|
Drivers\MegaPeriph.cpp|22|error: 'SPSR_SPI2X' was not declared in this scope|
Drivers\MegaPeriph.cpp|28|error: 'DDRB_DDB2' was not declared in this scope|
Drivers\MegaPeriph.cpp|28|error: 'DDRB_DDB1' was not declared in this scope|
Drivers\MegaPeriph.cpp|28|error: 'DDRB_DDB0' was not declared in this scope|
Drivers\MegaPeriph.cpp|29|error: 'PORTB_PORTB2' was not declared in this scope|
Drivers\MegaPeriph.cpp|29|error: 'PORTB_PORTB1' was not declared in this scope|
Drivers\MegaPeriph.cpp|29|error: 'PORTB_PORTB0' was not declared in this scope|
Drivers\MegaPeriph.cpp||In function 'void SPI_WriteByte(unsigned char)':expressionless:
Drivers\MegaPeriph.cpp|37|error: 'SPSR_SPIF' was not declared in this scope|
Drivers\MegaPeriph.cpp||In function 'unsigned char SPI_ReadByte()':expressionless:
Drivers\MegaPeriph.cpp|44|error: 'SPSR_SPIF' was not declared in this scope|
Drivers\MegaPeriph.cpp||In function 'void SPI_ByteIO(unsigned char*)':expressionless:
Drivers\MegaPeriph.cpp|52|error: 'SPSR_SPIF' was not declared in this scope|
Drivers\MegaPeriph.cpp||In function 'void SPI_BufferIO(unsigned char*, unsigned int)':expressionless:
Drivers\MegaPeriph.cpp|62|error: 'SPSR_SPIF' was not declared in this scope|
Drivers\MegaPeriph.cpp||In function 'void SPI_WriteBuffer(const unsigned char*, unsigned int)':expressionless:
Drivers\MegaPeriph.cpp|73|error: 'SPSR_SPIF' was not declared in this scope|
Drivers\MegaPeriph.cpp||In function 'void SPI_ReadBuffer(unsigned char*, unsigned int)':expressionless:
Drivers\MegaPeriph.cpp|83|error: 'SPSR_SPIF' was not declared in this scope|
Drivers\MegaPeriph.cpp||In function 'void SPI_SendConst(unsigned char, unsigned int)':expressionless:
Drivers\MegaPeriph.cpp|94|error: 'SPSR_SPIF' was not declared in this scope|
Drivers\MegaPeriph.cpp||In function 'void TWI_PowerControl(unsigned char)':expressionless:
Drivers\MegaPeriph.cpp|106|error: 'DDRD_DDD0' was not declared in this scope|
Drivers\MegaPeriph.cpp|106|error: 'DDRD_DDD1' was not declared in this scope|
Drivers\MegaPeriph.cpp|108|error: 'PORTD_PORTD0' was not declared in this scope|
Drivers\MegaPeriph.cpp|108|error: 'PORTD_PORTD1' was not declared in this scope|
Drivers\MegaPeriph.cpp|117|error: 'DDRD_DDD0' was not declared in this scope|
Drivers\MegaPeriph.cpp|117|error: 'DDRD_DDD1' was not declared in this scope|
Drivers\MegaPeriph.cpp|119|error: 'PORTD_PORTD0' was not declared in this scope|
Drivers\MegaPeriph.cpp|119|error: 'PORTD_PORTD1' was not declared in this scope|
||=== Build finished: 27 errors, 0 warnings (0 minutes, 0 seconds) ===|
||=== Build finished: 27 errors, 0 warnings (0 minutes, 0 seconds) ===|

avr-gcc uses different names for register bit. For example:

DDRD_DDD0
should be:
DDRD0

This:
PORTD_PORTD0
Should be:
PORTD0

and so on.

  1. You can download free versions of the IAR compilers if you register on their web site.

  2. The definitions with an underscore in the middle are single bit definitions. For example:

SPI_MISO_DDR = 0;

means set the DDR bit for the SPI MISO pin to 0. In general you need to use:

port &= ~(1 << bit);

where the original code sets a single bit to 0, and:

port |= (1 << bit);

where the original code sets a single bit to 1.