에러 원인좀 찾아주세요..
작성자 정보
- 쏭꼴통 작성
- 작성일
컨텐츠 정보
- 6,739 조회
- 1 댓글
- 0 추천
- 목록
본문
이 소스는 pci 디바이스에 관한 소스입니다..
vendor id와 device id를 등록하고 기계와 컴퓨터를 연결하여 기계의 이름과 주소를 알아내기 입니다.
에러 정말 많은대.. 원인좀 찾아주세요..
소스-->
#include <linux/module.h>
#include <linux/init.h>
#include <linux/ioport.h>
#include <linux/pci.h>
#define XX_DEV_MAJOR 0xfff
#define XXX_DEV_NAME 0xfff
int probe(struct pci_dev *dev, const struct pci_device_id *id);
void xxx_remove(struct pci_dev *dev);
int pci_enable_device(struct pci_dev *dev);
void pci_disable_device(struct pci_dev *dev);
int pci_bus_read_config_byte(struct pci_bus *bus, unsigned int devfn, int where, u8 *val);
int pci_bus_read_config_word(struct pci_bus *bus, unsigned int devfn, int where, u16 *val);
int pci_bus_read_config_dword(struct pci_bus *bus, unsigned int devfn, int where, u32 *val);
int pcibios_write_config_byte(struct pci_bus *bus, unsigned int devfn, int where, u8 *val);
int pcibios_write_config_word(struct pci_bus *bus, unsigned int devfn, int where, u16 *val);
int pcibios_write_config_dword(struct pci_bus *bus, unsigned int devfn, int where, u32 *val);
unsigned long pci_resource_start(struct pci_dev *dev, int bar);
unsigned long pci_resource_end(struct pci_dev *dev, int bar);
unsigned long pci_resource_len(struct pci_dev *dev, int bar);
unsigned long pci_resource_resource(struct pci_dev *dev, int bar);
int pci_request_regions(struct pci_dev*, char *dev_name);
void pci_release_regions(struct pci_dev*);
struct resource {
const char *name;
unsigned long start, end;
unsigned long flags;
struct resource *parent, *sibling, *child;
};
int xxx_read_info(struct pci_dev *dev)
{
u8 deviceid;
pci_read_config_byte(dev, PCI_DEVICE_ID, &deviceid);
return deviceid;
}
int pci_register_driver(struct pci_driver *drv);
void pci_unregister_driver(struct pci_driver *drv);
struct pci_device_id
{
__u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
__u32 subvendor, suvdevice; /* Subsystem ID's or PCI_ANY_ID */
__u32 class, class)mask; /* (class,subclass,prog-if) triplet */
kernel_ulong_t driver_data; /* Data private to the driver */
};
struct pci_driver {
struct list_head node;
char *name;
struct module *owner;
const struct pci_device_id *id_table;
int (*probe) (struct pci_dev *dev, const struct pci_device_id *id);
void (*remove) (struct pci_dev *dev);
int (*suspend) (struct pci_dev *dev, pm_message_t state);
int (*resume) (struct pci_dev *dev);
int (*enable_wake) (struct pci_dev *dev, pci_power_t state, int enable);
void (*shutdown) (struct pci_dev *dev);
struct device_driver driver;
struct pci_dynids dynids;
};
static struct pic_driver xxx_pci_driver = {
.name = "xxx",
.id_table = xxx_pci_tbl,
.probe = xxx_probe,
.remove = __devexit_p(xxx_remove),
#ifdef CONFIG_PM
.suspend = xxx_suspend,
.resume = xxx_resume,
#endif /* CONFIG_PM */
};
static int __init xxx_init_module (void)
{
return pci_register_driver(&xxx_pci_driver);
}
module_init(xxx_init_module);
static void __exit xxx_cleanup_module (void)
{
pci_unregister_driver (&xxx_pci_driver);
}
module_exit(xxx_cleanup_module);
int xxx_probe(struct pci_dev *dev, const struct pci_device_id *id)
{
pci_enable_device(dev);
// xxx_hw_addr = pci_resource_start(dev,0);
// xxx_addr_size = pci_resource_len(dev,0);
// pci_request_regions(dev, XXX_DEV_NAME);
// xxx_vaddr = ioremap(xxx_hw_addr, xxx_addr_size);
register_chrdev(XX_DEV_MAJOR, XXX_DEV_NAME, &xxx_fops);
// xxx_hardware_init();
return 0;
}
void xxx_remove(struct pci_dev *dev);
/////////////////////////////////////////////////////////////////////////////////////////////////
에러
make -C /lib/modules/2.6.18-164.el5/build SUBDIRS=/root modules
make[1]: Entering directory `/usr/src/kernels/2.6.18-164.el5-i686'
CC [M] /root/pci.o
/root/pci.c:26: error: expected identifier or ‘(’ before ‘struct’
/root/pci.c:26: error: expected ‘)’ before ‘->’ token
/root/pci.c:27: error: expected identifier or ‘(’ before ‘struct’
/root/pci.c:27: error: expected ‘)’ before ‘->’ token
/root/pci.c:28: error: expected identifier or ‘(’ before ‘struct’
/root/pci.c:28: error: expected ‘)’ before ‘->’ token
/root/pci.c:28: error: expected ‘)’ before ‘==’ token
/root/pci.c:28: error: expected ‘)’ before ‘?’ token
/root/pci.c:32: error: conflicting types for ‘pci_request_regions’
include/linux/pci.h:621: error: previous declaration of ‘pci_request_regions’ was here
/root/pci.c:36: error: redefinition of ‘struct resource’
/root/pci.c:55: error: redefinition of ‘struct pci_device_id’
/root/pci.c:58: error: expected ‘:’, ‘,’, ‘;’, ‘}’ or ‘__attribute__’ before ‘)’ token
/root/pci.c:58: error: expected identifier or ‘(’ before ‘)’ token
/root/pci.c:60: error: expected identifier or ‘(’ before ‘}’ token
/root/pci.c:62: error: redefinition of ‘struct pci_driver’
/root/pci.c:78: error: variable ‘xxx_pci_driver’ has initializer but incomplete type
/root/pci.c:79: error: unknown field ‘name’ specified in initializer
/root/pci.c:79: warning: excess elements in struct initializer
/root/pci.c:79: warning: (near initialization for ‘xxx_pci_driver’)
/root/pci.c:80: error: unknown field ‘id_table’ specified in initializer
/root/pci.c:80: error: ‘xxx_pci_tbl’ undeclared here (not in a function)
/root/pci.c:80: warning: excess elements in struct initializer
/root/pci.c:80: warning: (near initialization for ‘xxx_pci_driver’)
/root/pci.c:81: error: unknown field ‘probe’ specified in initializer
/root/pci.c:81: error: ‘xxx_probe’ undeclared here (not in a function)
/root/pci.c:81: warning: excess elements in struct initializer
/root/pci.c:81: warning: (near initialization for ‘xxx_pci_driver’)
/root/pci.c:82: error: unknown field ‘remove’ specified in initializer
/root/pci.c:82: warning: excess elements in struct initializer
/root/pci.c:82: warning: (near initialization for ‘xxx_pci_driver’)
/root/pci.c:84: error: unknown field ‘suspend’ specified in initializer
/root/pci.c:84: error: ‘xxx_suspend’ undeclared here (not in a function)
/root/pci.c:84: warning: excess elements in struct initializer
/root/pci.c:84: warning: (near initialization for ‘xxx_pci_driver’)
/root/pci.c:85: error: unknown field ‘resume’ specified in initializer
/root/pci.c:85: error: ‘xxx_resume’ undeclared here (not in a function)
/root/pci.c:85: warning: excess elements in struct initializer
/root/pci.c:85: warning: (near initialization for ‘xxx_pci_driver’)
/root/pci.c: In function ‘xxx_init_module’:
/root/pci.c:91: warning: passing argument 1 of ‘pci_register_driver’ from incompatible pointer type
/root/pci.c: In function ‘xxx_cleanup_module’:
/root/pci.c:97: warning: passing argument 1 of ‘pci_unregister_driver’ from incompatible pointer type
/root/pci.c: In function ‘xxx_probe’:
/root/pci.c:110: error: ‘xxx_fops’ undeclared (first use in this function)
/root/pci.c:110: error: (Each undeclared identifier is reported only once
/root/pci.c:110: error: for each function it appears in.)
/root/pci.c:110: warning: passing argument 2 of ‘register_chrdev’ makes pointer from integer without a cast
make[2]: *** [/root/pci.o] Error 1
make[1]: *** [_module_/root] Error 2
make[1]: Leaving directory `/usr/src/kernels/2.6.18-164.el5-i686'
make: *** [default] Error 2
꼭좀 찾아주세요~~
관련자료
-
이전
-
다음
정원용님의 댓글
- 정원용
- 작성일
일단 소스 첫부분의 함수 정의 부분이 pci.h 내에 정의된 내용과 충돌하지 않는지 한번 살펴보시는게 좋을듯 하네요.
에러메시지
/root/pci.c:32: error: conflicting types for ‘pci_request_regions’
include/linux/pci.h:621: error: previous declaration of ‘pci_request_regions’ was here
여기서 이미 선언이 다르게 되어 있는 등 header화일에서 해주고 있는 선언을 중복하고 있는것 같고,
26,27,28라인도 비슷한 원인인것 같은 느낌이 듭니다.
기본적으로 함수의 정의는 헤더파일에, 구현은 .c 파일에 해주시는게 맞다고 봅니다만.....