Segmentation fault with outb()
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
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...
[Index of Archives]
[Newbies FAQ]
[Linux Kernel Mentors]
[Linux Kernel Development]
[IETF Annouce]
[Git]
[Networking]
[Security]
[Bugtraq]
[Yosemite]
[MIPS Linux]
[ARM Linux]
[Linux RAID]
[Linux SCSI]
[Linux ACPI]