We propose and successfully test against new cosmological simulations a novel analytical description of the physical processes associated with the origin of cored dark matter density profiles. In the simulations, the potential in the central kiloparsec changes on sub-dynamical timescales over the redshift interval 4 > z > 2 as repeated, energetic feedback generates large underdense bubbles of expanding gas from centrally-concentrated bursts of star formation. The model demonstrates how fluctuations in the central potential irreversibly transfer energy into collisionless particles, thus generating a dark matter core. A supply of gas undergoing collapse and rapid expansion is therefore the essential ingredient. The framework, based on a novel impulsive approximation, breaks with the reliance on adiabatic approximations which are inappropriate in the rapidly-changing limit. It shows that both outflows and galactic fountains can give rise to cusp-flattening, even when only a few per cent of the baryons form stars. Dwarf galaxies maintain their core to the present time. The model suggests that constant density dark matter cores will be generated in systems of a wide mass range if central starbursts or AGN phases are sufficiently frequent and energetic.