  (Abridged) The simultaneous UV to X-rays/gamma rays data obtained during the
multi-wavelength XMM/INTEGRAL campaign on the Seyfert 1 Mrk 509 are used in
this paper and tested against physically motivated broad band models. Each
observation has been fitted with a realistic thermal comptonisation model for
the continuum emission. Prompted by the correlation between the UV and soft
X-ray flux, we use a thermal comptonisation component for the soft X-ray
excess. The UV to X-rays/gamma-rays emission of Mrk 509 can be well fitted by
these components. The presence of a relatively hard high-energy spectrum points
to the existence of a hot (kT~100 keV), optically-thin (tau~0.5) corona
producing the primary continuum. On the contrary, the soft X-ray component
requires a warm (kT~1 keV), optically-thick (tau~15) plasma. Estimates of the
amplification ratio for this warm plasma support a configuration close to the
"theoretical" configuration of a slab corona above a passive disk. An
interesting consequence is the weak luminosity-dependence of its emission, a
possible explanation of the roughly constant spectral shape of the soft X-ray
excess seen in AGNs. The temperature (~ 3 eV) and flux of the soft-photon field
entering and cooling the warm plasma suggests that it covers the accretion disk
down to a transition radius $R_{tr}$ of 10-20 $R_g$. This plasma could be the
warm upper layer of the accretion disk. On the contrary the hot corona has a
more photon-starved geometry. The high temperature ($\sim$ 100 eV) of the
soft-photon field entering and cooling it favors a localization of the hot
corona in the inner flow. This soft-photon field could be part of the
comptonised emission produced by the warm plasma. In this framework, the change
in the geometry (i.e. $R_{tr}$) could explain most of the observed flux and
spectral variability.
