The X-ray-derived cosmological star formation history and the galaxy X-ray luminosity functions in the Chandra Deep Fields North and South