RetroBSD

2.11BSD operating system for microcontrollers
It is currently Sat Apr 04, 2020 8:23 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Trying to write a driver
PostPosted: Sat Oct 17, 2015 8:44 pm 
Committer
User avatar

Joined: Thu Oct 11, 2012 8:45 am
Posts: 1801
Location: Room 217, Floor 8, Arm 8, Wheel S7, Mars Base Alpha 3
I'm currently trying to write a disk driver for Pito's 8MB ramdisk. However, the 411298462852301412649734 layers of macro crypticness are confusing the hell out of me.

So far I have worked out that I need to add entries to the bdevsw and cdevsw in mips/pic32/conf.c for bdev_disk_init(NSRAMC,sramc) and cdev_disk_init(NSRAMC,sramc), but it's not liking the cdev entry. I have the bdev working and it responds to opening the device as it should, but when I put the cdev entry in the list it can't compile:

Code:
../../mips/pic32/conf.c:66:28: error: pointer type mismatch in conditional expression [-Werror]
     (c > 0 ? __CONCAT(n,t) : (__CONCAT(dev_type_,t)((*))) enxio)
                            ^
../../mips/pic32/conf.c:139:55: note: in expansion of macro 'dev_init'
     dev_init(c,n,open), (dev_type_close((*))) nullop, dev_init(c,n,read), \
                                                       ^
../../mips/pic32/conf.c:282:5: note: in expansion of macro 'cdev_disk_init'
     cdev_disk_init(NSRAMC,sramc),   /* 10: */
     ^
../../mips/pic32/conf.c:66:28: error: pointer type mismatch in conditional expression [-Werror]
     (c > 0 ? __CONCAT(n,t) : (__CONCAT(dev_type_,t)((*))) enxio)
                            ^
../../mips/pic32/conf.c:140:5: note: in expansion of macro 'dev_init'
     dev_init(c,n,write), dev_init(c,n,ioctl), (dev_type_stop((*))) enodev, \
     ^
../../mips/pic32/conf.c:282:5: note: in expansion of macro 'cdev_disk_init'
     cdev_disk_init(NSRAMC,sramc),   /* 10: */
     ^

Because of the huge amount of macro obfuscation in there I have absolutely no clue what it's complaining about or even what it's even wanting. I basically copied the sd.c file and changed sd to sramc throughout (and deleted the sd specific stuff) just to try and get it going - so it should be happy with that.

Also I had to manually add function prototypes for the sramc* functions to conf.c, but I notice that there are no sd* prototypes anywhere that I can find - and yet it seems perfectly happy with that, and I really don't get how that can be. There must be something I am missing that means I don't need to add the prototypes, but Ganesh only knows what.

_________________
Why not visit my shop? http://majenko.co.uk/catalog
Universal IDE: http://uecide.org
"I was trying to find out if it was possible to only eat one Jaffa Cake. I had to abandon the experiment because I ran out of Jaffa Cakes".


Top
 Profile  
 
PostPosted: Sat Oct 17, 2015 8:59 pm 
Committer
User avatar

Joined: Thu Oct 11, 2012 8:45 am
Posts: 1801
Location: Room 217, Floor 8, Arm 8, Wheel S7, Mars Base Alpha 3
Found it

Code:
bdev_decl(sramc);
cdev_decl(sramc);

Now to make the driver work...

_________________
Why not visit my shop? http://majenko.co.uk/catalog
Universal IDE: http://uecide.org
"I was trying to find out if it was possible to only eat one Jaffa Cake. I had to abandon the experiment because I ran out of Jaffa Cakes".


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron




Powered by phpBB® Forum Software © phpBB Group

BSD Daemon used with permission