where is "struct resource_list" defined ?

Kernel development, writing drivers, coding, and questions regarding FreeBSD internals.

where is "struct resource_list" defined ?

Postby liuwang » 14 Nov 2011, 17:39

Where is [file]struct resource_list[/file] defined? Could not be found in [FILE]/usr/src[/FILE].
liuwang
Junior Member
 
Posts: 31
Joined: 19 Aug 2011, 19:10

Postby plamaiziere » 14 Nov 2011, 20:15

liuwang wrote:where is "struct resource_list" defined ?
Could not be found in /usr/src.


This is a [FILE]STAILQ[/FILE] of [FILE]resource_list_entry[/FILE], see [man=3]queue[/man].

http://fxr.watson.org/fxr/source/sys/bus.h?v=FREEBSD8;im=3#L246

Regards
plamaiziere
Member
 
Posts: 184
Joined: 04 Jan 2009, 21:37
Location: Rennes, France

Postby liuwang » 14 Nov 2011, 23:05

plamaiziere,

Thanks.
[FILE]<sys/queue.h>[/FILE] and [FILE]<sys/bus.h>[/FILE] are included and won't resovle the compiling errors.

Sincerely,
Liu
liuwang
Junior Member
 
Posts: 31
Joined: 19 Aug 2011, 19:10

Postby SirDice » 15 Nov 2011, 07:47

Perhaps if you showed us the code and the exact error we may be able to help.
Senior UNIX Engineer at Unix Support Nederland
Experience is something you don't get until just after you need it.
User avatar
SirDice
Old Fart
 
Posts: 16185
Joined: 17 Nov 2008, 16:50
Location: Rotterdam, Netherlands

Postby liuwang » 15 Nov 2011, 19:16

SirDice,

Thanks the help here.

The project is to port our PCIe controller card to FreeBSD from Linux. When porting Linux function [file]pci_request_regions()[/file] to FreeBSD we met the compiling error
Code: Select all
error: dereferencing pointer to incomplete type
at the c sentences of [file]rl = &dinfo->resources;[/file] in the following code segment.

[cmd=]make depend[/cmd] has been launched in kernel level and doesn't help.

Local type casting has been tried and doesn't help either.

Looks we go astray the PCIe porting methodology in FreeBSD.

Sincerely,
Liu

Code: Select all
/*----------------------------
 *
 * AOC_main.c
 *
 * x8 PCIe controller driver
 ---------------------------*/
 
#include <sys/param.h>
#include <sys/module.h>
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/errno.h>
#include <sys/conf.h>
#include <sys/uio.h>
#include <sys/malloc.h>
#include <sys/bus.h>
#include <sys/types.h>
#include <machine/bus.h>
#include <sys/rman.h>
#include <machine/resource.h>

#include <dev/pci/pcivar.h>
#include <dev/pci/pcireg.h>
#include <sys/queue.h>
#include <sys/bus.h>
#include <sys/pciio.h>
#include <dev/pci/pci_private.h>
#include <asm/atomic.h>
#include <bus_if.h>
#include <AOC.h>
#define VENDOR_ID  0x1b4b
#define MAX_REQUEST_NUMBER_PERFORMANCE   4096


struct AOC_softc
{
  device_t AOC_dev;
  struct cdev *AOC_cdev;
};

static int AOC_pci_request_regions( struct device *dev, const char *res_name )
{
  int i,j;
  int rid;
  int bar;
  struct resource_list_entry *rle;
  struct pci_devinfo *dinfo;
  struct resource_list *rl=NULL;

  for ( i = 0; i <= PCIR_MAX_BAR_0; i++ )
  {
    bar = PCIR_BAR( i );
    dinfo = dev->ivars;
    rl = &dinfo->resources;
    rle = resource_list_find( rl, SYS_RES_MEMORY, i );
    if( rle == NULL )
    {
      dinfo = device_get_ivars(dev);
      rl = &dinfo->resources;
      rle = resource_list_find( rl, SYS_RES_IOPORT, i );
    };
    if( rle == NULL )
    return (-ENODEV);
    rid = PCIR_BAR( i );
    if (bus_alloc_resource_any(dev, rle->type, &rid, RF_ACTIVE) == NULL)
    {
      for (j = 0; j <= PCIR_MAX_BAR_0; j++)
      {
        {
          bar = PCIR_BAR( bar );
          {
            dinfo = device_get_ivars( dev );
            rl = &dinfo->resources;
            rle = resource_list_find( rl, SYS_RES_MEMORY, j );
          };
          if ( rle == NULL )
          {
              dinfo = device_get_ivars( dev );
              rl = &dinfo->resources;
              rle = resource_list_find( rl, SYS_RES_IOPORT, i );
          };
        };
   if (rle == NULL)
   bus_release_resource(dev, rle->type, rle->rid, rle->res);
      };
      return (-EINVAL);
    };
  }
  return (0);
};

static int AOC_probe( device_t dev )
{
  device_printf( dev, "AOC Probe\nVendor ID : 0x%x\nDevice ID : 0x%x\n", pci_get_vendor( dev ), pci_get_device( dev ) );
  if ( pci_get_vendor( dev ) == VENDOR_ID )
  {
    printf( "AOC probe successful !\n" );
    device_set_desc( dev, "AOC");

    pci_enable_io( dev, SYS_RES_IOPORT );
    pci_enable_io( dev, SYS_RES_MEMORY );

    AOC_pci_request_regions(dev, "AOC");
    ...
    ...
};
liuwang
Junior Member
 
Posts: 31
Joined: 19 Aug 2011, 19:10

Postby wblock@ » 15 Nov 2011, 20:31

Please put code inside [code] blocks so the formatting is preserved.

It's probably better to ask these questions on the mailing lists. freebsd-drivers might be the place to start.
User avatar
wblock@
Old Fart
 
Posts: 10204
Joined: 07 Sep 2009, 23:23
Location: Milky Way galaxy

Re-format: Where is " resource_list " defined ?

Postby liuwang » 15 Nov 2011, 22:33

Wblock,

Thanks.
Will do.

Sincerely,
Liu


Code: Select all
*----------------------------
*
* AOC_main.c
*
* x8 PCIe controller driver
---------------------------*/

#include <sys/param.h>
#include <sys/module.h>
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/errno.h>
#include <sys/conf.h>
#include <sys/uio.h>
#include <sys/malloc.h>
#include <sys/bus.h>
#include <sys/types.h>
#include <machine/bus.h>
#include <sys/rman.h>
#include <machine/resource.h>

#include <dev/pci/pcivar.h>
#include <dev/pci/pcireg.h>
#include <sys/queue.h>
#include <sys/bus.h>
#include <sys/pciio.h>
#include <dev/pci/pci_private.h>
#include <asm/atomic.h>
#include <bus_if.h>
#include <AOC.h>
#define VENDOR_ID 0x1b4b
#define MAX_REQUEST_NUMBER_PERFORMANCE 4096


struct AOC_softc
{
  device_t AOC_dev;
  struct cdev *AOC_cdev;
};

static int AOC_pci_request_regions( struct device *dev, const char *res_name )
{
  int i,j;
  int rid;
  int bar;
  struct resource_list_entry *rle;
  struct pci_devinfo *dinfo;
  struct resource_list *rl=NULL;

  for ( i = 0; i <= PCIR_MAX_BAR_0; i++ )
  {
    bar = PCIR_BAR( i );
    dinfo = dev->ivars;
    rl = &dinfo->resources;
    rle = resource_list_find( rl, SYS_RES_MEMORY, i );
    if( rle == NULL )
    {
      dinfo = device_get_ivars(dev);
      rl = &dinfo->resources;
      rle = resource_list_find( rl, SYS_RES_IOPORT, i );
    };
    if( rle == NULL )
    return (-ENODEV);
    rid = PCIR_BAR( i );
    if (bus_alloc_resource_any(dev, rle->type, &rid, RF_ACTIVE) == NULL)
    {
      for (j = 0; j <= PCIR_MAX_BAR_0; j++)
      {
        {
          bar = PCIR_BAR( bar );
          {
            dinfo = device_get_ivars( dev );
            rl = &dinfo->resources;
            rle = resource_list_find( rl, SYS_RES_MEMORY, j );
          };
          if ( rle == NULL )
          {
            dinfo = device_get_ivars( dev );
            rl = &dinfo->resources;
            rle = resource_list_find( rl, SYS_RES_IOPORT, i );
          };
        };
        if (rle == NULL)
        bus_release_resource(dev, rle->type, rle->rid, rle->res);
      };
      return (-EINVAL);
    };
  }
  return (0);
};

static int AOC_probe( device_t dev )
{
  device_printf( dev, "AOC Probe\nVendor ID : 0x%x\nDevice ID : 0x%x\n", pci_get_vendor( dev ), pci_get_device( dev ) );
  if ( pci_get_vendor( dev ) == VENDOR_ID )
  {
    printf( "AOC probe successful !\n" );
    device_set_desc( dev, "AOC");

    pci_enable_io( dev, SYS_RES_IOPORT );
    pci_enable_io( dev, SYS_RES_MEMORY );

    AOC_pci_request_regions(dev, "AOC");
    ...
    ...
};
liuwang
Junior Member
 
Posts: 31
Joined: 19 Aug 2011, 19:10

Postby DutchDaemon » 16 Nov 2011, 00:45

[code], not [file] ...
User avatar
DutchDaemon
Old Fart
 
Posts: 10464
Joined: 16 Nov 2008, 20:17
Location: The Netherlands

Postby SirDice » 16 Nov 2011, 13:20

I am by no means a kernel hacker, not even a programmer actually..

But what happens if you change this:
Code: Select all
  struct resource_list_entry *rle;
  struct resource_list *rl=NULL;
{....snip.....}
    bar = PCIR_BAR( i );
    dinfo = dev->ivars;
    rl = [b]&[/b]dinfo->resources;
    rle = resource_list_find( rl, SYS_RES_MEMORY, i );


To this:
Code: Select all
  struct resource_list_entry *rle;
  struct resource_list *rl=NULL;
{....snip.....}
    bar = PCIR_BAR( i );
    dinfo = dev->ivars;
    rl = dinfo->resources;
    rle = resource_list_find( [b]&[/b]rl, SYS_RES_MEMORY, i );


Note the movement of the ampersand. Or just cut out that extra step, it doesn't seem to be used anywhere else anyway.

Code: Select all
  struct resource_list_entry *rle;
  struct resource_list *rl=NULL;
{....snip.....}
    bar = PCIR_BAR( i );
    dinfo = dev->ivars;
    rle = resource_list_find( &dinfo->resources, SYS_RES_MEMORY, i );
Senior UNIX Engineer at Unix Support Nederland
Experience is something you don't get until just after you need it.
User avatar
SirDice
Old Fart
 
Posts: 16185
Joined: 17 Nov 2008, 16:50
Location: Rotterdam, Netherlands

BTW Mr. John-Mark Gurney [jmg@funkthat.com] is helping me out with the methodology in

Postby liuwang » 16 Nov 2011, 17:53

SirDice,

Thanks your looking into this.

All combination of & * . -> have been tried and won't help in resolving this.

BTW Mr. John-Mark Gurney [jmg@funkthat.com] is helping me out with the methodology in porting our PCIe controller card from Linux to FreeBSD.

I am following his approach.

Sincerely,
Liu Wang
liuwang
Junior Member
 
Posts: 31
Joined: 19 Aug 2011, 19:10

Postby liuwang » 16 Nov 2011, 17:58

DutchDaemon,

By
Code: Select all
 do you mean [cmd] ?
I could only see [cmd]&[file] options there.

Should we manually quote it with [code] &
pair ?

Sincerely,
Liu
liuwang
Junior Member
 
Posts: 31
Joined: 19 Aug 2011, 19:10

Postby liuwang » 16 Nov 2011, 18:02

whoops ! It verified itself. I need to manually quote it with code&/code pair.

Sincerely,
Liu
liuwang
Junior Member
 
Posts: 31
Joined: 19 Aug 2011, 19:10

Postby SirDice » 17 Nov 2011, 07:38

liuwang wrote:BTW Mr. John-Mark Gurney [jmg@funkthat.com] is helping me out with the methodology in porting our PCIe controller card from Linux to FreeBSD.

I am following his approach.

Sounds like a plan :e

If you solve it, please share your solution. I'm sure other people might be interested.

By [code] do you mean [cmd] ?
I could only see [cmd]&[file] options there.

For future reference: BB Code List
Senior UNIX Engineer at Unix Support Nederland
Experience is something you don't get until just after you need it.
User avatar
SirDice
Old Fart
 
Posts: 16185
Joined: 17 Nov 2008, 16:50
Location: Rotterdam, Netherlands

Postby liuwang » 17 Nov 2011, 23:12

SirDice,

Will do sir.

Sincerely,
Liu
liuwang
Junior Member
 
Posts: 31
Joined: 19 Aug 2011, 19:10


Return to FreeBSD Development

Who is online

Users browsing this forum: No registered users and 0 guests