cso: add new cso_save/restore_state() functions