Devices which are Expunged but don't leave...

This forum is for general developer support questions.
Post Reply
Spirantho
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 34
Joined: Thu Jan 26, 2012 10:54 am

Devices which are Expunged but don't leave...

Post by Spirantho »

Hi everybody,

In my device I have a little Expunge function which just sets md->cw_device.dd_Library.lib_Flags |= LIBF_DELEXP and returns 0.

In the past I could get rid of the device using an avail flush or whatever, but now nothing I seem to do (since I updated to FE?) gets rid of the old device code so I have to keep rebooting to try my new builds.
Is there an example of what should be in my Expunge() routine to make it leave cleanly?

Thanks!
User avatar
trixie
Posts: 409
Joined: Thu Jun 30, 2011 2:54 pm
Location: Czech Republic

Re: Devices which are Expunged but don't leave...

Post by trixie »

@Spirantho

I've never coded a device but I'd say that the expunge procedure will be similar to (if not the same as) that of a library.

Normally, in the expunge function you should check the library instance counter (lib_OpenCnt), and if it is > 0, set lib_Flags |= LIBF_DELEXP and return 0 (LIBF_DELEXP stands for delayed expunge: something else is still using the library, so we can't expunge right now). If the counter == 0, you do your library cleanup, then IExec->Remove() from the system library list, and IExec->DeleteLibrary().
The Rear Window blog

AmigaOne X5000 @ 2GHz / 4GB RAM / Radeon RX 560 / ESI Juli@ / AmigaOS 4.1 Final Edition
SAM440ep-flex @ 667MHz / 1GB RAM / Radeon 9250 / AmigaOS 4.1 Final Edition
User avatar
tboeckel
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 68
Joined: Mon Jun 20, 2011 8:56 am
Contact:

Re: Devices which are Expunged but don't leave...

Post by tboeckel »

The latest SDK should include the "Expunge" tool to specifically expunge single libraries/devices (i.e. "Expunge my.device") or multiple libraries/devices matching a pattern (i.e. "Expunge my_#?.device" to expunge "my_first.device" and "my_second.device") from memory.

Apart from that you should obey what Trixie already said. The LIBF_DELEXP flag should only be set if your library/device cannot be expunged when your Expunge vector is called, because it is still opened. But if there are no living instances then you should of course do the actual expunging. When else would you do it otherwise if no in the Expunge vector?
User avatar
ssolie
Beta Tester
Beta Tester
Posts: 1010
Joined: Mon Dec 20, 2010 8:51 pm
Location: Canada
Contact:

Re: Devices which are Expunged but don't leave...

Post by ssolie »

Spirantho wrote:In the past I could get rid of the device using an avail flush or whatever, but now nothing I seem to do (since I updated to FE?) gets rid of the old device code so I have to keep rebooting to try my new builds...
There must be an error in your Expunge() vector implementation because it does work. There is some info on the wiki here:
http://wiki.amigaos.net/wiki/Exec_Devic ... g_a_Device

Normally, all you should have to do is replace the file and the OS will auto-magically expunge it for you.

In cases where replacing the file is not possible there is an Expunge command in your SDK to trigger an expunge manually.
ExecSG Team Lead
Post Reply