I think you need to refer COM3 (0x0100) in
reference to ES (Extra Segment) register.
You first copy 0x00 to es register and
then refer in COM3 inrelation to es, bye es:COM3
I don’t know the syntax of Linux
Assmbly, but I hope you got my point.
I think you need to add following code before
refering COM3
movl $(0x00) %eax
movl %eax %es
After refering refer COM3 in reference to
es register.
I might be wrong, if I am wrong please
correct me.
Regards,
Gaurav
From:
kernelnewbies-bounce@xxxxxxxxxxxx [mailto:kernelnewbies-bounce@xxxxxxxxxxxx] On Behalf Of Raja.Hayek@xxxxxxxxxxxxxx
Sent: Tuesday, July 27, 2004 5:29
AM
To: kernelnewbies@xxxxxxxxxxxx
Subject: Segmentation fault with
outb()
I am trying to to set up my ports for IO with the low
level inb() and outb() in the code below. However, as soon as I write to the
COM port, I get a segmentation fault. The hardware uses a lava card with 8 COM
ports available.
I
know that similar code works in module form, whereby I insmod the module, and
set up my ports using in the init_module() function. Here, however, I am trying
to build it into a regular executable. But is that the reason?
TIA.
Raja
Hayek.
//
some includes up here...
#define
COM3 0x100
// the address given to
COM3 as per setserial
static
const int BRDL = 0;
// Baud rate divisor
register offset
static
const int BRDH = 1;
static
const int IER = 1;
static
const int LCR = 3;
// line control
register
static
const int LCR_data = 0x03;
// 8 bits, no parity, 1 stop bit
static
const int LCR_access_baudrate = 0x80; // allow
access to the baud rate divisor registers
static
const int baud19200high = 0;
static
const int baud19200low = 6;
static
const int IER_data = 0;
// disable all COM interrupts
int
main()
{
outb(LCR_access_baudrate, COM3+LCR); //
COM3: this line causes segmentation fault
outb(baud19200low, COM3+BRDL);
// Setup the baud rate divisor
outb(baud19200high, COM3+BRDH);
outb(LCR_data, COM3+LCR);
// Access TX and RX data ports
outb(IER_data, COM3+IER);
// Setup interrupt masks
//
more code down here...