[S390] Move memory detection code to own file.