Nonadiabaticity in the initial oxidation of Mg(0001): First-principles density-functional calculations