Getting compilation error while writing standalone for ddi_get8


 
Thread Tools Search this Thread
Top Forums Programming Getting compilation error while writing standalone for ddi_get8
# 1  
Old 11-24-2011
Getting compilation error while writing standalone for ddi_get8

Hi All,

I have already posted a thread regarding ddi_regs_map_setup solaris system call guidance.

https://www.unix.com/programming/1719...stem-call.html


I am writing a standalone to use this system call.

Below is my partial standalone where i have only the declaration part:

Code:
#include <stdio.h>
#include <sys/dditypes.h>
#include <sys/conf.h>
#include <sys/ddi.h>
#include <sys/sunddi.h>

int main()
{
  dev_info_t *dip;
  uint_t     rnumber;
  ushort_t  *dev_addr;
  offset_t   offset;
  offset_t   len;
  ushort_t   dev_command;
  ddi_device_acc_attr_t dev_attr;
  ddi_acc_handle_t handle;
  dev_attr.devacc_attr_version = DDI_DEVICE_ATTR_V0;
  dev_attr.devacc_attr_endian_flags = DDI_STRUCTURE_LE_ACC;
  dev_attr.devacc_attr_dataorder = DDI_STRICTORDER_ACC;

  return 0;
}


The standalone give the following compilation errors:

Code:
ddiSystemcall.c: In function `main':
ddiSystemcall.c:15: error: `ddi_device_acc_attr_t' undeclared (first use in this function)
ddiSystemcall.c:15: error: (Each undeclared identifier is reported only once
ddiSystemcall.c:15: error: for each function it appears in.)
ddiSystemcall.c:15: error: syntax error before "dev_attr"
ddiSystemcall.c:16: error: `ddi_acc_handle_t' undeclared (first use in this function)
ddiSystemcall.c:17: error: `dev_attr' undeclared (first use in this function)
ddiSystemcall.c:17: error: `DDI_DEVICE_ATTR_V0' undeclared (first use in this function)
ddiSystemcall.c:18: error: `DDI_STRUCTURE_LE_ACC' undeclared (first use in this function)
ddiSystemcall.c:19: error: `DDI_STRICTORDER_ACC' undeclared (first use in this function)

Please let me know where am i going wrong.

Thanks in advance.

Moderator's Comments:
Mod Comment Moved to Programming. Also, please use [CODE] tags where appropriate

Last edited by pludi; 11-24-2011 at 10:06 AM..
# 2  
Old 11-28-2011
Try struct ddi_device_acc_attr_t dev_attr;
# 3  
Old 11-29-2011
Hi corona,

Thanks for the reply. I tried your changes. it still gives compilation errors:

Code:
sample.c: In function `main':
sample.c:25: error: storage size of 'dev_attr' isn't known
sample.c:26: error: `ddi_acc_handle_t' undeclared (first use in this function)
sample.c:26: error: (Each undeclared identifier is reported only once
sample.c:26: error: for each function it appears in.)
sample.c:26: error: syntax error before "handle"
sample.c:27: error: `DDI_DEVICE_ATTR_V0' undeclared (first use in this function)
sample.c:28: error: `DDI_STRUCTURE_LE_ACC' undeclared (first use in this function)
sample.c:29: error: `DDI_STRICTORDER_ACC' undeclared (first use in this function)


Since i am using a pre declated structure. Should i still declare it has struct in my code ?

This is how it is declared in "/usr/include/sys/dditypes.h":

Code:
typedef struct ddi_device_acc_attr {
  ushort_t devacc_attr_version;
  uchar_t devacc_attr_endian_flags;
  uchar_t devacc_attr_dataorder;
  uchar_t devacc_attr_access;   /* access error protection */
} ddi_device_acc_attr_t;

# 4  
Old 11-29-2011
If your code is now 25 lines long, you've changed it significantly. As my crystal ball is still down for maintenance I'll need you to post your updated code.
# 5  
Old 11-30-2011
Hi Corono,

I saw the header file dditypes.h and found that the the structures ddi_device_acc_attr_t and ddi_acc_handle_t are defined under "ifdef _KERNEL"

So while compiling i set the _KERNEL with -D option.

But now i am getting undefined reference error. Below is the code for accessing pci config space:

Code:
#include <sys/dditypes.h>
#include <sys/conf.h>
#include <sys/ddi.h>
#include <sys/sunddi.h>

#define CONFIG_VENDOR_ID_OFFSET 0x0
#define CONFIG_DEVICE_ID_OFFSET 0x2
#define CONFIG_CLASS_CODE_OFFSET 0x8
#define CONFIG_BASE_ADDR_2_OFFSET 0x18
#define CONFIG_REGS_SIZE 0x40

static struct ddi_device_acc_attr endian_attr = {
  DDI_DEVICE_ATTR_V0,
  DDI_STRUCTURE_LE_ACC,
  DDI_STRICTORDER_ACC
};

xxx_map_regs(dev_info_t *dip) {
  caddr_t configp; /* pointer to configuration space */
  caddr_t mem_reg1; /* pointer to memory space 1 */
  size_t mem_size; /* size of memory space as shown in "reg" */
  ddi_acc_handle_t handle0; /* Access handle for configuration space */
  ddi_acc_handle_t handle2; /* Access handle for memory space 1 */
  ulong_t base_addr2; /* Base address 1 value (rnumber = 2) */
  ushort_t vendor_id, device_id;
  uint_t class_code;
  /*
   * configp is the kernel virtual address that maps to the device
   * configuration space, rnumber is 0.
   */
  int status = ddi_regs_map_setup(dip, 0, &configp, 0, CONFIG_REGS_SIZE,
      &endian_attr, &handle0);
  /*

   * Comparing with the corresponding properties,
   * vendor_id should be 0x00001000.
   * device_id should be 0x0000000f.
   * class_code should be 0x00010000.
   * baddr1 should be 18000.
   */
   vendor_id = ddi_get8(handle0, configp + CONFIG_VENDOR_ID_OFFSET);
   device_id = ddi_get8(handle0, configp + CONFIG_DEVICE_ID_OFFSET);
   base_addr2 = ddi_get64(handle0, configp + CONFIG_BASE_ADDR_2_OFFSET);
   class_code = (uint_t)ddi_get64(handle0, configp + CONFIG_CLASS_CODE_OFFSET);
   class_code = (uint_t)(class_code >> 8);
}

int main()
{
  dev_info_t  *dip;
  dip =  (dev_info_t *)ddi_root_node();
  xxx_map_regs(dip);
  return 0;
}

Below is the error i get when i compile:

Code:
S213:/export/home/vijay/Programs/NEW_PCI # gcc pciinfo.c -D_KERNEL
pciinfo.c: In function `xxx_map_regs':
pciinfo.c:78: warning: passing arg 2 of `ddi_getll' from incompatible pointer type
pciinfo.c:80: warning: passing arg 2 of `ddi_getll' from incompatible pointer type
Undefined                       first referenced
 symbol                             in file
ddi_regs_map_setup                  /var/tmp//ccM91uBL.o
ddi_getb                            /var/tmp//ccM91uBL.o
ddi_root_node                       /var/tmp//ccM91uBL.o
ddi_getll                           /var/tmp//ccM91uBL.o
ld: fatal: Symbol referencing errors. No output written to a.out
collect2: ld returned 1 exit status


Please let me know if ddi system calls have some libraries to be included while compiling.
# 6  
Old 11-30-2011
According to this they are functions for device drivers, not for use in userspace. They will never work.
# 7  
Old 12-01-2011
Hi Corono,

I saw the man page. It said:

Quote:
Context

These functions can be called from user, kernel, or interrupt context.

Please clarify me how to confirm that these calls are only for device drivers ?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Proc compilation error.

I'm trying to compile a proc program when use make -f proc.mk , it gives the following error . `/export/home/app/oracle/product/10.2.0/lib/libclntsh.so' is up to date. rateutil.o: No such file or directory Please advise ,, I need urgent help. Thanks, Omar Atia:) (2 Replies)
Discussion started by: atiato
2 Replies

2. Programming

Compilation Error

I am getting the below given errors for the following program though all the variables have been declared and used appropriately. Please Help. The environment is AIX. Error: ------ "gbsizeprofile.c", line 67.4: 1506-275 (S) Unexpected text 'void' encountered. "gbsizeprofile.c", line 67.10:... (2 Replies)
Discussion started by: yschd
2 Replies

3. Programming

Compilation error : Please help

state_field state_abvr = { "AL","ALABAMA", "AK","ALASKA", "AZ","ARIZONA", "AR","ARKANSAS", "CA","CALIFORNIA", "CO","COLORADO", "CT","CONNECTICUT", "DE","DELAWARE", "DC","DISTRICT-OF-COLUMBIA", "FL","FLORIDA", "GA","GEORGIA", "HI","HAWAII", "ID","IDAHO", "IL","ILLINOIS",... (1 Reply)
Discussion started by: jagan_kalluri
1 Replies

4. Programming

C Question compilation error

What does the following mean: state_field state_abvr = { "AL","ALABAMA", "AK","ALASKA", . . . }; extern state_field state_abvr; issues we I am facing following compilation issue bosdf9d1:root make CC -I/bto/bcs/shared/include -I/bto/sys/BCS/usr/include ... (1 Reply)
Discussion started by: jaganreddy
1 Replies

5. HP-UX

compilation error

hello everyone, here i am attempting to compile a c++ submodule.OS is HP-UX. here i am getting the following error. ====================================== "Make: Don't know how to make compile. Stop." =================================== could you pls somebody suggest why this error is... (2 Replies)
Discussion started by: mannam srinivas
2 Replies

6. Linux

c++ compilation error

Hello every one, here i am attempting to compile a c++ module using gcc.it is throwing a error . error: ==== > make -S dummyCHARGP /usr/local/bin/gcc -g -DDEBUG -DMAT -I. -I/swtemp/usbs/cc/unix-ce/root/subsys/lib/Linux/ -I/opt/dce/include -I/opt/dce/include/dce ... (12 Replies)
Discussion started by: mannam srinivas
12 Replies

7. Programming

Compilation error

I am compiling a software xchm on solaris 10. First i run './configure' There is no error. But when i start compiling using 'gmake' following error shown /usr/local/include/wx-2.6/wx/x11/brush.h: In copy constructor `wxBrush::wxBrush(const wxBrush&)':... (3 Replies)
Discussion started by: mansoorulhaq
3 Replies

8. Programming

compilation error

Hi, While trying compile a C++ file in UNIX with gcc whose make rule involves the usage of /usr/ccs/bin/as, I get the following error: /usr/ccs/bin/as: No such file or directory /usr/ccs/bin/as: error: write error on output file "<filename>.o" *** Error code 1 clearmake: Error: Build... (2 Replies)
Discussion started by: smanu
2 Replies

9. Programming

Regarding compilation error.

Hi All, I facing the following compilation error; when I implementing the following logic. ostrstream ostr; ostr << (( scAxsm.getRecord( i ).getField( 2 ).getShort())%12)!=0?(( scAxsm.getRecord( i ).getField( 2 ).getShort())/12+1) : (( scAxsm.getRecord( i ).getField( 2 ).getShort())/12) <<... (1 Reply)
Discussion started by: sweta
1 Replies

10. UNIX for Dummies Questions & Answers

Pthread compilation error

I have trouble compiling a pthread program on unix system which suppotrs pthreads it gives unresolved _pthread_create _pthread_exit error. what to do? (1 Reply)
Discussion started by: basavaraj_m
1 Replies
Login or Register to Ask a Question