These patches can be used on other platforms, so move it to generic. Signed-off-by: Chukun Pan <amadeus@jmu.edu.cn> (cherry picked from commit cc2a8c2545)
cc2a8c2545